After a massive amount of work to do, we all can finally rest for a couple of days (but not too much).
The all new Seeking Alpha site is air-born. i am very proud to be in the technical name list for this one, it is a truly Rails'ish web platform brought to life in the hands of the top israeli ruby on rails aces, and may i add, the best people i had ever had the honour to work with.
so thank you all: Koby "sleepy" Menachemi, Dor "Diet Coke" Kalev, Shmuel l. Unity, Rita "Wacom" Kaplan, Yuval "Float:right;" Raz and the master, Adam "Big Blue" Fine.
way to go guys!
Ruby On Rails and a Conning Israeli entrepreneur
Seeking Alpha 2.0: Launch successful
Webistrano - Capistrano deployment the easy way
Blogfish introduced Webistrano, Webistrano is a Web UI for managing Capistrano deployments. It lets you manage projects and their stages like test, production, and staging with different settings. Those stages can then be deployed with Capistrano through Webistrano.
Webistrano's purpose is to make the deployment of multi-stage and multi-environment scenarios easy. Further it allows you to track who deployed what when to which servers and be alerted by email on each deployment.
Webistrano itself is a Ruby on Rails application that includes an edge version of Rails and all needed dependencies like Capistrano or Net::SSH. The only required dependencies are Ruby, Rake, and a database.
Currently the deployment part of Webistrano does not run on Windows.
The code is hosted at Rubyforge and distributed under the BSD license.
Webistrano can be downloaded here
Ruby For bloggers
There are 2 main issues to deal with when posting a technial post on a blog:
1. Syntax Highlighting
There is a wonderful service at The Complex which exports a beautiful Ruby (and other) code, as you see in this blog also.
2. Exampling
You want to example a piece of code you did, how to do it?
try this line:
- def show(&block)
- printf("%-25s>> %s\n", expr = block.call, eval(expr, block.binding).inspect)
- end
for example:
- show {%{ a = [1,2,3] }} ; show {%{ a.slice(1,2) }} ; show {%{ a.map { |x| x**3 } }}
will result in:
- a = [1,2,3] >> [1, 2, 3]
- a.slice(1,2) >> [2, 3]
- a.map { |x| x**3 } >> [1, 8, 27]
Using your GMail as ActionMailer Carrier
this was merely a try, it worked, but i don't think it's recommended so much, google might get angry.
create a conf file named ssmtp.conf in /etc/ssmtp
- # Config file for sSMTP sendmail
- #
- # The person who gets all mail for userids < 1000
- # Make this empty to disable rewriting.
- root=postmaster
- # The place where the mail goes. The actual machine name is required no
- # MX records are consulted. Commonly mailhosts are named mail.domain.com
- # GMAIL configuration
- mailhub=smtp.gmail.com:587
- AuthUser=youremail@gmail.com
- AuthPass=pass
- UseSTARTTLS=YES
- # The full hostname
- hostname=machinehostname
- # Are users allowed to set their own From: address?
- # YES - Allow the user to specify their own From: address
- # NO - Use the system generated From: address
- FromLineOverride=YES
then just point ActionMailer to user sendmail as carrier in your environment:
- ActionMailer::Base.delivery_method = :sendmail
and you are all set
Connection Options
i found a way to get the connection parameters (other than reading database.yml) of the current database connection.
- def connection_hash
- ActiveRecord::Base.connection.instance_variable_get(:@config_options)
- end
Dynamically adding methods
This is divine, ruby is too great to be true. no explanation needed.
- class Object
- def def(method_name, &block)
- (class << self; self end).send(:define_method, method_name, block)
- end
- end
- x = Object.new
- string = "This is a test"
- x.def(:elad_says) {puts "Elad says: " + string}
- x.elad_says
Routing List
i have seen someone doing this somewhere and i can't remember where. i personally didn't find any use to it, but, you know... someone will.
listing all your routes.
- ActionController::Routing::Routes.routes.each do |r|
- puts r
- end
Mean Mail Machine
i was trying the other day to create some sort of a newsletter. sadly it took me about 2 hours to generate and send 51000 emails (not spam :) ) so i tried to find a way to do it a little faster.
a friend of mine came across the idea of using threads so i tried to override the basics of ActionMailer in order to make the delivery method to user threads.
the change boosted me up to 18-20 mails per second, in other words, 1900% more efficient!
here is the code, just push it in your environment.rb (or lib, whatever), just don't use it for mean/nasty/microsoft needs :).
- ActionMailer::Base.delivery_method = :thread_smtp
- module ActionMailer
- class Base
- def perform_delivery_thread_smtp(mail)
- thread = Thread.new do
- perform_delivery_smtp(mail)
- end
- thread.run
- end
- end
- end
Customize Logger message format
I Hate these long, frustrating long messages coming out on me when i look at the log. They are long, and needed a refreshing change for my opinion.
here is what i found:
There is a method which is responsible for the actual STDOUT printing for the log file, it's called Logger#format_message. I decided to overrun it in a more pretty way.
I created a /lib library called logger_format.rb and required it in environment.rb,
- class Logger
- def format_message(level, time, progname, msg)
- "#{time.to_s(:long)} -- #{msg}\n"
- end
- end
for example.try it out and feel free to modify the output structure at will.
get classes of a class
- def get_all_subclasses_of(string)
- raise ArgumentError.new("#{string} is not an AR Class") if eval(string).class.ancestors
- .collect {|e| e.to_s.downcase}.include? ("ActiveRecord::Base")
-
- return ObjectSpace.subclasses_of(eval(string))
- end
num_to_english SVN
Number to english
num_to_english is my first plugin, i kinda thought it would become a nice addition to the Fixnum class in Ruby.
num_to_english hooks up to the Fixnum class and enables the use of the to_english method as follows
eizesus@eizesus-desktop:~/Projects/testing/trunk$ script/console
Loading development environment.
>> 3.to_english
=> "three"
>> 12.to_english
=> "twelve"
>> 34.to_english
=> "thirty-four"
>> 100.to_english
=> "one hundred"
>> (100 + 321).to_english
=> "four hundred twenty-one"
>> 12312311.to_english
=> "twelve million, three hundred twelve thousand, three hundred eleven"
get it from http://svn.creopolis.com/num_to_english/trunk
counter_cache
Many times when using a belongs_to relation, we encounter the need to size up that association, we can use 2 methods which are created for us, size and (association_pluralization)_count.
so if SuperHero has_many :super_powers than:
me = SuperHero.find(1)
me.super_powers.size
me.super_powers_count
they will both issue that same SQL statement at this point
SELECT count(*) as count_all FROM super_powers WHERE (super_hero_id = 1)
which basically preforms a SELECT * statement, we don't like it :)
the :counter_cache parameter for the belongs_to macro, indicates the use of a (association_pluralization)_count named column which will be incremented and decremented according to the use of the associative array, this can and does save a lot of time and DB - APP - DB roundup's.
The Chronic files
Although 20.days.ago is a very nice syntax and caused so many non-rails programmers to pass out almost naturally after seeing it work, it still ain't enough.
The Chronic gem enables parsing for date-description strings.
such "yesterday morning" or "sunday next month", Chronic will parse these strings into actual Time objects.
Read more...
Twiters Around
About Me

