Skip to content

Instantly share code, notes, and snippets.

View lukelex's full-sized avatar

Lukas Alexandre lukelex

View GitHub Profile
@lukelex
lukelex / Rakefile
Created October 26, 2013 17:57
Run ActiveRecord migrations outside of Rails
require 'bundler/setup'
require 'active_record'
require 'logger'
namespace :db do
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
end
describe 'Contexts.ContextManager', ->
reloadContextManager = ->
@contextManager = new Contexts.ContextManager
sampleContext = {id: 'uniqueId'}
differentContext = {id: 'differentId'}
describe '#push', ->
beforeEach reloadContextManager
@lukelex
lukelex / gist:6155821
Created August 5, 2013 13:12
Sublime Text 3 - user settings
{
"auto_indent": true,
"auto_reload_changed": true,
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 14.0,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
@lukelex
lukelex / gist:5437685
Created April 22, 2013 19:15
Sublime config
{
"auto_indent": true,
"auto_reload_changed": true,
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"font_size": 14.0,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
@lukelex
lukelex / JsonBasedClass
Created April 18, 2013 00:01
Instantiate a coffeescript object based on a JSON
class JsonBasedClass
constructor: (json) ->
for k,v of json
if k.indexOf '$'
key = @toCamel k
@[key] = v
@["$#{k}"] = v
toCamel: (field) ->
field.replace /(\_[a-z])/g, ($1) ->
@lukelex
lukelex / git.plugin.zsh
Created January 26, 2013 17:14
Git aliases
# Aliases
# simple stuff
alias g='git'
compdef g=git
alias gs='git status'
compdef _git gst=git-status
alias gpl='git pull'
compdef _git gl=git-pull
alias gplr='git pull --rebase'
compdef _git gup=git-fetch
@lukelex
lukelex / require_dir
Created January 10, 2013 03:49
Require all ruby files from a directory
Dir["./path/to/directory/*.rb"].each {|file| require file }
@lukelex
lukelex / toggle_attribute.js
Created December 24, 2012 18:59
Toggle an attribute
$('input:checkbox').attr('checked', function(idx, oldAttr) {
return !oldAttr;
});
@lukelex
lukelex / gist:4369478
Created December 24, 2012 14:44
Build latest Ruby version from source
wget --no-check-certificate https://raw.github.com/joshfng/railsready/master/railsready.sh && bash railsready.sh
@lukelex
lukelex / install.md
Created December 24, 2012 14:17
Installing latest version of MongoDB on ubuntu

=Install MongoDB

==Add 10gen package to source.list

The 10gen package contains the latest mongoDB version, append below line to the end of the file “/etc/apt/sources.list”

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

For example, vim the “source.list” and append the 10gen package like this :