Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@shripadk
shripadk / gist:552554
Created August 27, 2010 00:59
Setting up Heroku Hostname SSL with GoDaddy SSL Cert
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
@mndoci
mndoci / iam_fog.rb
Created May 29, 2011 03:48 — forked from zapnap/iam_fog.rb
Using Amazon IAM with Fog (example)
# via http://blog.zerosum.org/2011/03/02/better-aws-access-control-with-iam-and-fog.html
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
@watson
watson / ability.rb
Created October 5, 2011 09:50
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@kagemusha
kagemusha / gist:1504633
Created December 21, 2011 04:47
Migrate from Mongo to Postgres in Rails 3.1
Tested on: Rails 3.1, Mongoid 2.0.1, pg 0.12.0 gem
Migrate from Mongo to PG
1. remove mongoid gem
2. add pg gem
3. in application.rb re-add ActiveRecord
4. for all models
- inherit from ActiveRecord::Base
- get rid of Mongoid:Document line
- make migrations and put fields there
@Akkuma
Akkuma / application.coffee
Created April 20, 2012 14:19
Tower.js Passport Example
passport = require 'passport'
googOID = require('passport-google').Strategy
steamOID = require('passport-steam').Strategy
passport.use new steamOID
returnURL: 'http://localhost:3000/auth/steam/return'
, realm: 'http://localhost:3000'
, () -> console.log arguments
passport.use new googOID
@acao
acao / users_controller.js
Created May 14, 2012 21:13
RailwayJS Sample Users controller file
var bcrypt = require('bcrypt');
load('application');
before(loadUser, {only: ['show', 'edit', 'update', 'destroy']});
before(loadGroups, {only: ['new', 'edit']});
action('new', function () {
this.title = 'New user';
this.user = new User;
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active April 2, 2024 14:57
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@dpsk
dpsk / deploy.rb
Created July 5, 2012 12:42 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
@axelpale
axelpale / combinations.js
Last active July 7, 2023 10:37
JavaScript functions to calculate combinations of elements in Array.
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* 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,