Archive for the ‘English’ Category

uptimed and uprecords

четвъртък, септември 15th, 2011

Nice! As I am maniac of  uptime here is nice utility found at http://www.linuxjournal.com/content/tracking-server-uptimes

uptimed. It is similar to the utility that most of us have heard of, uptime, except that it runs as a daemon and logs the system’s uptime instead of just reading info that is lost on a reboot. Uptimed provides a secondary command called uprecords

вторник, август 23rd, 2011

If you have a lot of readings then Struct is the winner.

If you have equal read/write then Hash

And forget for OpenStruct

Here is why and how I benchmark all those methods



guda: ~/vanilla_ui/vanilla_properties  (v2 *$ u=) ∴ irb
ruby-1.8.7-p330 :001 > require ‘benchmark’
=> true
ruby-1.8.7-p330 :002 > require ‘ostruct’
=> false
ruby-1.8.7-p330 :003 > n = 5000000
=> 5000000
ruby-1.8.7-p330 :004 >
ruby-1.8.7-p330 :005 >   puts “convertions”
convertions
=> nil
ruby-1.8.7-p330 :006 >
ruby-1.8.7-p330 :007 >   Benchmark.bm do |x|
ruby-1.8.7-p330 :008 >      x.report(“Struct init at start”) { CustomerOne = Struct.new(:name, :age);  s = CustomerOne.new(‘a’);   n.times do s.name; end }
ruby-1.8.7-p330 :009?>    x.report(“Struct with write op”) { CustomerTwo = Struct.new(:name, :age);  s = CustomerTwo.new;  s.name = ‘a’; n.times do s.name; end }
ruby-1.8.7-p330 :010?>    x.report(“Hash”) {  s = Hash.new;  s[:name] = ‘a’; n.times do   ; s[:name]; end }
ruby-1.8.7-p330 :011?>    x.report(“OpenStruct”) { s = OpenStruct.new;  s.name = ‘a’; n.times do   ;  s.name; end }
ruby-1.8.7-p330 :012?>   end
user     system      total        real
Struct init at start
1.160000   0.000000   1.160000 (  1.155457)
Struct with write op  1.200000   0.000000   1.200000 (  1.208754)
Hash  1.510000   0.000000   1.510000 (  1.507588)
OpenStruct  5.990000   0.000000   5.990000 (  5.999714)
=> true
Lets do some = operations
ruby-1.8.7-p330 :015 >   Benchmark.bm do |x|
ruby-1.8.7-p330 :016 >      x.report(“Struct init at start”) { CustomerMale = Struct.new(:name, :age);  n.times do s = CustomerMale.new(‘a’);  s.name; end }
ruby-1.8.7-p330 :017?>    x.report(“Hash”) { n.times do   ; s = Hash.new;  s[:name] = ‘a’; s[:name]; end }
ruby-1.8.7-p330 :018?>    x.report(“Struct with write op”) { CustomerFemale = Struct.new(:name, :age);  n.times do s = CustomerFemale.new;  s.name = ‘a’; s.name; end }
ruby-1.8.7-p330 :019?>    x.report(“OpenStruct”) { n.times do   ; s = OpenStruct.new;  s.name = ‘a’; s.name; end }
ruby-1.8.7-p330 :020?>   end
user     system      total        real
Struct init at start  9.930000   0.000000   9.930000 (  9.943670)
Hash 11.090000   0.000000  11.090000 ( 11.127766)
Struct with write op 12.230000   0.000000  12.230000 ( 12.243452)
OpenStruct still working ….

to_i or to_s is faster?

четвъртък, август 4th, 2011
require 'benchmark'
n = 500000

puts "convertions"
Benchmark.bm do |x|
 x.report("to_i") { n.times do   ; "123456789".to_i; end }
 x.report("to_s") { n.times do   ; 1234567890.to_s; end }
 x.report("to_sym") { n.times do   ; 1234567890.to_sym; end }
end

user     system      total        real
to_i  0.310000   0.000000   0.310000 (  0.315844)
to_s  0.490000   0.000000   0.490000 (  0.490607)
to_sym  0.170000   0.000000   0.170000 (  0.171511)

Benchmark.bm(30) do |x|
 x.report("string.to_i == number") { n.times do   ; "123456789".to_i == 1234567890; end }
 x.report("number.to_s == string") { n.times do   ; 1234567890.to_s == '1234567890'; end }
 x.report("string.to_sym == string.to_sym") { n.times do   ; '1234567890'.to_sym == '1234567890'.to_sym; end }
 x.report("num.to_sym == string.to_sym") { n.times do   ; 1234567890.to_sym == '1234567890'.to_sym; end }
 x.report("number.sym == number.sym") { n.times do   ; 1234567890.to_sym == 1234567890.to_sym; end }
