Skip to content

Instantly share code, notes, and snippets.

@deanohyeah
deanohyeah / js script loader
Created September 4, 2013 18:18
Load a script with a call back when it is done loading. For scripts that depend on each other
function loadScript(url, callback){
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
@deanohyeah
deanohyeah / Fixed div, hug footer
Created September 4, 2013 18:20
Fixes a div and unfixes when the footer comes in.
@deanohyeah
deanohyeah / python geocode function
Created September 24, 2013 17:01
python function to use googles geocoding. import requests
def _geocode(self, address, *args, **kwargs):
url = 'http://maps.googleapis.com/maps/api/geocode/json'
payload = {
'address': address+' '+self.state,
'sensor': 'false',
}
r = requests.get(url, params=payload)
if r.status_code == 200:
data = r.json
@deanohyeah
deanohyeah / .vimrc
Last active October 17, 2015 05:52
.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
" Ctrlp options
let g:ctrlp_root_markers = ['.ctrlp']
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
\ }
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*.,*/.DS_Store,*/tmp/*
@deanohyeah
deanohyeah / macVim setup
Last active August 29, 2015 13:57
Set up vim with mac vim
Download latest version of mac vim
https://github.com/b4winckler/macvim/releases
Install pathogen.vim(manages plugins)
http://www.vim.org/scripts/script.php?script_id=2332
Install a theme possibly:
https://github.com/altercation/vim-colors-solarized
Install CtrlP
@deanohyeah
deanohyeah / gist:df972fea8daa13e6b14f
Created January 22, 2016 21:23
Nodejs script to start jenkins build and poll for status
#!/usr/bin/env node
var request = require('request'),
fs = require('fs'),
Promise = require('bluebird'),
baseUrl = '',
patchName = process.argv[2].toString(),
formData = {
file0: fs.createReadStream(`/Users/skytap/src/current/ui_nodejs/.hg/patches/${patchName}`),
json: '{"parameter":[{"name":"ui_nodejs/.hg/patches/test_patch","file":"file0"}]}'
};
@deanohyeah
deanohyeah / batch_delete.coffee
Created June 28, 2016 21:23
use promises to batch delete things. Resolve when all complete
save: ->
# avoid making a request before one comes back
return if @prop('busy')
@prop('busy', true)
# we want to delete first so that when we call save we get updated response without the deleted models
@delete().then =>
@save()
.then (models) =>
# # add the response of models to the collection
@reset(models) if models.length
find . -type f -print0 | xargs -0 -n 1 sed -i -e 's/module.exports.*/module.exports = ->/g
@deanohyeah
deanohyeah / cucumber_find_steps.vim
Last active June 10, 2017 05:31
Cucumber js step finder
let b:cucumber_root = '~/src/current/ui/test/features/step_definitions'
if !exists("b:cucumber_steps_glob")
let b:cucumber_steps_glob = b:cucumber_root.'/**/*'
endif
function! s:getallsteps()
let step_pattern = '\/\^.*$\/'
let steps = []
for file in split(glob(b:cucumber_steps_glob),"\n")
let lines = readfile(file)
@deanohyeah
deanohyeah / optional_flag_parsing.sh
Created July 12, 2017 16:35
Shell: example of optional flag parsing
# this function will search all passed arguments for optionalFlag's existence
function test() {
if [[ $* == *--optionalFlagt* ]]
then
do stuff
else
do other stuff
fi
}