Skip to content

Instantly share code, notes, and snippets.

View linjunpop's full-sized avatar
🐚
Sleeping

Jun Lin linjunpop

🐚
Sleeping
View GitHub Profile
namespace :sass do
desc 'Updates stylesheets if necessary from their Sass templates.'
task :update => :environment do
sh "rm -rf public/stylesheets/compiled tmp/sass-cache"
Sass::Plugin.options[:never_update] = false
Sass::Plugin.update_stylesheets
end
end
Copyright (C) 2011 by Strobe Inc
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:
The above copyright notice and this permission notice shall be included in
@chapados
chapados / yield-self.m
Created June 18, 2011 20:21
yield(self) pattern implemented with objective-C blocks
//
// yield(self) pattern implemented using objective-C blocks
// (not as pretty as Ruby...)
//
// compile:
// llvm-gcc-4.2 -o yield-self -framework Foundation yield-self.m
#import <Foundation/Foundation.h>
@class MyClass;
@mrsweaters
mrsweaters / nginx_virtual_host
Created October 23, 2011 17:10 — forked from scottlowe/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
upstream example-workers {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a single worker for timing out).
server unix:/tmp/example.co.uk.socket fail_timeout=0;
}
server {
listen 80; # default;
server_name example.co.uk;
root /home/example.co.uk/website/public;
@daronco
daronco / README
Created January 19, 2012 13:31
Organize javascripts and stylesheets like views in rails 3.1
Call the helpers 'javascript_include_tags_for_action' and 'stylesheet_link_tags_for_action' in the headers section
of your layout to automatically include javascript and stylesheet files for the current controller and action.
The files are included only if they exist. It is first included the file for all the actions of acontroller (e.g 'events/_all.js')
and then the file for the current action (e.g. 'events/show.js').
You can organize javascripts and stylesheets like views are organized.
Assuming you have the controllers "Events" and "Spaces":
- app/
@flaneur2020
flaneur2020 / Gemfile
Created February 8, 2012 02:27
less painful web prototyping with sinatra, slim, sass, and coffeescript
source 'http://ruby.taobao.org'
gem 'sinatra'
gem 'sinatra-reloader'
gem 'slim'
gem 'sass'
gem 'coffee-script'
gem 'compass'
gem 'pry'
@sj26
sj26 / README.md
Created February 29, 2012 10:38
Subdomains in Rails 3

Subdomains in Rails 3

Are still a nightmare to get tested, etc.

To share sessions across subdomains you need to set the session options during the request so you know what domain you're sharing across. This means we still need to do it with a before_filter, or something similar. It looks like you should be able to set :domain => true in config/initializers/session_store.rb to do this instead but Devise does not support it yet as far as I can see.

Here I'm using subdomains with a custom url_for extension which means from "http://www.smackaho.st" root_path would be "/" while from "http://admin.smackaho.st" root_path would be "http://www.smackaho.st/".

In cucumber this is forced to always qualify the full URL with the subdomain. It also rewrites the port in/out as neccessary to cope with Capybara's server using an alternate port (used by Selenium for javascript testing etc). The project I'm on is still using web_steps (sigh) so I had to touch the "should be on" step definition to cope with

@amateurhuman
amateurhuman / gist:2005745
Created March 9, 2012 09:03
Installing Rubinius 2.0.0-dev with rbenv

Installing rbx-2.0.0-dev with Ruby 1.9 support using rbenv can be a tad tricky. This is what I did to get up and running, you'll need another version of ruby already installed as well as rake.

The basic outline:

  1. Clone Rubinius HEAD from github
  2. Configure installation for rbenv and 1.9 support
  3. Install Rubinius
  4. Configure your $PATH to use Rubinius gems
  5. Start using Rubinius
@wrburgess
wrburgess / gist:2086949
Created March 19, 2012 00:20
Setting up New Relic for Sinatra on Heroku #newrelic #sinatra #heroku
@2bits
2bits / wkhtmltopdf.rb
Created April 14, 2012 10:53
wkhtmltopdf-0.11.0_rc1 hack to build their patched qt as an option
require 'formula'
class WkhtmltopdfQt < Formula
url 'git://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt.git'
end
class Wkhtmltopdf < Formula
homepage 'http://code.google.com/p/wkhtmltopdf/'
url 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1.tar.bz2'
sha1 'db03922d281856e503b3d562614e3936285728c7'