sudo apt-get install sbcl
curl -O http://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
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
# Load modules | |
Hapi = require("../../../lib") | |
# Declare internals | |
internals = {} | |
rootHandler = (request) -> | |
request.reply.view "index", | |
title: "examples/views/jade/index.js | Hapi " + Hapi.utils.version() | |
message: "Index - Hello World!" |
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
# requires BSD sed | |
namespace :whitespace do | |
desc 'Removes trailing whitespace' | |
task :cleanup do | |
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`; | |
do sed -i '' 's/ *$//g' "$f"; | |
done}, {:verbose => false} | |
puts "Task cleanup done" | |
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
class ModelWizard | |
attr_reader :object | |
def initialize(object_or_class, session, params = nil, param_key = nil) | |
@object_or_class = object_or_class | |
@session = session | |
@params = params | |
@param_key = param_key || ActiveModel::Naming.param_key(object_or_class) | |
@session_params = "#{@param_key}_params".to_sym | |
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
def step?(step) | |
@current_step.nil? || current_step + 1 == step | |
end | |
» @object.current_step | |
=> 0 | |
» @object.step?(0) | |
=> true | |
» @object.step?(1) | |
=> true |
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
# rbenv inspired by https://gist.github.com/1441139 | |
# make sure running as root user | |
apt-get -y update | |
apt-get install linux-headers-2.6.32-5-amd64 | |
apt-get -y upgrade | |
apt-get -y install curl git-core python-software-properties build-essential git-core curl libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev libcurl4-openssl-dev libxslt-dev libxml2-dev | |
# add-apt-repository | |
curl -o /usr/sbin/add-apt-repository http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txtchmod o+x /usr/sbin/add-apt-repository |
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
#PostController | |
def index | |
if params[:search] | |
@posts = Post.search(params[:search]).order("created_at DESC") | |
else | |
@posts = Post.all.order('created_at DESC') | |
end | |
end | |
#Post model |
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/ruby | |
# theme | |
# Pry.config.theme = "vim-detailed" | |
# Pry.config.theme = "tomorrow" | |
# Pry.config.theme = "solarized" | |
Pry.config.theme = "pry-siberia-16" | |
# Pry.config.theme = "zenburn" | |
# Pry.config.theme = "pry-classic-256" |
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
## based on the example at: | |
## http://gist.github.com/17371 | |
## | |
## put me in lib/un_haml.rb (in the haml-based project) | |
## | |
## call me on the command line thus: | |
## $ script/runner UnHaml app/views/layouts/application.html.haml | |
## $ script/runner UnHaml */*/*/*.haml | |
## | |
class UnHaml < Haml::Engine |
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
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class | |
# https://github.com/plataformatec/simple_form/issues/316 | |
inputs = %w[ | |
CollectionSelectInput | |
DateTimeInput | |
FileInput | |
GroupedCollectionSelectInput | |
NumericInput | |
PasswordInput |