Skip to content

Instantly share code, notes, and snippets.

View loginx's full-sized avatar

Xavier Spriet loginx

View GitHub Profile
@kpumuk
kpumuk / deploy.rb
Created November 18, 2009 10:03
Using bundled Jammit to precache assets in deploy.rb
namespace :deploy do
desc 'Bundle and minify the JS and CSS files'
task :precache_assets, :roles => :app do
root_path = File.expand_path(File.dirname(__FILE__) + '/..')
jammit_path = Dir["#{root_path}/vendor/gems/jammit-*/bin/jammit"].first
yui_lib_path = Dir["#{root_path}/vendor/gems/yui-compressor-*/lib"].first
assets_path = "#{root_path}/public/assets"
# Precaching assets
run_locally "ruby -I#{yui_lib_path} #{jammit_path}"
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
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
@loginx
loginx / irb.rb
Created May 30, 2012 16:21
How to use make_flaggable with STI relations
User.find(1).flag Tablet.find(1)
# => #<MakeFlaggable::Flagging id: 1, flaggable_type: "Device", flaggable_id: 1, flagger_type: "User", flagger_id: 1, reason: nil, created_at: "2012-05-30 16:16:23", updated_at: "2012-05-30 16:16:23">
User.find(1).flagged? Tablet.find(1)
# MakeFlaggable::Flagging Load (0.4ms) SELECT "flaggings".* FROM "flaggings" WHERE "flaggings"."flagger_id" = 1 AND "flaggings"."flagger_type" = 'User' AND "flaggings"."flaggable_type" = 'Tablet' AND "flaggings"."flaggable_id" = 1 LIMIT 1
# => false
# :rage:
#########
# If you look at the query, it inserted the `flaggable_type` as 'Device', but is searching for 'Tablet'
@johnthethird
johnthethird / ie8.html
Created June 9, 2012 20:54
IE8 Batman Performance
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>Batman Profiler</title>
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/es5-shim.js"></script>
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/v0.9.0/lib/batman.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2024 09:51
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ryanray
ryanray / deploy.rb
Created November 21, 2013 11:15
I couldn't find a quick example of how to deploy a node.js app using Capistrano 3. This gist assumes you are using Capistrano 3, Upstart, Forever, ssh/forward agent, and an unprivileged user named 'deploy'. Hopefully this simple setup will help to get you started.
# config/deploy.rb
# probably a lot of ways to improve this...
set :application, 'my_app'
set :repo_url, '[email protected]:USERNAME/my_app.git'
# should set up a deploy user
set :user, 'deploy'
set :deploy_to, '/var/www/my_app'
set :scm, :git