Skip to content

Instantly share code, notes, and snippets.

View taktran's full-sized avatar

Tak Tran taktran

View GitHub Profile
@taktran
taktran / rails_cheatsheet.md
Created November 2, 2011 18:02
Rails cheatsheet

An incomplete cheatsheet for rails 3. Things are added as they are required.

## Debugging

Check errors

@user = User.new(:email => email)
puts @user.valid?
@user.errors.each { |e| puts "#{e}: #{@user.errors[e]}" }
@taktran
taktran / git-cheatsheet.md
Created November 13, 2011 11:17
Git cheatsheet

Git cheatsheet

An incomplete just-in-time cheatsheet for git. Things are added as required.

Add remote repository

To add an existing repo to a remote repo

  1. For github/bitbucket, create repo there first, and get git address, eg
@taktran
taktran / gist:1388735
Created November 23, 2011 14:04
Ruby for converting a string to a css class
def get_css_class(str)
"class-#{str.downcase.gsub(/\W/, "-")}" if str.present?
end
@taktran
taktran / css_template.scss
Created November 23, 2011 16:52
CSS template
@import 'reset';
@import 'typography';
/* Variables
-----------------------------------------------------------------------------*/
/* Colours */
/* General styles
@taktran
taktran / sinatra_cheatsheet.md
Created December 7, 2011 15:45
Sinatra cheatsheet

Useful commands

last_response
    .body

last_request
    .path
    .url
    .session

.cookies

@taktran
taktran / mongomapper_cheatsheet.md
Created January 25, 2012 19:39
Mongomapper cheatsheet

Mongomapper cheatsheet

Mongomapper reference

Set up connection

require 'mongo_mapper'

def setup_mongo_connection(mongo_url)
@taktran
taktran / javascript-cheatsheet.md
Created February 9, 2012 02:02
Javascript cheatsheet

Ajax

Debugging

To print out objects

JSON.stringify(obj)

@taktran
taktran / gist:2358527
Created April 11, 2012 10:32
Rack protection bug

Server dumps of env.to_yaml to replicate the rack-protection bug. Only seems to be an issue with IE9, without set :protection, except: :session_hijacking set.

I have the following setup:

rack (1.4.1)
rack-force_domain (0.2.0)
rack-protection (1.2.0)

sinatra (1.3.2)

rack (~> 1.3, >= 1.3.6)

@taktran
taktran / shipit.rake
Created September 11, 2012 11:09
Ship it! rake task. Some details about the rationale here: http://blog.pebblecode.com/post/32263926012/ship-it
# Ship it! rake task
#
# Merge branch (master by default) to deployment branch, and deploy to server.
#
# Prerequisite:
#
# * Declare all deployment branches in `ALL_DEPLOYMENT_BRANCHES`
# * Declare deploy only branches in `DEPLOY_ONLY_BRANCHES` (ie, does not merge master)
# * Modify `Deploy.command` function as necessary
#
@taktran
taktran / Preferences.sublime
Created September 12, 2012 13:07
Tak's sublime user preferences
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
".sass-cache",
"tmp"