Clickjacking and Facebook

english — Tags: , , , , — @ 00:29

Sometimes it amuses me how stupid and innocent we (humans) are. Detecting a scam when getting an email or receiving a call saying you won X amount of dollars is easy to tell. But when a friend is saying something is more complicated to detect the trick. Because it’s your friend saying it and you somehow trust him/her. Right?

Tonight I noticed the following link on my Facebook wall:

Clickjacking

Yes the first thing you notice is the butt of what it looks like a “schoolgirl”. It looks fishy after you see that lots of your friends liked that link. Is a really good meme or a trick. Anyway after googling victorialinn@live.com (the email included in the source code of the page) I found an interesting analysis of all this. It is so fascinating. Take your time to read that blog. Is really interesting.

Disclaimer: I would lie to you by saying I didn’t click it. I did it indeed. Naughty Mario I shouldn’t had clicked it. But hey I’m a man!! The photo was depicting a schoolgirl. I had to click it!! :)

Shorten URL: http://bit.ly/ik6GEzshorten url

Die bug!

english — Tags: , , , , , , — @ 13:29

Dead fly

Every once in a while I have to fix a bug that really drives me crazy. When this happens I usually recall one morning in the Computer Lab, back in college, one of my professors saying: “It doesn’t matter what you do, it doesn’t matter if you get upset or mad. You won’t beat the computer”. That morning I didn’t understand what he was trying to say. Actually I thought he was making fun of us. Foolish Mario, he wasn’t trying to do that. He was trying to advice us: to always stay calm.

Software Development could be stressful sometimes, if you write software you already know that. Even if you are an experienced programmer knowing the tools and loving writing software you will eventually face a situation, usually fixing a bug, that will drive you crazy and this gets worse when time is constrained, which usually is. At that time is when you have to breath deeply and evaluate every single piece of the puzzle. That’s when you begin enjoying the situation.

Software programmers like to fix, create and understand stuff, specially people with technical background, like me. We are also kind of masochists and we never give up. In my case I like saving those tips because I’m certain that I will need that information in the future.

The following is a list of tips that I wanted to share (and save!) and might be useful when debugging and/or writing software on Linux. Almost all tips are for debugging shared libraries however most of them will work for anything else besides shared libraries. There might be similar alternatives for the other OSs, I’m not sure though.

LD_DEBUG

If you write shared libraries or if have built any package from source you might be familiar with LD_LIBRARY_PATH, an environment variable meant to be used for specifying directories where to search libraries first, recommended for development and testing, nothing else. Well there’s another environment variable called LD_DEBUG, really useful for debugging. It basically outputs all dl* function calls. Use LD_DEBUG=help command for help.

nm and objdump

GNU Binutils is fascinating and has several utilities, however most of the time you will use only those two commands. Reading the manual is the best way to understand them. Basically they help you by listing the symbols used and exported in object files. I’ve used this two commands to make sure the final file, after linking, doesn’t reference to any other library I don’t need, and to make sure my shared libraries export the functions that were meant to export.

stop-on-solib-events

One of the hidden gems of gdb. Setting stop-on-solib-events to 1 will allow you to pause the execution of your program when a shared library is loaded. Really useful to know why is my shared library loaded twice? or who is loading what library?. See the other commands to specify files.

ldd and pmap

These are quite similar, both somehow tell you dependencies. The main difference is that ldd shows what libraries are required and pmap shows you process memory mapping, this means memory used and what libraries are actually used for the program.

strace

Traces all calls and signals used by the program. Using -e to define expressions is required unless you want to see lines and lines of calls. It could be useful if you want to profile you program.

valgrind

Required for profiling. In my previous job I used a lot since all applications were running 24×7 and memory was one of the most important things. I usually leave the application running for days using the following arguments: –leak-check=full –leak-resolution=high –show-reachable=yes then I comeback ctrl+c and I see the results.

Something else?

I’m sure I’m missing more commands, some of them language/platform-specific however I’m also sure this list will help me recalling what to check first when debugging shared libraries.

References

Shorten URL: http://bit.ly/i60ZArshorten url

Mono Accessibility 2.1

Candles

Last Tuesday, we presented Mono Accessibility 2.1. We worked really hard on this release. Our main goals were, among other things, to improve our UI Automation Client API implementation, polish the interaction with at-spi2, better Moonlight accessibility and to handle custom and client-side providers. The great work made by all the contributors was the reason this release accomplished those goals.

