Skip to content

Instantly share code, notes, and snippets.

View dubilla's full-sized avatar

Dan Ubilla dubilla

View GitHub Profile
@dubilla
dubilla / gist:c111f2fd832236e33d45
Created January 2, 2016 18:29 — forked from datwright/gist:1082717
Rails Migrations Cheat sheet
# Migration generator shortcuts.
# rails generate migration MyNewMigration
# rails generate migration add_fieldname_to_tablename fieldname:string
# rails generate model Product name:string description:text
# The set of available column types [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean]
# A migration is a subclass of ActiveRecord::Migration. You must implement the "up" and "down" (revert) methods.
# These are the handy methods available to a Migration:
@dubilla
dubilla / vim-on-heroku.sh
Created October 8, 2015 19:09 — forked from sfate/vim-on-heroku.sh
vim on heroku
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@dubilla
dubilla / gist:4c98e30ea6619533a338
Created March 31, 2015 20:47
Git Branches Command
alias branches="git for-each-ref --sort=-committerdate refs/heads/ --format='%1B[0;32m%(authorname)%09%1B[0;36m(%(committerdate:relative))%09%1B[0;33m%(refname:short)%09%1B[m% (subject)' --count 10 | tail -r | column -t -s $'\t'"
# Player 1 plays 0s
# Player 2 plays 1s
if item.even?
box[move] = 'X'
elsif item.odd?
box[move] = '0'
end
# Did player 1 win?
if item.odd? and item > 3 and player_winner?(box, '0')
@dubilla
dubilla / gist:252e4c8d03b9db87a909
Created August 25, 2014 15:38
.git/hooks/pre-push
#!/usr/bin/env ruby
# Read this blog to know more about this script.
#
# http://blog.bigbinary.com/2013/09/19/do-not-allow-force-pusht-to-master.html
class PrePushHandler
def handle
reject if pushing_to_master? && forced_push?
describe 'Deal Term Display', ->
HTML = '<div deal-terms></div>'
scope = elem = DealTerm = null
beforeEach ->
inject ($compile, $rootScope, _DealTerm_) ->
DealTerm = _DealTerm_
scope = $rootScope.$new()
scope.log = deal_terms: []
scope.showthis = true
= f.input :space_condition, collection: ['raw', 'pre-existing', 'pre-built', 'white box', 'core and shell'], label_method: :capitalize, label: "Space condition", :input_html => {:id => "space_condition_{{$index}}", :'ng-model' => 'space.space_condition', :'ng-init' => 'space.space_condition=""'}
@dubilla
dubilla / gist:11191245
Created April 22, 2014 19:24
Ellipsis on Text Overflow
I narrowed it down:
1. The element on the right must be in the DOM before the element on the left, and have float: right
2. The element on the left must have display: block, float: none, white-space: nowrap, overflow: hidden, text-overflow: ellipsis
@dubilla
dubilla / property-spaces-ctrl.js.coffee
Created March 7, 2014 23:42
jQuery to Angular tie-up
$document.on 'nested:fieldAdded and:again', (event) ->
$scope.$apply ->
$compile(event.field)($scope)
true
true
@dubilla
dubilla / _space_fields.html.haml
Created March 7, 2014 22:52
nested_form unique id
- object_id = f.object_name.gsub(/[^0-9]+/,'') || f.options[:child_index]