Source: Woork! - Beautiful Javascript Date Pickers
Great list of Date Picker plugins and scripts, for several Javascript frameworks.
Ruby On Rails and a Conning Israeli entrepreneur
Beautiful Javascript Date Pickers
Rails 2 i18n: Globalize2 plugin for Rails
A while ago i posted a post about a Globalize plugin bug in Rails 2.x. Eventually i found a solution but i was still waiting for a real solution for Rails 2.x to supersede my monkey patching.
Well, it's here.
note for the Hebrew natives: check out the examples :)
Globalize2 is the successor of Globalize for Rails.
It is compatible with and builds on the new I18n api in Ruby on Rails. and adds model translations as well as a bunch of other useful features, such as Locale fallbacks (RFC4647 compliant) and automatic loading of Locale data from defined directory/file locations.
Globalize2 is much more lightweight and modular than its predecessor was. Content translations in Globalize2 use default ActiveRecord features and do not limit any functionality any more.
All features and tools in Globalize2 are implemented in the most unobstrusive and loosely-coupled way possible, so you can pick whatever features or tools you need for your application and combine them with other tools from other libraries or plugins.
Get it from joshmh Github Repo
Elliott Kember: Sexy Page Curl JQuery plugin
Just one of those fun-and-no-real-use things you might want to put in your blog/personal-homepage.
Elliott Kember created this Page Curl plugin for JQuery which shows a page curl on the corner of your website, with the option to set an image below it.
Check the demos.
Periodical AJAX requests and Session Expiry
My current applicaiton requires a session expiry feature, so fat, pretty ordinary, i decided to use the limited sessions plugin, as i always do.
The problem came up when i found out, that sessions aren't being released after the desired time had passed.
What was the problem?
first we will need to understand how rails uses sessions, basically it's something like that
- session is retrieved from whereever it is. (ActiveRecordStore,CookieStore...)
- Controller#Action is being preformed
- Session is saved
Solution
In my application.rb, i have a before_filter which updated the session with user_id in order to relate the session to the user, i migrated another field into the session table so i can keep my own track over changes, named it 'last_updated' like that
class AddCustomUpdateDateToSessions < ActiveRecord::Migration
def self.up
add_column :sessions, :last_updated, :datetime
end
def self.down
remove_column :sessions, :last_updated
end
end
and changed the application.rb method to update the new field, instead of the 'updated_at' field, and prevented my AJAX requests to update to the session, no need.
before_filter :update_session
def update_session
unless request.xhr?
if logged_in?
if session.model.user_id.nil?
session.model.update_attribute(:user_id, current_user.id)
end
session.model.update_attribute(:last_updated, DateTime.now)
end
end
end
(yeah, i know it can be done better.)
i also needed to change all the 'updated_at' references to 'last_updated' field inside the plugin's limited_sessions.rb, in order to completely take control over the session update flag.
now it's working and my ajax calls do not cause the expiry interval to expire.
attachment_fu and minimagick resize bug
In one of my latest projects i was using the attachement_fu plugin to handle image uploads.
The attachement_fu plugin enables the option to select an image processor engine between ImageScience, Rmagick add MiniMagick:
- Rmagick
Kinda bulky, leaking but fully functional - MiniMagick
Simple version of Rmagick, simple and small. - ImageSceince
Small, nice, and quick.
sudo gem install mini_magick
and added a specific :processor option to my Logo model.
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 2.megabytes,
:resize_to => 'x100',
:processor => :mini_magick
but when i was uploading an image, i was was expecting it to be resized based on the options i specified in the model. imagine how surprised i was when i found out that the image is not being resized.
checking the log found the following error:
Exception working with image: ImageMagick command (identify "/var/folders/Bv/Bvbna8-OH548ZWju8naF4U+++TI/-Tmp-/minimagick11451-0") failed: Error Given 32512
Googling it didn't help me much (except from finding other people with the same problem), so i decided to switch to ImageScience instead (RMagick is out of the question of course).
sudo gem install image_science
this will include all most all dependencies, the freeImage dependency is also needed.
us mac/darwin users can simply use port:
sudo port selfupdate
sudo port install freeimage
now change the processor in the model
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 2.megabytes,
:resize_to => 'x100',
:processor => :image_science
and now it's working. yeah!.
Rails Plugin: Dynamic Session Expiry
With session_lifetime you can set after how much time of inactivity your session should expire, you can execute an action when the session expires, and you can set where to redirect_to after session expiry.
Example
class ApplicationController << ActionController::Base
expires_session :time => 2.hours, :redirect_to => '/login'
protected
def on_expiry
flash[:notice] = "Your session has been expired, and you have been logged out."
end
end
Get it from
git://github.com/DefV/session_lifetime.git
Rails Plugin: import_svn
This plugin imports a rails project into subversion (excluding tmp files, logs and more) and converts the current directory to a working copy of that project.
SvnImport goes a little bit further than just adding everything; it ignores resources such as logs, tmp files and database.yml and environment.rb.
For the database.yml and environment.rb files, SvnImport creates template files, and provides a task for copying them back after checkout. This allows each developer to have their own database settings and/or keep the password for the production database out of version control.
Installation
script/plugin install https://svn.cjohansen.no/rails/plugins/svn_import/trunk
Usage
rake svn:import
This task will only successfully run once - before the applicaton has been added to subversion. Once it's been added, the task will no longer do anything. When a new developer checks out the project, she can get the standard setup by doing:
rake svn:setup
Source
Update: Rails 2.1 globalize plugin - Fix
I am using globalize since ever, I always prefered it over gettext or what ever taylor made i18n solution out there.
It seems to be that there is a problem with the action method of date_select, or if to be more specific, the month_select helper produces a "wrong number of arguments" exception... I droped the usage of the globalize plugin for meantime... But I am really looking forward for a real solution... Anyone?
Update
i found a post a about a Rails 2.1 compliant Globalize plugin release. it is currently working for me with no special problems.
Installation:
script/plugin install git://github.com/heythisisnate/globalize.git
Rails Tip: Annotate models
Ever happened to forget what columns does a Model has?
well, instead of Model.column_names, you can easily install the annotate_models plugin which adds the models schema info as a comment at the top of your model.rb file.
install from
script/plugin install http://repo.pragprog.com/svn/Public/plugins/annotate_models
and from the project root
rake annotate_models
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
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)