What happened since last time?

Explaining this release is kind of hard if you are not involved in Mono Accessibility, and even more difficult if you’re not involved in Accessibility at all. However, if you’re familiar with Mono and .NET you are, also, aware of the possibility of developing .NET-based applications that run on both platforms with minor* changes or no changes at all. But, before the implementation of Mono Accessibility, there was something missing: all those applications were not accessible.

This meant two things. First Atk-based Assistive Technologies (ATs) were not able to access Windows Forms nor Silverlight applications. Second .NET-based ATs using UI Automation were not able to run on Mono. Making them useless for people requiring Accessibility to interact with software running Mono on Linux**.

After the implementation of Mono Accessibility, we have:

  • UI Automation API Framework
  • Bridge between UI Automation and ATK

This way ATs using either Accessibility Technology, Atk or UI Automation, will be able to interact with Gtk+, Windows Forms and Silverlight applications, with no changes at all.

This is what happened

In the following video: (if you are using a RSS reader click this link) gcalctool is launched and an application, using UI Automation Client API, interacts with it, clicking buttons “2″, “+”, “3″ and “=”.

Then UIA Explorer, a .NET- based application using UI Automation Client API, also interacts with gcalctool, if you pay attention you will notice that UIA Explorer also lists all other Gtk+ based applications, such as Nautilus and the GNOME Panel.

Finally Mozilla Firefox is executed (both Novell Moonlight with Accessibility Support and Novell Moonlight Accessibility Extensions plugins were installed prior running it) and an Atk-based Accessility Debugger, Accerciser, is launched to interact with the Moonlight application.

The source code used to test GCalctool is the following:

// gmcs -pkg:mono-uia gcalc.cs && mono gcalc.exe

using System;
using System.Linq;
using System.Windows.Automation;

namespace Mono.A11y.Examples {
	public class GCalc {
		public static void Main (string []args)
		{
			AndCondition cond
				= new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
				                                            ControlType.Window),
				                    new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Calculator"));
			var gcalc = AutomationElement.RootElement.FindFirst (TreeScope.Children, cond);
			
			cond = new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
			                                                 ControlType.Button),
			                         new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Add"));
			var addButton = gcalc.FindFirst (TreeScope.Descendants, cond);
			
			cond = new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
			                                                 ControlType.Button),
			                         new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Numeric 2"));
			var Button2 = gcalc.FindFirst (TreeScope.Descendants, cond);
			
			cond = new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
			                                                 ControlType.Button),
			                         new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Numeric 3"));
			var Button3 = gcalc.FindFirst (TreeScope.Descendants, cond);
			
			cond = new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
			                                                 ControlType.Button),
			                         new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Calculate result"));
			var calcButton = gcalc.FindFirst (TreeScope.Descendants, cond);
			
			cond = new AndCondition (new PropertyCondition (AutomationElementIdentifiers.ControlTypeProperty,
			                                                 ControlType.Button),
			                         new PropertyCondition (AutomationElementIdentifiers.NameProperty, "Calculate result"));
			var resultText = gcalc.FindFirst (TreeScope.Descendants, cond);

			// Clicking buttons
			InvokePattern addInvoke = (InvokePattern) addButton.GetCurrentPattern (InvokePattern.Pattern);
			InvokePattern Invoke2 = (InvokePattern) Button2.GetCurrentPattern (InvokePattern.Pattern);
			InvokePattern Invoke3 = (InvokePattern) Button3.GetCurrentPattern (InvokePattern.Pattern);
			InvokePattern calcInvoke = (InvokePattern) calcButton.GetCurrentPattern (InvokePattern.Pattern);
			
			System.Console.WriteLine ("Pressing \"2\"");
			System.Threading.Thread.Sleep (500);
			Invoke2.Invoke ();
			
			System.Console.WriteLine ("Pressing \"+\"");
			System.Threading.Thread.Sleep (500);
			addInvoke.Invoke ();
			
			System.Console.WriteLine ("Pressing \"3\"");
			System.Threading.Thread.Sleep (500);
			Invoke3.Invoke ();
			
			System.Console.WriteLine ("Pressing \"=\"");
			System.Threading.Thread.Sleep (500);
			calcInvoke.Invoke ();
		}
	}
}

Where do I get it?

If you installed Mono Accessibility 2.0 an option to upgrade should be available now, if not Mono Accessibility is available for a variety of Linux distributions, including:

