Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
# see http://coderack.org/users/dira/middlewares/76-haml-sass-for-static-sites | |
app = Rack::Builder.new do | |
use Rack::SiteGenerator#, :generators => { :html => :erb, :css => :less }, :source_path => "views/others" | |
run Rack::StaticApp.new | |
end | |
Rack::Handler::Mongrel.run app, :Port => 9292 |
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/) | |
// Then, use underscore's mixin method to extend it with all your other utility methods | |
// like so: | |
_.mixin({ | |
escapeHtml: function () { | |
return this.replace(/&/g,'&') | |
.replace(/>/g,'>') | |
.replace(/</g,'<') | |
.replace(/"/g,'"') | |
.replace(/'/g,'''); |
# config/initializers/omniauth.rb | |
module OmniAuth | |
module Strategies | |
# tell OmniAuth to load our strategy | |
autoload :Pixelation, 'lib/pixelation_strategy' | |
end | |
end | |
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :twitter, "app_name", "secret" |
# app/uploaders/avatar_uploader.rb | |
process :fix_exif_rotation | |
process :strip | |
process :resize_to_fill => [1024, 768] | |
process :quality => 90 # Percentage from 0 - 100 |
Some exercises from the Falsy Values workshops.
The good parts:
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is no longer valid. Please see Compass-Rails for instructions on how to install.
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rubygems' | |
gem 'minitest' | |
require 'minitest/autorun' | |
require 'action_controller/test_case' | |
require 'miniskirt' | |
require 'capybara/rails' |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
view = Backbone.View.extend | |
initialize: | |
@render() | |
render: | |
$el.html('<div class="content">fun times</div>') |