Skip to content

Instantly share code, notes, and snippets.

@trevorrjohn
trevorrjohn / gist:3366765
Created August 16, 2012 04:14
Jasmine failure
Expected { 0 : HTMLNode, length : 1, context : HTMLNode, selector : '#input1', constructor : Function, init : Function, jquery : '1.7.2', size : Function, toArray : Function, get : Function, pushStack : Function, each : Function, ready : Function, eq : Function, first : Function, last : Function, slice : Function, map : Function, end : Function, push : Function, sort : Function, splice : Function, extend : Function, data : Function, removeData : Function, queue : Function, dequeue : Function, delay : Function, clearQueue : Function, promise : Function, attr : Function, removeAttr : Function, prop : Function, removeProp : Function, addClass : Function, removeClass : Function, toggleClass : Function, hasClass : Function, val : Function, on : Function, one : Function, off : Function, bind : Function, unbind : Function, live : Function, die : Function, delegate : Function, undelegate : Function, trigger : Function, triggerHandler : Function, toggle : Function, hover : Function, blur : Function, focus : Function,
@trevorrjohn
trevorrjohn / gist:3749088
Created September 19, 2012 11:09
Pass by reference
int main() {
int foo = 5;
bar(foo);
if(foo == 5) {
cout << "foo not changed" << endl;
}
passByReference(foo);
if(foo == 6) {
@trevorrjohn
trevorrjohn / gist:4091199
Created November 16, 2012 21:47
Assoc implementation
string &Assoc::operator(const string key) {
int index = hash(key);
// Case where key is not in hash
if(heads[index] == NULL) {
heads[index] = new Elem(key);
return heads[index]->value;
}
Elem *iter = heads[index];
// Case where key is already stored in hash
while(iter != NULL) {
@trevorrjohn
trevorrjohn / gist:4108934
Created November 19, 2012 04:21
argv example
// if we had the program
int main(int argc, char* argv[]) {
cout << "output is: ";
for(int i = 0; i < argc; i++)
cout << argv[i] << ", ";
cout << endl;
return 0;
}
struct Position {
char value;
// some other attributes
};
class Board {
public:
Board();
Board(string filename); //another constructor given a filename
~Board();
1) backup production database:
heroku pgbackups:capture --expire --remote production
2) obtain url string to backup from step 1:
heroku pgbackups:url --app production_app_name --remote production_app_branch_name
3) transfer backup from production to staging app:
heroku pgbackups:restore DATABASE 'production_app_backup_url_string_from_step_2' --app production_app_name --app staging_app_name --confirm staging_app_name
@trevorrjohn
trevorrjohn / vim regex
Created February 12, 2013 03:38
Vim regex to change old style rails hashes to new style (ie. :key => "value" to key: "value")
:%s/:\(\w*\) =>/\1:/g
@trevorrjohn
trevorrjohn / gist:5984669
Created July 12, 2013 13:59
Run spec in tmux
map rr :exec ":silent !tmux send-keys -t 1 'zspec %". ":" . line('.') . "' C-m"<CR>:redraw!<cr>
map tt :exec ":silent !tmux send-keys -t 1 'zcuke %". ":" . line('.') . "' C-m"<CR>:redraw!<cr>
@trevorrjohn
trevorrjohn / product_flavors.gradle
Created April 30, 2014 19:27
Build on whitelisted flavors
{
// Preferences => Compiler => Gradle => VM Options. Add -DflavorWhitelist=flavor1,flavor2
// Omit -DflavorWhitelist for all flavors.
def flavorMap = [
flavor1: {
// flavor stuff
},
flavor2 : {
// flavor 2 stuff
}
@trevorrjohn
trevorrjohn / reorder_ide_dependencies.sh
Created December 11, 2014 04:24
Fix order of dependencies for Intellij or Android Studio
#!/bin/sh
set -o pipefail
set -o errexit
set -o nounset
#set -o xtrace
__DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
__BASE__="$(basename "${0}")"
__FILE__="${__DIR__}/${__BASE__}"