Moonlight applications require the following extra steps:

Have fun and if you find any bug with this release, please file it. If you want to contribute or need specific assistance, please join our mailing list, or drop in #mono-a11y on irc.gimp.org.

* Of course this depends on what APIs you are using. If you want to know how compatible is your application try MoMA.
** Notice however, even though Mono is muti platform and UI Automation is included in both Mono and Silverlight, in order to allow other ATs running on other platforms, different than Linux, you will require to implement an specific bridge to talk to you OS Accessibility Layer.

Shorten URL: http://bit.ly/9AVyB9shorten url

Hackweek V: YaSTroid

Hackweek is an excellent opportunity to try something new. Hackweek V was not the exception. From June 7th to June 11th I joined a fantastic group of hackers to implement YaSTroid, our Android Front-end to WebYaST.

The week was fun. Learning new stuff, in this case Android, always helps me to see things different and somehow makes me appreciate other development platforms. Recalling Java was not that difficult. Honestly I thought Java had something new to offer to all developers, but it seems that Java hasn’t changed dramatically in years.

WebYaST and YaSTroid

WebYaST is an open source project which goal is to provide a web front-end for YaST functionality to enable remote 1:1 management. The interaction is basically like this (see the detailed diagram to get more information):

WebYaST

WebYaST and YaSTroid communicate using the REST API. If you have installed WebYaST you can access the documentation locally using:

http://localhost/restdoc

This website should show you a list of available methods and their arguments, if any, and examples showing you how to use them and the data returned. Pretty straightforward. Is also good idea to read the source code in case the documentation is missing. Everything is written in Ruby, so it should really simple to read.

Getting YaSTroid

Developing YaSTroid requires having Eclipse and Android installed. After that clone the repository. Make sure you are using Android 1.5 when defining your virtual device.

git clone git@gitorious.org:opensuse/yastroid.git

Result

WebYaST + YaSTroid  WebYaST + YaSTroid

Stephen and Scott recorded a video demoing the application using a real device, I recommend watching it full-screen to see all details:

If you can’t see the embedded video follow this link.

Useful links

Shorten URL: http://bit.ly/dv8bSsshorten url

Comparing Ruby and C#: Equality

Beauty

While reading The Ruby Programming Language I wrote a couple of notes about the language comparing it to C#. This is the first post of the series talking about those notes.

C# and Ruby share a similar syntax to compare equality in objects. Both use the operator equals (==) and, at least, one method to compare. Ruby uses equal? and eql?, C# uses Equals. Also, both support overriding the equals (==) operator to provide a different logic in case that’s required. The methods’ name are different but they work pretty much the same.

Understanding the difference between both languages is really simple. If you already know the difference between reference types and values types you are pretty much all set.

Ruby

Method equal?

Method used to test reference equality in two objects. For example:

#!/usr/bin/env ruby

a = 0
b = 0.0
c = b
d = e = 0

# "false" pointer c points to b, and b and a 
# are different types.w
puts "c.equal?(a) #{c.equal?(a)}" 
# "false" b and a are different types
puts "b.equal?(a) #{b.equal?(a)}" 
# "true" Same type, same value. 
puts "d.equal?(e) #{d.equal?(e)}"

Method eql?

Synonym of equal?, not strict type conversion. Notice Hash classes uses this method for creating the hash, so if two values are the same the hash method should return the same value.

#!/usr/bin/env ruby

a = 0
b = 0.0
c = b
d = e = 0

# "false" Pointer c points to b, and b and a are different types
puts "c.eql?(a) #{c.eql?(a)}" 
# "false" Different types
puts "b.eql?(a) #{b.eql?(a)}" 
# "true" Same type, same value. 
puts "d.eql?(e) #{d.eql?(e)}"

Operator equals (==)

By default, in Object class, it’s a synonym of equal?. Tests reference equality.

#!/usr/bin/env ruby

a = 0
b = 0.0
c = b
d = e = 0

# "true" Even when pointer c points to b, and b and a 
# are different types, the value is the same
puts "c == a #{c == a}" 
# "true" Type is casted to allow comparing them
puts "b == a #{b == a}" 
# "true" Same type, same value. 
puts "d == e #{d == e}"

C#

Before explaining the equality options, notice one important difference between Ruby and C#.

