nunojob:~ dscape/08$ echo The Black Sheep

Posts tagged ‘icons’

famfamfam flag iconset yaml representation on ruby

First download the flags from famfamfam into a folder called flags (pngs only,
no subfolders!).

Now in the bash:

cd flags
ls > file.txt

Now your on the interactive ruby shell (irb).

# If you want to use this as a script just copy
# the bash lines and put them as
# system ‘cd flags’
# system ‘wget …’ and so on

# We start treating the output from the ls
# open the ls output
f = ‘file.txt’
# place the file in lines
lines = f.readlines
# map those who have 2 digits codes
lines = { |line| line.size == 7 }
# get the 2 digits
lines = { |line| line[0..1] }

# Then the iso file
# open the iso file
f = ‘iso3166_en_code_lists.txt’
# get rid of the notes
# place the file in iso
iso = f.readlines
# create a new hash
hashed_iso = {}
# select non empty lines { |a| !a.rstrip.empty? }.map do |b|
# remove the whitespaces and split in ‘;’
aux = b.rstrip.split ‘;’
# place info in the hash
hashed_iso[aux[1].downcase] = aux[0].capitalize

# Now we cross information giving more
# importance to what’s in the iso.
iso_famfamfam = {
# select those who have flags in famfamfam
|k,v| lines.member? k
}.sort_by {
# sort them by the name the user will see
|pair| pair[1]

# Now we create the contents to store in the yaml file
# create the yaml first line
yaml_lines = “hash: \n”
iso_famfamfam.each do |pair|
# for each pair, create the yaml
# representation and put in yaml_lines
yaml_lines < < ' ' + pair[0] + ': ' + pair[1] + "\n" end yaml_lines << "array: ---\n" iso_famfamfam.each do |pair| yaml_lines << '- - ' + pair[0] + "\n - " + pair[1] + "\n" end # put it in a file f = 'flags.yml', 'w' f.write yaml_lines f.close #sample for loading the yaml into ruby f = 'flags.yml' fy = YAML.load f [/sourcecode] Now you have your yaml representation of the flags. Do what you please. Personally I'm going to use the file to load it to Ruby when my Ruby on Rails app starts and use it as part of the registration system in the

Howto: Change folder icon in Leopard

Copy the icon you want to use (PNG), browse to the folder you want to change the icon.

Now select it and press command + I. Now select the folder and press command + V to paste the icon.