20100320

I hate flash, but I need flash

Since past week, I switched to my desktop computer. Is a 64 bit AMD quadcore, with 4 GB ram, an NVidia 9500 GT card and 2 SATA-II disks (500 GB each).

What problem could I have with this powerful computer, simple, flash (and some movies problems, but the codecs are not supported to 64 bits yet).

So I decided to make this simple, I first made a script called kill_flash:


#!/bin/bash

PID=`ps -ef|grep -i chrome|grep -i adobe|perl -lane 'print $F[1];'`
echo "pid: $PID"
kill -9 $PID
echo "RC: $?"


That was quite useful, but as when I see flash things, I'm using mostly just a browser, and was quite annoying to go to the console and type kill_flash. So I made my first ruby + gtk2 app (is short, but useful to me):


#!/usr/bin/env ruby

require 'rubygems'
require 'sys/proctable'
include Sys
require 'gtk2'

$ToKill = Array.new()

def do_kill_flash
$ToKill.each{|mpid|
Process.kill("KILL",mpid)
}
end

window = Gtk::Window.new
window.signal_connect("delete_event") {
puts "delete event occurred"
#true
false
}

window.signal_connect("destroy") {
puts "destroy event occurred"
Gtk.main_quit
}

buttonKillFlash = Gtk::Button.new("Kill Flash")
buttonKillFlash.signal_connect("clicked") {
msg = "Kill the following: \n"
ProcTable.ps{|ps|
if ps.cmdline =~ /flashplugin-nonfree\/libflashplayer/
msg = msg.to_s + ps.cmdline
$ToKill.push(ps.pid.to_i)
end
}
msg = msg.to_s + "?"
unless $ToKill.empty?
dialog = Gtk::MessageDialog.new(window,
Gtk::Dialog::DESTROY_WITH_PARENT,
Gtk::MessageDialog::QUESTION,
Gtk::MessageDialog::BUTTONS_OK_CANCEL,
msg)
dialog.run do |response|
case response
when Gtk::Dialog::RESPONSE_OK
do_kill_flash
end
end
else
dialog = Gtk::MessageDialog.new(window,
Gtk::Dialog::DESTROY_WITH_PARENT,
Gtk::MessageDialog::QUESTION,
Gtk::MessageDialog::BUTTONS_OK,
"Nothing to kill")
dialog.run
end
dialog.destroy

}

button_exit = Gtk::Button.new("close")
button_exit.signal_connect("clicked"){
Gtk.main_quit
}

box = Gtk::VBox.new(false,0)
box.pack_start(buttonKillFlash,true,false,2)
box.pack_start(button_exit,true,false,2)
window.border_width = 10
window.add(box)
window.show_all

Gtk.main


As you could see, this code is dirty and quick. In the future, I'll put some other buttons to make other things (like make a class to the do_kill_flash), but for now, is useful to me.

Making a gnome applet was quite difficult, and I should write more code, just to make the kill, but when I read more on that, I'll put the code here.

20100315

the education problem in Argentina (a federal problem)

For a long time in Argentina I heard that the country must be more federal, and not so concentrated around the capital city.

This is a long term problem, mostly because the main port is still in Buenos Aires, so everything is passing through this city (there is another ports inside the country, but mostly everything is still in Buenos Aires).

But in these days, the problem relays in other parts, more than just the economical importance of Buenos Aires. And that is that, if a family wants to move from one city to another, the education of the children is a problem.

In EEUU and another countries, the education program is shared among the whole country, but in Argentina, every city could manage some themes that they want to teach, relegating others. And even the when they want to teach that themes. That causes that, if somebody wants to move with his/her family, the child/ren of the family could lost the year, or must prepare some themes to give the equivalences to let this child take normal classes in the new school.