First, Ruby is a dynamic typed language. When declaring variables there’s no meaning of variable type, all variables can be used to identify instances of different types depending on the situation. For example, we can define a variable x to act as a string, and then use the same variable x to act as an integer, this doesn’t mean we are converting the string to integer, this means we are using the same pointer (variable x) for two different types, string and integer, pointing to two different addresses in memory. For example:

#!/usr/bin/env ruby

a = "I'm string"
# Output: "a Value: 'I'm string' Class: 'String'"
puts "a Value: '#{a}' Class: '#{a.class}'"

# Output: "a Value: '10.0' Class: 'Float'"
a = 10.0
puts "a Value: '#{a}' Class: '#{a.class}'"

C# is a static typed language, all variables must indicate their type before instantiating an object. For example, when declaring a variable x of type string, you will be able to create an instance of string, only, there’s no way to “reuse” x as an integer in the same scope. Try to compile the following example, it will fail:

public class RubyAndCSharp {
	
	public static void Main (string []args) {
		string x = "I'm string";
		System.Console.WriteLine ("a Value: '{0}' Class: '{1}'", x, x.GetType ());

		x = 10.0; // It will fail here: "error CS0029: Cannot implicitly convert type `double' to `string'"
		System.Console.WriteLine ("a Value: '{0}' Class: '{1}'", x, x.GetType ());
	}
}

Second, memory management. Both languages manage memory automatically: by default all memory is created and released automatically, there is no need to explicitly release or allocate memory, unless the programmer wants to do so. However, in C# there’s a “difference” between types. There are two type categories: Value Type and Reference Type. The difference, related to memory use, is the way they work and the addresses in memory they use. Declaring value types automatically allocates memory, declaring reference types declares a pointer and the memory is allocated when the object pointed by the variable is instantiated. The Value Types are allocated in the stack and the Reference Types are allocated in the heap.

This difference is really important. Comparing two instances of objects with different “category”, one value type and one reference type, does not work, it just fails. Is like comparing an apple to an orange. Is comparing a value stored in the stack to a value stored in the heap. We can’t compare them without writing any extra code.

And this extra code means using the base class object as the pointer for different types, because both types, value type and reference type, are subclasses of object, in one way or another. Let’s try to compile the following example:

public class RubyAndCSharp {
	
	public static void Main (string []args) {
		object x = "I'm string";
		// Output: "a Value: 'I'm string' Class: 'System.String'"
		System.Console.WriteLine ("a Value: '{0}' Class: '{1}'", x, x.GetType ());

		x = 10.0;
		// Output: "a Value: '10' Class: 'System.Double'"
		System.Console.WriteLine ("a Value: '{0}' Class: '{1}'", x, x.GetType ());
	}
}

After this short (or long?) explanation we are ready to see talk about the methods.

Method Object.Equals()

Is used to test reference equality in reference types and bitwise equality in value types. For example:

public class RubyAndCSharp {

	class MyClass {
		public string Name { get; set; }
		public override string ToString () { return Name; }
	}
	
	public static void Main (string []args) {
		// object.Equals in Reference Types uses address memory
		MyClass myClass0 = new MyClass () { Name = "test" };
		MyClass myClass1 = myClass0;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, object.Equals (myClass0, myClass1));
		
		// Let's try again. This will return false. myClass1 and myClass2 are different instances
		myClass1 = new MyClass () { Name = "test" };

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, object.Equals (myClass0, myClass1));
		
		// It doesn't matter myInt0 and myInt1 are different variables, equality will be true.
		int myInt0 = 1; 
		int myInt1 = 1;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myInt0, myInt1, object.Equals (myInt0, myInt1));
	}
}

Operator equals (==)

Is, basically, a synonym of object.Equals, same rules apply.

public class RubyAndCSharp {

	class MyClass {
		public string Name { get; set; }
		public override string ToString () { return Name; }
	}
	
	public static void Main (string []args) {
		// == in Reference Types uses address memory
		MyClass myClass0 = new MyClass () { Name = "test" };
		MyClass myClass1 = myClass0;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, myClass0 == myClass1);
		
		// Let's try again. This will return false. myClass1 and myClass2 are different instances
		myClass1 = new MyClass () { Name = "test" };

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, myClass0 == myClass1);
		
		// It doesn't matter myInt0 and myInt1 are different variables
		int myInt0 = 1; 
		int myInt1 = 1;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myInt0, myInt1, myInt0 == myInt1);
	}
}

Operator Object.ReferenceEquals()

