PDFetch.com was released today by me and Shmuel Ahdut.
PDFetch is a simple app to enable a phrase specific search of online (and free of course) PDF files (other file types will be supported later on).
i will appreciate comments and remarks.
Ruby On Rails and a Conning Israeli entrepreneur
PDFetch released
Model Reflection Overview
We all use ActiveRecord Reflection on the fly while programming, since we declare all the relations in the model and we are considering it as obvious.
i tried to search and see if there is a way to find those reflections and to alter it in runtime.
Model.reflections
i found this collection which contains all the information about the current model reflections.
for example.
- .macro: this will return the type of the current reflection (:has_many, etc..)
- .primary_key_name: the reflection primary key
- .options: the reflection SQL join options
- etc. etc.
for example, the following code will show me all the reflections for a model named Article:
- >> y Article.reflections.values.collect {|e| e.macro.to_s + " => " + e.primary_key_name.to_s }
- ---
- - has_many => taggee_id
- - belongs_to => layout_id
- - has_many => article_id
- - has_one => subject_id
- - belongs_to => user_id
- - has_many => taggee_id
- => nil
iphone on rails
A simple way to build iPhone specific interface with Rails
- class ApplicationController < ActionController::Base
- exempt_from_layout('iphone_html.erb')
- before_filter :check_iphone
- protected
- def iphone?
- request.user_agent.include?('iPhone')
- end
- def check_iphone
- if iphone?
- request.parameters[:format] = 'iphone_html'
- end
- end
- end
- class DashboardController < ApplicationController
- def index
- @top_movies = Movie.top_movies
- @movie = @top_movies.first
- respond_to do |format|
- format.html # index.html.erb
- format.iphone_html #index.iphone_html.erb
- end
- end
- end
The running program
sometimes it can come handy to be able to know in which program you are running know.
it can be useful when displaying error information or such.
- caller(0)[0].split(".rb")[0] >> "(irb):74:in `irb_binding'"
WYMeditor - Standards driven WYSIWYG editor
no words are needed, just a small thanks.
thanks for my man Dor Kalev for finding this edgy top of the line XHTML WYSIWYG editor
among the amazing features of this new editor:
1. XHTML strict + CSS compliant
2. No font or text formatting, sizes or colors - WYMeditor is CSS-based Designed
3. to be easy to integrate into your application
4. No installation needed - this is 100% Javascript code - no plugin, no extension
5. Simple Javascript code, you don't need to be a 'Javascript Guru' to understand it
6. Will remain as simple as possible
7. focus on well-tested code, stability and usability before adding new features
8. Image, link, table support
9. Skins supportvia CSS
10. Free and Open Source, fully adaptable to your needs
UPDATED: 13/11/07
The dude released it as a plugin, i am a bit late with this update, but
there it is.
Setting up logger options
i was called the other day about one of my past projects server going down because it's production log exceeded 2GB.
regularly, there is a cron job to cycle the log file and prevent such joyous occasions, but for some reason it didn't happen. so i decided to read a little bit about the Logger class in Rails and see if it has some magic for me yet.
in order to replace the log file path (and/or name) use the following syntax in environment.rb:
- Rails::Initializer.run do |config|
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log")
- end
The actual cure for my problem came when i found the option to prevent the logger file from exceeding a pre-defined limit.
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log", 1, 2*1024*1024)
and a little extra for creating a brand new log file for each day.
- config.logger = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log", "daily")
i suggest reading even more on the rails development browser
Add custom operators in Ruby
Jay Phillips developed the 'superators' gem, which enables the use of custom operators in Ruby. for example.
- require 'rubygems'
- require 'superators'
- class Array
- superator "<---" do |operand|
- self << operand.reverse
- end
- end
- ["jay"] <--- "spillihp"
relative_time_helper plugin
most of us are using rails's built in time_ago_in_words, Rick Olsan wrote a much better plugin to extend that use and gives much better results.
- <%= relative_time(Time.now) %>
- # today
- <%= relative_time(1.day.ago) %>
- # yesterday
- <%= relative_time(1.day.from_now) %>
- # tomorrow
- <%= relative_time_span([Time.now, 5.days.from_now]) %>
- # May 17th - 22nd
To install it just snap it out of:
- script/plugin install http://ar-code.svn.engineyard.com/plugins/relative_time_helpers
Unique Insertion into Array
- [1,2,3] | [3,4,5] >> [1, 2, 3, 4, 5]
Seeking Alpha 2.0: Launch successful
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!
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
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)