Skip to content

Instantly share code, notes, and snippets.

@adrianmoses
adrianmoses / 1p_get_item_jq.sh
Created April 9, 2018 18:11
Get item 1p with jq
jq '. | {title: .overview.title, url: .overview.url, username: .details.fields[1].value, password: .details.fields[0].value}'
package main
import (
"fmt"
"reflect"
"encoding/json"
)
type Task struct {
Name string
@adrianmoses
adrianmoses / 0_reuse_code.js
Created April 6, 2017 22:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adrianmoses
adrianmoses / monty_hall.py
Created August 18, 2016 04:33
Monty Hall Problem
import random
def expose_goat(doors, sel_index):
for i in doors:
if i != sel_index:
choice = doors[sel_index]
if choice == 'goat':
print "Door %s is a goat" % i
return i
factorial = lambda n: reduce(lambda x, y: x * y, range(1, n+1))
(6 * 7 * 24 * 60 * 60) == factorial(10)
window.location.getParams = function() {
var params = {};
var paramList = window.location.search.slice(1).split('&');
paramList.forEach(function(param, index, list){
params[param.split('=')[0]] = param.split('=')[1];
});
return params;
};

Keybase proof

I hereby claim:

  • I am ammoses89 on github.
  • I am adrianmoses (https://keybase.io/adrianmoses) on keybase.
  • I have a public key whose fingerprint is AA8D 0DE4 00FB D7B4 343A FADA EA4D 3AAC 6B40 A597

To claim this, I am signing this object:

@adrianmoses
adrianmoses / fx_plan.py
Created April 22, 2015 01:01
Forex Monthly Trajectory
from calendar import monthrange
MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
INITIAL_DEPOSIT = 10000
YEARS = 3
STARTING_YEAR = 2016
YEAR_RANGE = list(range(STARTING_YEAR, (STARTING_YEAR + YEARS+1)))
@adrianmoses
adrianmoses / hn.py
Created April 12, 2015 03:52
Uses HN Firebase API to make very simple command line interface
import time
import webbrowser
import requests
STORY_COUNT = 10
def get_stories(story_ids):
stories = []
for story_id in story_ids:
@adrianmoses
adrianmoses / api_key_gen.py
Created January 29, 2015 01:28
simple method for generating api keys
import hashlib
import base64
import random
# src - http://jetfar.com/simple-api-key-generation-in-python/
def api_key_gen():
return base64.b64encode(hashlib.sha256( str(random.getrandbits(256)) ).digest(),
random.choice(['rA','aZ','gQ','hH','hG','aR','DD'])).rstrip('==')