Pretty straightforward, tests reference:

public class RubyAndCSharp {

	class MyClass {
		public string Name { get; set; }
		public override string ToString () { return Name; }
	}
	
	public static void Main (string []args) {
		// Object.ReferenceEquals in Reference Types uses address memory
		MyClass myClass0 = new MyClass () { Name = "test" };
		MyClass myClass1 = myClass0;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, System.Object.ReferenceEquals (myClass0, myClass1));
		
		// Let's try again. This will return false. myClass1 and myClass2 are different instances
		myClass1 = new MyClass () { Name = "test" };

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myClass0, myClass1, System.Object.ReferenceEquals (myClass0, myClass1));
		
		// This will also return false.
		int myInt0 = 1; 
		int myInt1 = 1;

		System.Console.WriteLine ("object.Equals('{0}','{1}') = {2}", myInt0, myInt1, System.Object.ReferenceEquals (myInt0, myInt1));
	}
}

Colophon

Sometimes you will have to use an object reference to refer to both types, value and reference, if you are planning to compare their value you have to use the static method object.Equals(a,b). Using the operator equals (==) will always return false, because of the boxing/unboxing:

public class RubyAndCSharp {
	
	public static void Main (string []args) {
		string str0 = "hola";
		string str1 = "hola";
		
		object obj0 = str0;
		object obj1 = str1;

		System.Console.WriteLine ("Equals: {0}, Using ==: {1}, object.Equals {2}", 
		                          obj0.Equals (obj1), // True
		                          obj0 == obj1, // True
		                          object.Equals (obj0, obj1)); // True
		                          
		bool bool0 = true;
		bool bool1 = true;
		
		obj0 = bool0;
		obj1 = bool1;

		System.Console.WriteLine ("Equals: {0}, ==: {1}, object.Equals {2}", 
		                          obj0.Equals (obj1), // True
		                          obj0 == obj1, // False
		                          object.Equals (obj0, obj1)); // True
		                          
	}
}

Updated 2010-03-17: Thanks to sukru for noticing the error in the examples.

Updated 2010-03-18: Fixed typos, thanks to yoeri and doza noticing them.

Shorten URL: http://bit.ly/9Mvvgzshorten url

Accessibility in Moonlight

An important milestone happened on Friday, February 26: Mono Accessibility 2.0 was released. It’s important because all applications running on Moonlight 2.0, or greater, will be accessible from now on.

Accessibility?

If you are not familiar with this word, Accessibility, it might mean nothing to you and, probably, you will need a more formal definition:

Accessibility is a general term used to describe the degree to which a product, device, service, or environment is accessible by as many people as possible. Accessibility can be viewed as the ability to access and possible benefit of some system or entity. Accessibility is often used to focus on people with disabilities and their right of access to entities, often through use of assistive technology.” Wikipedia

You have interacted with Accessibility in real life, even if this is your first time reading this word. Have you seen those tiny bumps on the floor when taking the subway? Wheelchairs ramps or the dots on elevator buttons? Have you heard that noise, like beeping, when crossing the street? Have you noticed the audio jack in some ATMs?

These are real life examples of Accessibility. Accessibility in software is similar, it’s basically the degree of interaction between your software and people with temporal or permanent disabilities. People who can only use the keyboard or the mouse, people with low vision, blind people or people with hearing disabilities. All of them will be able to interact and use your application only if it’s accessible. That’s why Accessibility is important.

Accessibility and Moonlight

Microsoft Silverlight is web application framework for building media experiences and rich interactive applications for the Web. Moonlight is an open source implementation of Silverlight. Besides providing a rich experience for the web, applications running on Moonlight are now available for people with disabilities, allowing them to interact and use these applications. The interaction between these new applications and existent Accessibility Technologies (ATs), such as screen readers, is the same. All existent ATs are reused, it’s like interacting with any other desktop application. ATs in GNOME should work right now without any change and, if any change is required, it will help to provide a better integration with this framework.

Implementation

Moonlight Atk Bridge

Refer to Accessibility Architecture for a detailed explanation of the complete architecture.