end

user     system      total        real
string.to_i == number           0.400000   0.000000   0.400000 (  0.401863)
number.to_s == string           0.740000   0.000000   0.740000 (  0.744603)
string.to_sym == string.to_sym  0.560000   0.000000   0.560000 (  0.574106)
num.to_sym == string.to_sym     0.460000   0.000000   0.460000 (  0.459292)
number.sym == number.sym        0.400000   0.000000   0.400000 (  0.399014)

Rails tip of the day

вторник, април 12th, 2011

Generating random string

ActiveSupport::SecureRandom.hex(16)

Autoicrement the serial in bind zone files

четвъртък, септември 2nd, 2010

Argh. 30+ zone files and I have to increment all numbers by hand…no way.

Usage:  ./inc.rb in the current directory with all db files.

#!/usr/bin/ruby

Dir.glob("*.db") do |file_name|
 new_zone = [] (още...)

Wireframing for faster website development

неделя, август 29th, 2010

I have tried the approach listed in “Getting Real” by 37signals and I have great results.

The client was very happy because he can imagine his website.

Now I am considering to buy or make such nice tools :)

http://www.uistencils.com/website-stencil-kit.html

http://www.mstonerblog.com/index.php/blog/comments/return_of_the_paper_wireframes/
1. Pencil

Pencil (free) is a Firefox plugin that professes to enable you to build wireframes and prototypes. As a prototyping tool it’s quite good, allowing you to quickly put together a reasonably high fidelity mockup. However, be aware you’ll still need to produce the visual design elements for Pencil, as it relies on dragging and dropping pre-made graphical elements.

The output wireframe elements that ship with Pencil do tend to be based on the look and feel of a Windows desktop application. This really is undesirable for a web application, however you could modify this with your own page elements.

Another downside of Pencil is that its export functionality provides only a few image formats. This means that Pencil falls short of being a real interactive prototype development tool.

Balsamiq Mockups

Balsamiq Mockups (price:$US79, demo available) is an interesting product running on Adobe AIR. Its representation of the interface elements has a refreshing hand-drawn, sketch-like quality to them. This does help promote the degree of changeability of the wireframes, as they look very much like a draft. If you lack the skills to create hand-drawn sketches then Balsamiq is a useful tool, as it allows you to produce quality roughs. Balsamiq also offers a standard collection of interactive screen elements, which is helpful to start off with.

http://gomockingbird.com/ is like balsamia

https://www.jumpchart.com/ – for very simple pages- I cant find how to change the layout.

Denim

A java based.

http://dub.washington.edu:2007/denim/

Eclipse based plugin – http://wireframesketcher.com/

And a nice topic in stackoverflow http://stackoverflow.com/questions/55363/best-tools-for-creating-website-wireframes

iphone

http://iphonemockup.lkmc.ch/

Software development

събота, август 28th, 2010

After my blog post about the junior software developers I have very bright idea of how the world could get benefit from them.

When you catch a junior in mistake – let him contribute to the open source community. Not with coding. With translating. Take some open project and translate it to your native language.

Maybe after all the junior will release that he is much happier to translate than coding :)

win-win condition.

N.B. On the picture – Young coder is coding in Word.

Hash to encode iso-8859-1 (western) to html entities

сряда, август 25th, 2010
ENTITIES = {
 'À' => 'À',
 'Á' => 'Á',
 'Â' => 'Â', (още...)

Is Rails going down?

понеделник, август 23rd, 2010

The first Rails framework was fast. then it become slow, big and the idea of convetion over configuration becomes more poisoned.

Currently to start with Rails you have to learn a lot of stuff which are added just now and is not sure how long they will stay.

Also Rails is not targeting the developers to be fast but is targeting to be the perfect framework.

The price for that is that almost a year and a half there is no new version while the they refactor it.

No goodies like scafolding, only enterprise stuff around.

That is my personal opinion on this framework.

As I like to say – you cant leave your followers without food for such long time.

Piece of wizdom

неделя, август 22nd, 2010

The original code

<%= select(“city”,”kind”, t(:place_types).map.map!.each{|key, value| [value, key]}, {:include_blank => t(:chose), :selected => @city.kind}) %>

The bad code

t(:place_types).map.map!.each{|key, value| [value, key]}, {:include_blank => t(:chose), :selected => @city.kind})

the replacement

key_values = t(:place_types).collect{|key, value| [value.to_s, key.to_s, ]}

Rails.ouch.ouch.omg!