This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
# Be sure to have rails and thin installed. | |
require "rubygems" | |
# We are not loading Active Record, nor the Assets Pipeline, etc. | |
# This could also be in your Gemfile. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
# The following lines should come as no surprise. Except by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# USAGE: ruby myleakedin.rb yourpassword | |
# assumes you have the dump in the same dir as combo_not.txt | |
require 'digest/sha1' | |
pass = ARGV.first | |
hex = Digest::SHA1.hexdigest(pass) | |
print "HEX: #{hex} => " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
class PerfTest | |
def with_inject(array) | |
mapped_vals.inject(array, :<<) | |
end | |
def with_plus(array) | |
array + mapped_vals | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleStateMachine | |
extend ActiveSupport::Concern | |
# instance methods | |
included do | |
def current_step | |
# model that includes this module must have a field called 'current_step' | |
super || steps.first | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jQuery custom plugin skeleton with CoffeeScript | |
class MyPlugin | |
someMethod: (args) -> | |
# do something | |
constructor: (element, params) -> | |
@someMethod(some_args) | |
# do something | |
# install in the window namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/custom_devise/password_controller.rb | |
class CustomDevise::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(resource_name).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"code.google.com/p/go.net/websocket" | |
) | |
type connection struct { | |
// The websocket connection. | |
ws *websocket.Conn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
This code is a working example of the code shown in the 12devs[0]'s article: | |
"Rapid Prototyping with AngularJS"[1] by Tom Ashworth[2]. | |
I put it here for reference ;-) | |
[0] http://12devs.co.uk | |
[1] http://12devs.co.uk/articles/rapid-prototyping-with-angularjs/ | |
[2] http://twitter.com/phuunet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#commit model | |
class Commit < ActiveRecord::Base | |
# 1) We don't need a provider based Commit subclass, a String field | |
# should be enough. In case, we can associate a Provider model | |
# (1 to 1 relation) that represents a specific provider | |
# 2) we might want to use commit IDs, then build the commit URL at runtime | |
# (perhaps an URL template specific to the provider should be specified in Provider model) | |
# this shuould prevent eventual URL changes by providers :-) | |
attr_accessible :commit_url, :author, :commit_message, :provider |