- Elad Meidar
- I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.
Blog Archive
-
▼
2009 (67)
-
▼
March (9)
- Moved to Mephisto
- Rails Nested Resources Tutorial
- Raphael: Amazing vector graphics Javascript Libraty
- Storing Files in Ruby on Rails
- Live Free: Open Source Software indexes
- Debugging Javascript in Web Applications: Major br...
- 140 Characters Web applications
- Rails and Facebook: Why (still) iFrame is better t...
- Rails Facebook App Enlightments: HTTP timeouts
-
▼
March (9)
Labels
- 1.9 (1)
- 2.0 (1)
- 2.2 (1)
- 2.3 (1)
- 2.x (1)
- accessibility (2)
- account (1)
- actionmailer (1)
- activerecord (3)
- adsense (1)
- affiliate (1)
- ajax (3)
- amazon (4)
- analytics (1)
- api (3)
- application (1)
- array (1)
- associations (1)
- attachment_fu (1)
- autocomplete (1)
- aws (2)
- blog (4)
- books (4)
- boolean (1)
- browser (8)
- browsers (3)
- bugs (4)
- buzz (1)
- callback (1)
- callbacks (1)
- caller (1)
- capistrano (1)
- chronic (1)
- class (2)
- classes (1)
- classifieds (1)
- client (1)
- coding (2)
- collboration (1)
- console (2)
- convert (1)
- core (2)
- core. object (1)
- cost (1)
- css (7)
- database (10)
- date (3)
- dating (1)
- db (2)
- debug (2)
- deploy (5)
- deployment (3)
- design (11)
- development (5)
- dojo (1)
- eager (1)
- ec2 (2)
- effects (1)
- elad (2)
- email (3)
- engine (1)
- engineyard (1)
- english (1)
- entrepreneur (1)
- environment (2)
- erd (1)
- error (1)
- example (1)
- expire (1)
- explorer (1)
- extention (1)
- extra (2)
- facebook (2)
- fast (1)
- file (1)
- files (1)
- firefox (4)
- fixtures (1)
- font (1)
- form (1)
- framework (16)
- free (6)
- funny (2)
- gem (7)
- gems (2)
- git (5)
- globalize (2)
- gmail (3)
- google (8)
- graphes (2)
- graphics (1)
- guides (4)
- hacks (1)
- hosting (1)
- html (1)
- http (1)
- ie (5)
- ie8 (1)
- image (2)
- indomite (1)
- install (1)
- iphone (1)
- israel (2)
- javascript (19)
- JQuery (10)
- js (3)
- legacy (1)
- leopard (1)
- lib (1)
- library (3)
- links (2)
- list (1)
- loading (1)
- log (1)
- logger (2)
- logging (1)
- love (1)
- mac (4)
- mail (2)
- manuals (1)
- mapping (1)
- mass (1)
- mephisto (3)
- mercurial (1)
- meta (1)
- metaprogramming (3)
- microsoft (1)
- migrations (2)
- minimagick (1)
- mistake (1)
- mistakes (1)
- model (1)
- money (4)
- mootools (4)
- move (1)
- movies (2)
- music (1)
- mvc (2)
- mysql (2)
- native (1)
- nested (1)
- network (1)
- new (1)
- newsletter (1)
- num_to_english (1)
- numbers (2)
- object (1)
- observer (1)
- ohad (1)
- open (1)
- operators (1)
- optimization (4)
- oracle (4)
- overload (1)
- parse (1)
- pdf (4)
- php (3)
- plugin (11)
- plugins (7)
- programming (4)
- programs (1)
- projects (5)
- prototype (1)
- queries (1)
- rails (50)
- rails 2.0 (10)
- rails 2.1 (6)
- rake (2)
- rants (1)
- record (1)
- reflections (1)
- release (3)
- rendering (1)
- reset (1)
- resize (1)
- rest (1)
- rjs (1)
- ror (1)
- routes (3)
- routes.rb (2)
- ruby (49)
- ruby on bells (2)
- ruby on rails (28)
- ruby-debug (1)
- s3 (2)
- salary (1)
- scaling (2)
- schema (2)
- screencasts (1)
- script (4)
- scripts (1)
- search engine optimization (1)
- security (3)
- seeking alpha (1)
- select (1)
- sendmail (1)
- seo (2)
- sequencer (1)
- sessions (1)
- share (2)
- shell (1)
- site (3)
- site map (1)
- sites (1)
- skype (1)
- social (2)
- source (1)
- source control (4)
- sprites (1)
- sql (1)
- stand alone (1)
- standards (1)
- startup (6)
- storage (2)
- subversion (4)
- svn (1)
- team (1)
- technology (1)
- testing (1)
- textmate (1)
- thread (1)
- time (1)
- tips (45)
- tools (5)
- tracking (1)
- tricks (36)
- tutorials (5)
- ui (4)
- uml (1)
- update (1)
- upgrading (2)
- url (1)
- usability (2)
- user interface (7)
- validations (1)
- vector (1)
- vote (1)
- web (9)
- web services (2)
- web2.0 (4)
- webistrano (1)
- wire (1)
- wwr (1)
- xhtml (1)
- yahoo (1)
- yui (1)
- רובי (8)
- רובי און ריילס (7)