Archive for category Software and Development

Ruby

Yesterday, a friend of mine asked me if I’d recommend Ruby programming language. I’ve said that, even if I had never tried it, it is said to be very reliable. Nevertheless, I’ve decided to try it, just by curiosity. So I’ve gone to the Ruby language website, and there, I’ve found some code, a hello word example:

# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end
 
  def salute
    puts "Hello #{@name}!"
  end
end
 
# Create a new object
g = Greeter.new("world")
 
# Output "Hello World!"
g.salute

I tried it, and until today, forgotten it. But, today, I wanted to do a script to generate all IP addresses in an IP block. I first thought to do it in python, a language I’m more familiar with, but, still driven by curiosity, I’ve wondered if I could do it in Ruby. And that’s what it gave:

#!/usr/bin/env ruby
# The NetMask class
class NetMask
	@mask
	@baseIP
	def initialize()
		@mask = 0
		@baseIP = 0
	end
	def parseFromString(str)
		array = str.split(".")
		if array.length != 4
			array = str.split("-")
		end
		if array.length == 4
			@mask = array[0].to_i + array[1].to_i * 256 + array[2].to_i * 65536 + array[3].to_i * 16777216
		end
	end
	def setFromInt(value)
		@mask = ('1' * value + '0' * (32 - value)).to_i(2)
	end
	def parseBaseIPFromString(str)
		array = str.split(".")
		if array.length != 4
			array = str.split("-")
		end
		if array.length == 4
			@baseIP = array[0].to_i * 16777216 + array[1].to_i * 65536 + array[2].to_i * 256 + array[3].to_i
		end
	end
	def formatIntToIP(int)
		return (int/16777216).to_s+ "." + ((int/65536)%256).to_s + "." + ((int/256)%256).to_s + "." + (int%256).to_s
	end
	def getMask()
		return formatIntToIP(@mask)
	end
	def getBaseIP()
		return formatIntToIP(@baseIP)
	end
	def generateIPList()
		array = []
		for i in (@baseIP & @mask) .. ((@baseIP & @mask) | ((2**32)-1)-@mask) do
			array.push(formatIntToIP(i))
		end
		return array
	end
end
 
mask = NetMask.new()
args = ARGV[0].split("/")
if args.length == 2
	mask.parseBaseIPFromString(args[0])
	mask.setFromInt(args[1].to_i)
else
	mask.parseBaseIPFromString(ARGV[0])
	mask.setFromInt(ARGV[1].to_i)
end
puts mask.generateIPList()

Just for information, the help is here.

No Comments

BattleFlash v2 @Annecy

These last two days, I’ve participated to a small Adobe Flash contest in Annecy, named the Battle Flash (Frenchies have recurrent a tendency to reverse orders of words :P ). The concept is pretty simple: In a first phase, as a team composed from one to six students, you have to realise five different flash animations, each having its subject, one imposed artwork, one imposed sound or music and one imposed text. These imposed media had to be respectively used in each of ‘em, but we were allowed to modify them, providing that we kept their artistical meaning. Secondly, each team is opposed to another, like in a single-elimination tournament. Our team hadn’t done the last subject, so we couldn’t win. But, unfortunately, the first round was on the only one subject we didn’t treat, and so, we were eliminated from the beginning of this tournament, that’s sad…
Nevertheless, I was the only one coder in the team, and as such, I’ve chose what method and software we had to use to produce .swf files. I use a Linux distribution, so I couldn’t choose Flash as coding platform. I like free (and also open-source) software, and that’s why I naturally came to Adobe’s Open-Source Flex SDK. But I have been annoyed by the impossibility to debug my animations correctly. Actually, I didn’t know of the “Linux debugger and standalone players” existence… I will publish my work soon, at least for the subject I have to continue. :)

No Comments

HADOPI doesn’t works… As expected??

Is in the same vein as that previous post, it seems that the three-strike-law (I appointed HADOPI™), this article (in french) says that piracy has increased by three percent in France, since the adoption of the law… How pathetic they still believe in this kind of method…

No Comments

Ubuntu Party 2009 @Cité des Sciences de Paris la Villette

Last year (2009) I went to the Ubuntu Party 2009 in the Cité des Sciences de Paris la Villette. It was nice, and I had a great dinner with most of the staff. I didn’t expect much from this event, I have just been there by curiosity; because I didn’t like Ubuntu a lot. And yet, I was impressed by Mark Shuttleworth’s conference¹, which changed my mind and my considerations on it. I thought and I still think it is a crappy Operating system which is also simple to deploy and to use. What has changed is that now, I know that this “imperfect” software is based on very good ideas, and that the Ubuntu team seems to be very dynamic (which means that the correction of any bug or defective design is just a matter of time).

