Skip to content

Instantly share code, notes, and snippets.

View liwh's full-sized avatar
🎯
Focusing

robie lee liwh

🎯
Focusing
View GitHub Profile
@eric1234
eric1234 / 0_instructions.txt
Created April 9, 2011 01:12
Using Sprockets 2 in Rails 3.0.x with CoffeeScript & SASS
UPDATE: Please see some of the forks for an updated version of this guide. I
myself have moved onto the Rails 3.1 betas to get the asset pipeline. But if
you want to stay on stable there are other folks who are keeping this guide
relevant despite the changes constantly occurring on Sprockets 2. The comments
on this gist will lead you to the right forks. :)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@dwarfmondo
dwarfmondo / placeholder-text.js
Created May 1, 2011 19:12
Add placeholder text functionality for IE.
/*
CSS to style the placeholder text.
Separate rule for Firefox.
Cannot stack with WebKit's.
*/
input.placeholder_text,
textarea.placeholder_text {
color: #777;
}
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

Sprockets Railtie Setup

This file at actionpack/lib/sprockets/railtie.rb defines the Sprockets::Railtie, defining another Railtie for Rails. This Railtie is responsible for detecting if the application at-hand is using CoffeeScript, and if so will set config.app_generators.javascript_engine on the application to be :coffee.

Next, this defines an initializer called sprockets.set_configs which sets up ActionController::Base to either use or not use sprockets depending on the configuration option config.assets.enabled.

Finally, this file defines an after_initialize hook for the application which is the real meat of this Railtie. If assets are disabled (with the config.assets.enabled config option set to false) then this after_initialize hook will do nothing.

If assets are enabled then, this initializer first makes a call to an asset_environment protected method near the bottom of this file which requires the sprockets gem, creates a new Sprockets::Environment object, and then co

@shedd
shedd / assets.rake
Created June 20, 2011 18:05
Check asset encoding for valid UTF-8
namespace :assets do
task :check => :environment do
paths = ["app/assets", "lib/assets", "vendor/assets"]
paths.each do |path|
dir_path = Rails.root + path
if File.exists?(dir_path)
dir_files = File.join(dir_path, "**")
@brentertz
brentertz / _base.scss
Created July 3, 2011 02:59
Flash messages
/* Flashes
-------------------------------------------------------------- */
.js #flash {
display: none;
}
#flash {
position: absolute;
width: 100%;
z-index: 10000;
@nolman
nolman / async_io.rb
Created July 7, 2011 05:56
Async IO
require 'rubygems'
require 'eventmachine'
require 'em-http-request'
require 'fiber'
EventMachine.run do
http = EM::HttpRequest.new('http://www.google.com').get
begin
puts "Before"
http.callback {
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@flores
flores / gist:1179586
Created August 29, 2011 22:25
HAProxy -> Ruby 1.9.2p290 Sinatra/Thin, 8 * (HTTPerf, 1.5K rate, 20K connections) testers
# httperf --server=shark-biggie.borderstylo.com --port=80 --uri=/pie --num-conn 20000 --ra 1500 --hog
httperf --hog --client=0/1 --server=shark-biggie.borderstylo.com --port=80 --uri=/pie --rate=1500 --send-buffer=4096 --recv-buffer=16384 --num-conns=20000 --num-calls=1
Maximum connect burst length: 148
Total: connections 20000 requests 20000 replies 15484 test-duration 106.023 s
Connection rate: 188.6 conn/s (5.3 ms/conn, <=16926 concurrent connections)
Connection time [ms]: min 37.2 avg 33363.5 max 96430.5 median 25186.5 stddev 29166.2
Connection time [ms]: connect 23533.0
Connection length [replies/conn]: 1.000