Page 10 of 30

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?

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)

Lenovo y410 windows7 notes

Audio, Alps Touch pad and Video drivers are not installed properly for Windows 7 – Given by Lenovo.

I searched audio driver on realtek website and latest HD driver are working fine with windows 7.

I found toshiba alps touch pad driver and it is working fine. Scrolling is now working fine with touch pad.

javascript mvc compare

framework/keywords  - Google Results  - Github      Last Commit
backbone rails mvc  - 1,490,000         2432, 258   May 27, 2011
knockout rails mvc  - 383,000           495, 66     May 22, 2011
spine rails mvc     - 110,000           595, 32     about 14 hours ago
jamal rails mvc     - 77,500            12, 3       March 10, 2011
aframe rails mvc    - 8,840             1, 1        about 15 hours ago

My xfce setup

Some shortcuts

Alt + F4 Close window
Alt + F5 Maximize window
Alt + F6 Maximize vertically
Alt + F7 Maximize horizontally
Alt + F8 Hide window
Alt + F9 Shade window
Alt + F10 Stick window
Alt + Tab Cycle windows focus
Ctrl + Shft + Alt + Arrow (up, down, left, or right) Move window
Shft + Alt + Arrow (up, down, left, or right) Resize window
Shft + Alt + Page_Up Raise window
Shft + Alt + Page_Down Lower window
Alt + F11 Toggle fullscreen
Ctrl + Alt + Arrow right arrow Next workspace
Ctrl + Alt + Arrow left Previous workspace
Alt + Insert Add a workspace
Alt + Delete Delete a workspace
Ctrl + F(N) Go to workspace number N (1-9)
Alt + Ctrl + Home|End Move the window to previous|next workspace
Alt + Ctrl + keypad key number N Move a window to workspace number N (1-9)
Alt + F1 Start xfhelp4
Alt + F2 Start xfrun4
Alt + Ctrl + Delete Lock the screen

Ubuntu Unity Nonsense

Just upgraded the ubuntu to 11.04 (Natty Narwhal) and what a surprise! I got MacOS look and feel.

Doing some research and I can’t believe Gnome3 has the same STUPID look as MacOS OMG!!!

What innovation  you see at copying the same OS from MAC. I remember the days when the Linux desktop looks innovating and it was pleasure to work with so many options. Now everything is going the Apple way.

I felt depressed is there around at least one windows manager which is not influenced from Apple?

I hate Dock launchers –  looks not innovating – it looks clumsy and old. Everything which is copied clumsy!

Gnome3 – you are going on the same path as Unity!

Windows7 – is 100 times better because it has its OWN LOOK AND FEEL – I’d rather work with windows7 than on a Gnome3/Unity. Blah!

The solution?

Xfce desktop is now closes to what Gnome was

MAC OS, WTF?!

No support for write on NTFS drives.

strange keyboard – I remember how I laugh when microsoft put their logo on dedicated button on the keyboards – haha -> Apple

Usability – What are those fancy drawing on the keys, they look all the same to me, no way to rember them.

Fucked hardware – $60 for cable which cost less then $1 haha, no card reader.

Nice plastic case with big mouse pad.

I hate the way how MAC os wants to be different making some irritating changes – not revolution – only some small tweaks.

Apple Mac is for people which DON’T know how to work with computers

http://shadowofged.blogspot.com/2007/07/bad-news-on-doorstep.html

Rails tip of the day

Generating random string

ActiveSupport::SecureRandom.hex(16)

Netbeans is dropping Ruby/Rails

They have to put their efforts on Java. Phuuuu.

Seriozly this was the best IDE around for Ruby/Rails.

  • RubyMine – is heavy and cluttered and it is not free
  • Vim – is nice but it is NOT ide
  • RadRails – is in some beta

Here is a list of alternatives on stackoverflow and some others

Why not to choose wordpress for a publishing platform

Today when I look in my xcache I found interesting fact. Most of the wordpress pages are around  1Mb.

OMG! 1MB for a blog post. This is server/memory killer.

One more thing is that their API is total mess (very well documented) but still mess.

© 2024 Gudasoft

Theme by Anders NorénUp ↑