First, Mark told us about cadence (or to plan releases on milestones rather than functionalities). He said that it:

  • Energizes a project
  • Regularises project releases (on a 3/6/12 months basis; adapt the time cycle to the project)
  • Force developers to release their work to the project
  • Gives a rapid feedback from users
  • Makes collaboration between projects easier
  • Allows users to help each other (since they have similar versions of software)

I think this might be a good practice for middle-sized and big projects; while I would prefer “when it’s done” releases for little projects, since it allows more flexibility and give me much more free time when I work alone on a project.

Then, he spoke of the quality of a project, and said that:

  • Projects witch have tests are more open to contributions
  • Automated package creation from stable software branches increases the number of people who really use an up to date version of the software and allows a great feedback on latest versions.
  • It’s important to be aware of the difference between a new software development and the maintenance of the current version of an existing one.
  • There is less pressure to back-port new features (rather than to maintain stable branch) when people know when the next version will be out (see cadence).
  • More aggressive changes can be done since more accurate feedback is available from more users.
  • Automated crash reporting gathers all crash information (mainly from log-files) and spot all problems as they happen.

And finally he got into design, or the way you approach a problem.

  • Best open source software are made by people who instinctively understand (grok) good software design.
  • Design as skill is a profession.
  • Creating both a design and engineering space on a projects make the project healthy.
  • Ask tests from unexpected (aka. random; as instance, people picked from street or at a shop, friends of friends, etc.) people gives a more complete feedback
  • Design is also about functionalities integration into the window manager and all its parts.

In the end, I liked to be there, I learned a lot of things, and now, I still use Ubuntu, but I don’t grumble as often as before about it. ;)

So, see you at the next Ubuntu Party² :)


¹ A post on Mark’s blog about time based release and cycles in free software.
² Due to some slight inconveniences with part of the UP staff, I’ve not been there.

No Comments

Nautilus SVN plugin

Today, I had to checkout some SVN repository, and so, I downloaded subversion. But I reminded that when I used windows, a while ago, a sort of GUI plugin was available for explorer. So, I started to seek for the same thing for Nautilus. And I found out this.

P.S.: I also sorted out this, for those who don’t want to use rabbitvcs. But I haven’t tested it yet.

No Comments

D-ie6, die!

From a nice web-log on which 404 errors are awesome :)

die6

No Comments

Customers, their ambitions vs. their needs.

Few days ago, one of my friends told me a short story which happened to him a very short while before:

My friend is a web developer, and so, his customers usually want him to code online software. One of his customers, though, wanted an e-commerce website «Like another one». So, my friend immediately thought at a huge web application which was dedicated, would have scaling abilities, advanced features, etc.  The customer then told him that he only had slightly more 700 bucks to start the project. My friend, conscious of the fact that the price of something like that application would cost at least ten times more, told his client that he could do something «light» to start, on what the client agreed. So, he started to work, hard, and got something working, then he put the stuff online. All has been okay for some weeks, ’til the customer wanted to do some slight modifications on his website… These slight changes would have been so if my friend would have done a complete and finished product, what he obviously hadn’t done for this little amount of money. So, despite the fact that his work has been thought to be evolutive, he had to recode most of the website in order to make the site suitable for these slight modifications. So he told that to the customer, who didn’t accept the quote. After arguing a short while, they both agreed that a simple e-commerce website would be sufficient.

So, my friend migrated his customer on an e-commerce website solution, and him and his client are both satisfied with that. The moral of this story is to NEVER trust a customer on his needs: they always are either distorted by the customer’s ambition, or, rarely, willingly lowered, in order to pay less (and, unfortunately, have less) than really needed. The role of a developper is also to understand his customer’s needs, and to explain them why and what they really need.

No Comments

XBox gamepad driver for Linux

Tonight I plugged my Xbox controller to my freshly installed Ubuntu setup. I have been using Windows Xp for at least three years, and I didn’t know it should work natively; so I started to look at existing drivers. I founded out that a project exists, but source code was two years old. I contributed to it and it seemed to work.

After encounting some problems I have to debug this driver. I’ll post any further information here.

2 Comments

Windows Clipboard viewer…

Today I found a nice software into windows, which is very useful and handy: the Clipboard viewer. It’s located in %SystemRoot%\System32\clipbrd.exe. This great software doesn’t only allow to view, but also to erase, save and load clipboard content.

No Comments

Regedit trick to getting rid of “Use the Web service to find the appropriate program”

In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, create a new DWORD value named NoInternetOpenWith and set it to 1. Done. And, yes, it’s mostly a note for myself.

No Comments