Skip to content

Instantly share code, notes, and snippets.


Adam Lassek alassek

  • Flywheel
  • Omaha, NE
View GitHub Profile
kneath /
Created Nov 18, 2009 — forked from defunkt/bundle.rake
Intelligent asset bundling for Rails (GitHub's asset bundling)

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js
karmi / workers.rake
Created Jul 22, 2010
Rake taks to launch multiple Resque workers in development/production with simple management included
View workers.rake
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
View twitter_user_timeline_search.rb
require 'twitter'
user = "sferik"
query = /rimm/i
(1..16).each do |page|
Twitter.user_timeline(user, :page => page, :count => 200).each do |tweet|
puts + ": " + tweet.text if query.match(tweet.text)
View gist:981520
# Bulk API design
# resources :posts
class PostsController < ActiveController::Base
# GET /posts/1,4,50,90
# post_url([ @post, @post ])
def show_many
@posts = Post.find(params[:ids])
dhh / gist:1014971
Created Jun 8, 2011
Use concerns to keep your models manageable
View gist:1014971
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
benedikt / rails.rb
Created Jul 30, 2011
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
View rails.rb
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
chrisk / crontab.erb
Created Aug 17, 2011
Example crontab generation in Capistrano
View crontab.erb
# This crontab is automatically generated on deploy
RAILS_ENV=<%= stage %>
RAKE_CMD="<%= "#{bundle_path} rake --rakefile #{current_path}/Rakefile --trace" %>"
LOG_FILE="<%= "#{current_path}/log/cron.log" %>"
# Note: times are in the user's local time
<% if stage == :production && primary_server -%>
mislav / Gemfile
Created Aug 31, 2011
How to integrate Compass with Rails 3.1 asset pipeline
View Gemfile
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass'
alassek / typeIntent.js
Created Sep 14, 2011
Trigger change event without hitting enter, like Google Live Search
View typeIntent.js
* Copyright (c) 2011 Lyconic, LLC.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
alassek / extendEach.js
Created Sep 19, 2011
Easy multiple-inheritance in Backbone.js
View extendEach.js
(function () {
function extendEach () {
var args =,
child = this;
_.each(args, function (proto) {
child = child.extend(proto);