Skip to content

Instantly share code, notes, and snippets.

View deepakdargade's full-sized avatar
🎯
Focusing

Deepak Dargade deepakdargade

🎯
Focusing
View GitHub Profile
@deepakdargade
deepakdargade / installation.sh
Created April 13, 2012 07:27 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@deepakdargade
deepakdargade / 01_step.sh
Created April 5, 2012 12:01 — forked from Mikke/01_step.sh
Rails 3 has_many use checkboxes and multiple select in the form
rails g scaffold Book title:string description:text
rails g scaffold Pubhouse title:string address:text
rails g model BookPubhouse book_id:integer pubhouse_id:integer
rake db:migrate
module ActAsArchive
def self.included(klazz)
klazz.extend Query
end
module Query
def archived
unscoped {
where("is_archvied = ? ", true)
}
@deepakdargade
deepakdargade / README.markdown
Created March 28, 2012 07:56 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@deepakdargade
deepakdargade / Paperclip Wicked PDF image tag rewrite
Created March 20, 2012 10:45
Paperclip Wicked PDF image tag rewrite
def wicked_pdf_image_tag(img, options={})
if img[0].chr == "/" # images from paperclip
new_image = img.slice 1..-1
image_tag "file://#{Rails.root.join('public', new_image)}", options
else
image_tag "file://#{Rails.root.join('public', 'images', img)}", options
end
end
@deepakdargade
deepakdargade / config.ru
Created March 1, 2012 13:02
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application
@deepakdargade
deepakdargade / Gemfile
Created January 19, 2012 11:03 — forked from BellandWhistle/Gemfile
Faye and Ruby on Rails 3
gem 'faye', '0.6.1'
@deepakdargade
deepakdargade / reorderable
Created January 2, 2012 07:17 — forked from chebyte/reorderable
plugin for reorder item with rails 3 and jquery
# Reorderable
Allows drag-n-drop reordering of ActiveRecord model items when using MySQL and jQuery.
## Installation
Add the following to your Gemfile:
gem 'reorderable', :git => "git://github.com/chebyte/reorderable.git"
@deepakdargade
deepakdargade / gist:1475528
Created December 14, 2011 06:34 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end