Skip to content

Instantly share code, notes, and snippets.

@purplejacket
purplejacket / stormpath_query.js
Created January 5, 2016 05:09
Wrapping multiple calls to directory.getAccounts into a Promise
var getAccounts = function(directoryHref, usernames, callback) {
client.getDirectory(directoryHref, function(err, directory) {
var accountPromises = _.map(usernames, function(username) {
return new Promise(function(resolve, reject) {
var foundAccount;
directory.getAccounts({username: username, expand: 'customData'},
function(err, accounts) {
accounts.each(
function(account, cb) {
account.id = account.username;
@purplejacket
purplejacket / .bash_profile
Created May 5, 2016 02:51
.bash_profile -- Mac OSX
alias l='ls -latr'
alias l.='ls -ld .*'
alias ll='ls -lhvrt'
alias t='tree -d -L 1'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
@purplejacket
purplejacket / quit_vim.md
Last active May 12, 2016 01:35
quit vim -- how do you quit vim?

QUESTIONS:

How do you quit vim?
I pressed q in vim's command mode, but it doesn't quit.
Why doesn't q quit vim?
WTF – I press q and vim goes crazy?
Why is 'q' for macro-record and not 'quit'?
Would it be safer to just take off and kill $(ps -e | grep vim | awk '{print $1}') the site from orbit – just to be sure?

ANSWERS:

{
"_id": {
"$oid": "52b213b38594d8a2be17c780"
},
"approvalfy": 1999,
"board_approval_month": "November",
"boardapprovaldate": "2013-11-12T00:00:00Z",
"borrower": "FEDERAL DEMOCRATIC REPUBLIC OF ETHIOPIA",
"closingdate": "2018-07-07T00:00:00Z",
"country_namecode": "Federal Democratic Republic of Ethiopia!$!ET",
@purplejacket
purplejacket / node_https_with_pfx.js
Created August 4, 2016 23:44
A small node program to test https using a pfx file. Note: uses port 8443 so as not to disrupt the production instance.
var url = require('url');
var path = require('path');
var express = require('express');
var http = require('http');
var https = require('https');
var fs = require('fs');
var moment = require('moment');
require('log-timestamp'); // this will cause console.log to prepend timestamps
@purplejacket
purplejacket / node_indexer.js
Created August 12, 2016 17:01
A node script to gather JSON files from various mounted volumes and subdirectories, then populate an elasticsearch cluster. Uses a js generator.
// replace 'includes(.json)' with RE
var http = require('http');
var fs = require('fs');
var es_hostnames = {
oilyonion: 'search-oilyonion-27bdlhisfhglh34my6e3c6lpuq.us-west-2.es.amazonaws.com',
bouncypepper: 'search-bouncypepper-m4utjzuqkoj5ahb32jfqokwvz4.us-west-2.es.amazonaws.com'
}
var ten_mb = 10*1024*1024;
class Dictionary
def initialize
@trie = {}
end
def add(word)
return false if !word.kind_of?(String) || word == ''
array = word.split('').collect {|char| char.to_sym}
_add(array, @trie)
require 'dictionary'
describe Dictionary do
before do
@d = Dictionary.new
end
it "should be empty when created" do
@d.words.should == []
end
****************************************************************************
*
* Program: al_adhoc.prg
*
* Authors: Kai Middleton
*
* Written: 8-87
*
*
* Function: generate a report on up to eleven fields
@purplejacket
purplejacket / for_the_love_of_money.txt
Last active December 10, 2016 06:12
For the Love of Money - Queen Latifah - New Jack City
♪ Another brother wants to win the hustler-of-the-year award ♪
♪ HOW MANY BENZES AND BMs can one man afford? ♪
♪ it ain't just him -- it's also you and you and that guy ♪
♪ who won't be satisfied ♪
♪ 'til all of us is gettin' high ♪
♪ one hit for her, she's pullin' down your drawers ♪
♪ one hit for him, his welfare check is yours ♪
♪ it ain't nothing but a small thing in a big city, see ♪
♪ you're living for the money, B ♪
♪ don't let money change you ♪