Skip to content

Instantly share code, notes, and snippets.

View jacobsimeon's full-sized avatar

Jacob Morris jacobsimeon

  • Mozilla/Pocket
  • Vancouver, WA
View GitHub Profile
@jacobsimeon
jacobsimeon / first
Created November 17, 2016 22:19
Pass variable
#/bin/bash
VAR=5
./other $VAR
@jacobsimeon
jacobsimeon / user-service.js
Last active September 17, 2015 02:35
Using a 'model' in angular
// this is the constructor function of the javascript object (i.e. the `initialize` method)
var User = function(data, http) {
// copy data (presumably a simple JSON object received by a call to some API)
angular.copy(data, this);
this.http = http;
}
// add methods to the User "class"
User.prototype.fullName = function() {
return this.firstName + ' ' + this.lastName;
@jacobsimeon
jacobsimeon / numeric_whole_ext.rb
Created January 20, 2014 21:04
Check if a number is an integer with Numeric#whole?.
class Numeric
# works for Float, Integer and BigDecimal
def whole?
self % 0 == 1
end
end
@jacobsimeon
jacobsimeon / migration.vim
Created November 1, 2013 22:12
Open most recent migration in vim.
function! OpenMostRecenMigration()
exec 'vsp' system('echo db/migrate/`ls db/migrate | tail -n 1 | cut -f 1`')
endfunction
nnoremap <Leader>m :call OpenMostRecenMigration()<CR>
@jacobsimeon
jacobsimeon / rails.vim
Created November 1, 2013 21:50
Rails db:something related vim commands
command Migrate !zeus rake db:migrate db:rollback && zeus rake db:migrate db:test:prepare
command Rollback !zeus rake db:rollback
command Reset !zeus rake db:reset
# FancyCheckbox: A customizable checkbox tool.
#
# Hides a given checkbox and replaces it with a div, binding the appropriate
# event handlers to manipulate the real, underlying checkbox.
# Also copies any existing label into the replacement markup.
#
# DOM tree looks like this:
# <input name="john-doe" type="checkbox" style="display: none;">
# <div class="fancy-checkbox-container">
# <div class="fancy-checkbox-label-wrapper">
@jacobsimeon
jacobsimeon / zeus.json
Created September 24, 2013 17:24
Zeus config
{
"command": "ruby -rubygems -r./custom_plan -eZeus.go",
"plan": {
"boot": {
"default_bundle": {
"development_environment": {
"prerake": {"rake": []},
"console": ["c"],
"generate": ["g"],
" 80 characters color column
if exists('+colorcolumn')
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
" highlight trailing whitespace
highlight WhitespaceEOL ctermbg=Red guibg=Red
match WhitespaceEOL /\s\+$/
" remove whitespace before save
autocmd BufWritePre {*.rb,*.js,*.coffee,*.scss,*.haml} :%s/\s\+$//e
@jacobsimeon
jacobsimeon / custom_plan.rb
Created September 11, 2013 17:29
Add this to root of the projects and name it `custom_plan.rb`
require 'zeus/rails'
require 'dotenv'
class CustomPlan < Zeus::Rails
def boot
Dotenv.load
super
end
end