In both Accessibility implementations, Silverlight and Moonlight, Microsoft UI Automation is used for interacting and exposing data of UI elements of the application. These data are used by ATs to access and manipulate those UI elements. Properties such as visibility, sensitivity or interaction, are exposed by Automation Peers (also known as Automation Providers), along with Automation Patterns to indicate the type of interaction in the control, for example: accepting selection or allowing clicking. There’s always a relation one to one, one Automation Peer and one Control. The properties are available to ATs through the information exposed by the UIA/Atk Bridge module. This module is loaded by the Moonlight application to interact with ATs. It keeps a tree of Atk objects to represent every UI Automation element in the Moonlight application.

The interaction between ATs and Moonlight applications is like this:

  1. An AT requests information about the Moonlight control in Firefox.
  2. Firefox asks Moonlight this information.
  3. Moonlight uses the A11yHelper to load the UIA/Atk bridge module and returns the root accessible, it represents the control’s Automation Peer: WindowAutomationPeer.
  4. From now on, new AutomationPeers will be mapped, one-to-one, to an Atk.Object. All data requested by an AT will be accessed through the associated Atk.Object, and this one will return information contained in the AutomationPeer.

If you are curious you can checkout the sources to see the final implementation:

  • Moonlight: important bits located in class/System.Windows/System.Windows.Automation.Peers/ and class/System.Windows/Mono/A11yHelper.cs.
  • Moonlight UIA/Atk Bridge: implementation located in MoonAtkBridge/.

How do I install it?