This is a mayor problem, to let the country become federal. And the most important part, is that the capital city couldn't get more people. This is an old city, that contains a lot of problems (structural problems, like the public services). And, as you could see in another cities, that there is a limit from city to city (some space without houses or buildings). Around the city you have more than 4 times of the surface of the city with the part called "Conhurbano", that is a continuous urban part from the center of Buenos Aires, to a long distance.


Ver mapa más grande

The problem of the education, increments the problems of the city, that is not prepared to host so many people (and in workdays the city increments the number because in the surrounds host a lot of workers that their jobs are in the capital city).

And as the people is not moving from (usually is moving to) the capital to the other cities or provinces, the cost in doing that is quite high.

A solution to this problem is quite simple, make a "curricula" for the whole country, that is the same in every city around the country, and respected by all the teachers (specially the time when they teach every theme).

20100304

syslog mortis, komputisto esprimado


estela@neko_vet$ /etc/init.d/syslog restart
syslog: not enough space
estela@neko_vet$ > /var/run/lung
Message from syslog: kernel panick
estela@neko_vet$ /etc/init.d/syslog restart
syslog: process died unexpectedly
estela@neko_vet$ write matias@matias_home "process syslog died unexpectedly"
matias@matias_home# tar -jcvf /dev/good_memories /home/syslog
matias@matias_home# rm -fr /home/syslog

20100302

ruby on rails and reorder the columns order in the view

This year was quite difficult to me, as I don't have a job since the 4th of January until now (2nd of March). And I think that is going to be like that for a some more time (as the interesting projects that I was offered to work in, the money is not enough, but that projects are really cool).

Well, this weekend I tried to keep going into my cook book, now in ruby, as the previous version in Perl was quite nice, but nobody would take that serious, as I did everything by myself and with my own XML definitions. The model that now I'm working is quite easy, a simple database:



ActiveRecord::Schema.define(:version => 20100302024114) do

create_table "categories", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "ingredients", :force => true do |t|
t.string "name"
t.integer "recipe_id"
t.integer "quantity"
t.string "measure"
t.string "part"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "notes", :force => true do |t|
t.integer "recipe_id"
t.string "keyword"
t.text "text"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "recipes", :force => true do |t|
t.string "name"
t.integer "yield"
t.integer "category_id"
t.text "preparation"
t.datetime "created_at"
t.datetime "updated_at"
end

end



This is quite simple, but yet powerful enough to what I need. For example, if i ever need something like the origin of the recipe, I just could add a note titled "origin" and the region in the text field. The only problem and that I should reconsider in some time, is that some preparations have parts, for example the base, the filling and the cover (for example a lemon pie). I manage to put that in the ingredients, as some parts uses the same ingredients, but in different measures, and perhaps somebody just want to make only the filling or the cover, but not the whole meal. But having another table for the preparation, just I don't like for now (as the preparations could vary from 1 to 5 or more, that should be in a separated table).

The main problem that I had was that the documentation was quite nasty about the reorder of the columns. Every web that I found was telling how to reorder the rows (the information in the columns) by an specified column. But I want to reorder the column, and the formal documentation just don't say anything useful to me.

So, after digging a lot of time in Google, I found http://api.rubyonrails.org/ and inside that http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002294 That was the beginning of the solution.

I printed that method, the code was:

class RecipesController < ApplicationController

active_scaffold :recipe do |config|
p config.columns()
end

end


That was quite useful, the very first line of the output was:


Completed in 301ms (View: 26, DB: 0) | 200 OK [http://10.0.0.52/recipes/new?_method=get&adapter=_list_inline_adapter]
#<ActiveScaffold::DataStructures::Columns:0x7fa930f14100 @_inheritable=[:name, :yield, :category, :ingredients, :preparation, :notes],
[...]


For the first time I had the proper names to call the others tables and my recipe table without the default order.


config.columns = [:name, :yield, :category, :ingredients, :preparation, :notes]


I know that this post was quite long and in this nasty language, but most of the people (well, programmers) just search the things in English.