Skip to content

Instantly share code, notes, and snippets.

@trevorrjohn
trevorrjohn / encryption_instructions.md
Last active August 29, 2015 14:19
OSX Encrypt Folder Instructions

Encrypt a File OSX

Instructions on to encrypt a file on OSX 10.9. Based of this StackOverflow post.

Requirements

  • Homebrew
  • osxfuse brew install Caskroom/cask/osxfuse
  • encfs brew install encfs
@trevorrjohn
trevorrjohn / android-intellij.groovy
Last active August 29, 2015 14:11
gradle task to fix dependency order in Android Studio
apply plugin: 'idea'
idea {
module {
testOutputDir = file('build/test-classes')
}
}
task initGradleTest << {
def imlFile = '<path to iml>.iml'
@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__}"
@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 / 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 / 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
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
struct Position {
char value;
// some other attributes
};
class Board {
public:
Board();
Board(string filename); //another constructor given a filename
~Board();
@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;
}
@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) {