Before installing, make sure Assistive Technologies is enabled, then add the Mono UIA repository (see Downloading) and follow the instructions (taken from Installing):

  1. Install the updated xulrunner package from the above repositories. (This is required until Firefox 3.7 because of bug #480317)
  2. Install Novell Moonlight with Accessibility Support for 32 bit or 64 bit.
  3. Install Novell Moonlight Accessibility Extensions
  4. Restart Firefox
  5. Enjoy!

Useful links

Shorten URL: http://bit.ly/9vR5QPshorten url

Tasque 0.1.9!

Yes! Your favorite task management application is back. Tasque v0.1.9 was released today!. New features include:

  • Support for Mono >= 2.6
  • Customizable color highlighting in tasks.
  • Hiveminder improvements
  • New translations
  • And more!

See the announce email to get more information.

Get it while it’s hot!

Screenshots?

Tasque 0.1.9   Tasque Preferences

More here!

Where to get?

More information?

Shorten URL: http://bit.ly/ahqNtdshorten url

Parallel Development Environments? Pulque!

¡Quiero pulque!

By Claire L. Evans / CC BY-ND 2.0

This is an updated version of Multiple Parallel Mono Environments.

What is Pulque?

Pulque is a collection of applications written in Ruby and Bash scripting to maintain parallel development environments.

Why does Pulque exist?

Three reasons:

  1. I need to keep multiple versions installed of the same software,
  2. I need to know what Version Control System is used by the software, and the most important
  3. I want to keep myself sane.

At work, I have to interact with different open source projects, most of them use Subversion and Git, but some others use Bazaar and Mercurial. Keeping track of the current parallel development environment and the VCS used by the software is exhausting.

You spend time focusing on something that shouldn’t be that important:

  • Managing your parallel environments and,
  • Keeping track of the VCS used by the software

Is easy to get confused when interacting with the repository, for example, executing svn update when the software is stored in a git repository. Is silly, but it happens. Unless you are using an IDE that support Multiple Parallel Development Environments you will need the terminal to configure and build your projects.

Pulque helps you maintaining parallel development environments by:

  • Printing in the bash prompt the name of the parallel development environment and the type of the VCS, this information is updated depending on the working directory,
  • Defining aliases to the default commands used to configure and build the software project, to always prefix your projects using your parallel environment, and
  • Showing a failure or success alert when the command finishes.

Installing and using Pulque

Follow the instructions in INSTALL, or if you are using openSUSE 11.2:

OneClick Install
Click here to drink Pulque!

Don’t forget to add the function pswitch to your .bashrc. Bash will autocomplete your environment name when using TAB TAB.

function pswitch {
  source /usr/bin/__pswitch $1
}

Read the USING file to understand how to use Pulque in the daily basis. If you find something weird or interesting please create an issue to fix it.

Colophon

According to Wikipedia: “Pulque, or octli, is a milk-colored, somewhat viscous alcoholic beverage made from the fermented sap of the maguey plant, and is a traditional native beverage of Mexico.

Shorten URL: http://bit.ly/ay65poshorten url

The Ruby Programming Language

english — Tags: , , , , , , , , — @ 23:50

Ruby

A couple of days ago I finished reading: The Ruby Programming Language, book written by David Flanagan and Yukihiro Matsumoto. If I have to say anything about the book and, the language, of course, is: I am impressed. The syntax is pretty for writing and simple for reading. Its simplicity makes you understand the code, is like visualizing the goal of the program in your mind by reading it, not running it. It is like reading a well written letter. You just understand.

I must say, when I was reading the book, at the beginning. I did not feel comfortable with the weird, at that time, syntax. Method decorations such as “!” and “?”, and the support for methods aliases made no sense. Actually I thought I was wasting my time by trying to learn the language. I was wrong.

When I learned C++ several years ago, I did not have reference to object orientation or any object-oriented programming language. Learning it was difficult, but, at the same time, easy. Difficult because I did not know the paradigm, easy because it was my first time learning that kind of syntax. After learning C++ I decided to learn Java and after that, I decided to learn C#.

And I learned them all the same way. I “translated” the syntax. Translated it from the “new language” to the “old language”. I did learn them all. And I thought, for long time, that the rule was: “Learn all the languages the same way: by translation”. I was wrong. Again.

Learning a new programming language, in my opinion, is better when you do not translate the new language. Similar to learn to speak a new language. In both cases, you have to think in the language. I decided to think in the new language. To do it that way. The Ruby way. The results were amazing. Were so amazing that inspired me to write a project in Ruby. I wanted to try out the syntax, the platform and the community. To see if the language was that good as I thought.

After trying it out. No disappointments at all. Actually is interesting that C# and Ruby share a lot of things, syntactically speaking. Both of them are pretty languages. Probably they do not share goals. However, I’m sure they share one goal: to make the life of the software developer easier. And, to a software developer, a programming language, and everything around it, that makes your life easier is what matters the most.

Shorten URL: http://bit.ly/5drYK7shorten url

Hackweek IV: Gwibber + Sharing

english — Tags: , , — @ 13:51

I decided to try something different this Hackweek to learn a programming language and get involved into another exciting software libre project. There were too many options, too many good projects to work on. I selected gwibber because of three reasons:

  1. gwibber supports several microblogging services, including my favorites: Twitter and Facebook.
  2. gwibber is written in Python.
  3. gwibber doesn’t integrate with other gnome applications, for example Cheese or Nautilus.

So… what’s the new cool feature?

Something I like to call “Sharing Services”. What’s a sharing service? A sharing service is a service using an online provider to share data, easier impossible. For example: Images would be shared using Twitpic, Videos would use yfrog, Files would use Drop.io and Plaint Text files would use Pastebin (this is configurable, in case you were wondering) I’m sure you got the idea.

Data Sharing on Gwibber Data Sharing on Gwibber

Technical approach

The implementation is based on the following UML class diagram:

Data Sharing on Gwibber

The idea is simple, subclass Provider and override share method and you are pretty much all set. I already implemented 3 services: twitpic to share images, yfrog to share images and video, and pastebin.ca to share plain text files. My plans include to implement the following providers:

Plain text

Video

Files

To allow communication between gnome/gtk/dbus-based applications I added a new dbus method: share(filename,message), that way you can “share” your file using a message, you don’t need to explicitly tell the provider+service to use, gwibber will use the filename’s mime-type to get the valid provider and the configured service, convenient isn’t it?

Data Sharing on Gwibber

Where to get it?

I branched trunk to implement this feature, you can read launchpad to get more information, basically you need to:

bzr branch lp:~mario-carrion/gwibber/gwibber-services

and execute:

./bin/gwibber

I also included a patch for cheese, I’m using gnome-2-26 branch, in case you want to share your videos and images on gwibber using cheese.

Cool video

Known bugs and issues

I’m aware of several bugs, for example: web timeouts, invalid responses and random deadlocks, so take it easy, remember: this is a preview, be happy. Also I need to think about multiple instances and implementing a real HTTP handler instead of using the MultiPartForm class, will decide it later.

OpenSUSE 11.1 Users: you may need to install python-related dependencies. OpenSUSE 11.1-64, if you want to use the nautilus extension, you will need create a symbolic link in /usr/lib/ for libpython2.6.so. I’m going to report the packing bug as soon as possible.

BTW, you can always follow me on twitter: @mariocarrion in case you want to recommend me a new provider.

Shorten URL: http://bit.ly/c0Rcxbshorten url
Next Page »
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2004-2014 Mario Carrion | powered by WordPress with Barecity