Skip to content

Instantly share code, notes, and snippets.

View deepakdargade's full-sized avatar
🎯
Focusing

Deepak Dargade deepakdargade

🎯
Focusing
View GitHub Profile

Rails 2.3.10 on App Engine (DataMapper)

Do not use rvm (or install and run from JåRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also: gist.github.com/gists/269075

Install the Development Environment

@deepakdargade
deepakdargade / speadsheet.rb
Created August 5, 2011 08:09 — forked from brianstorti/speadsheet.rb
Ruby spreadsheet example
require 'spreadsheet'
Spreadsheet.client_encoding = 'UTF-8'
TEST_FILE = "test.xls"
MODIFIED_FILE = "modified.xls"
def inspect_sheet sheet
sheet.each do |row|
if row[1].is_a? Spreadsheet::Formula
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
options = OpenStruct.new
options.rows = 10
options.columns = 10
OptionParser.new do |opts|
opts.on('-r', '--rows [INTEGER]', 'Number of rows', Integer) do |x|
@deepakdargade
deepakdargade / _form.html.haml
Created August 15, 2011 12:06 — forked from CamonZ/_form.html.haml
Polymorphic Autosave Associations with Paperclip
= f.error_messages
%div{:style=>"padding-bottom:20px"}
%div
= f.label :name, 'Nombre del producto'
%br
= f.text_field :name, :size => 70
#clientdesc
%div
= f.label :excerpt, 'Resumen del producto'
%br
@deepakdargade
deepakdargade / Devise-Trackable.rb
Created October 6, 2011 07:34
Devise Trackable file
require 'devise/hooks/trackable'
module Devise
module Models
# Track information about your user sign in. It tracks the following columns:
#
# * sign_in_count - Increased every time a sign in is made (by form, openid, oauth)
# * current_sign_in_at - A timestamp updated when the user signs in
# * last_sign_in_at - Holds the timestamp of the previous sign in
# * current_sign_in_ip - The remote ip updated when the user sign in
@deepakdargade
deepakdargade / jquery-put-data-rails
Created October 6, 2011 07:36
Rails 3 put data through jquey ajax
In gemfile add,
gem "json"
In javascript file,
var path ="/branches/8/student/154;
$.ajax({
type: "PUT",
url: path,
data: { student : JSON.stringify( {name : "deepak", last_name : "dargade"} ) },
dataType: 'json',
@deepakdargade
deepakdargade / rails3-select-with-default-values.rb
Created October 6, 2011 07:40
rails 3 select with default values
options_for_select(@user_groups.collect { |p| [p.name, p.id] }, @user.user_group)
@deepakdargade
deepakdargade / custom-attributes-to-select-options.rb
Created October 6, 2011 07:43
rails 3 custom attributes to select options
<%= f.select :country_id, options_for_select(@countries.map{ |c| [c.name, c.id, {'data-currency_code'=>c.currency_code}] }) %>
@deepakdargade
deepakdargade / rails3-custom-attributes-to-select-options-2.rb
Created October 6, 2011 07:44
rails 3 custom attributes to select options 2
<%= f.select :country_id, options_for_select(@countries.map{ |c| [c.name, c.id, {'data-currency_code'=>c.currency_code}] }, selected_key = f.object.country_id) %>
@deepakdargade
deepakdargade / rails3-custom-attributes-to-select-options-3.rb
Created October 6, 2011 07:45
rails 3 custom attributes to select options 3
<%= f.select :country_id, grouped_options_for_select(@continents.map{ |group| [group.name, group.countries.map{ |c| [c.name, c.id, {'data-currency_code'=>c.currency_code}] } ] }, selected_key = f.object.country_id) %>