Skip to content

Instantly share code, notes, and snippets.

@justinmoon
justinmoon / whoami.md
Last active September 10, 2018 18:15
Who am I

Objective

  • Find role where I can most help Bitcoin become reserve currency of world
  • Meet partners for next wave of ventures 10 years out, when Bitcoin has become boring and mainstream
  • Become financially independent (not there yet)
  • I'm currently trying to create a Bitcoin programming bootcamp to help experienced devs get Bitcoin jobs. My goal is to start first cohort on November 1. It would be free for students, and would monetize with recruiter fees from job placements.

Skills / Background

  • Interdisciplinary. I like to think about sales and I like to think about code.
  • First employee at Karmic Labs.
  • One of our products was an expense management system for corporations that issued debit cards to all employees and apps for spending authorization in place of reimbursements. I built the mobile app.
@justinmoon
justinmoon / demo.py
Created August 14, 2018 23:13
Python: How to subclass threading.Thread
import random
import threading
import time
class MyThread(threading.Thread):
def run(self):
seconds = random.random()
print(f"sleeping for {seconds} seconds")
time.sleep(seconds)
@justinmoon
justinmoon / demo.py
Created August 14, 2018 19:32
Check if thread is dead in Python
import threading
import time
def doom():
raise RuntimeError()
def zoom():
while True:
#!/usr/bin/python
# btpeer.py
from __future__ import print_function
import socket
import struct
import threading
import time
import traceback
@justinmoon
justinmoon / hang.log
Last active July 16, 2016 22:38
From a hanging unittest
=================================== FAILURES ===================================
_____________________________ test_multilline_num ______________________________
def test_multilline_num():
code = ('x = 1\n'
'ls -l\n') # this second line wil be transformed
> tree = check_parse(code)
tests/test_ast.py:31:
@justinmoon
justinmoon / Discussion.md
Last active June 25, 2016 21:01
See Discussion.md

Problem statement

  • When I attmept to exercise a certain API using the main.py script below, the server usually (but not always) sends a 400.
  • When I take a given url that generated a 400, and:
    • Paste it into Chrome, I get a 200!
    • Fire up python REPL and feed it to requests.get, I get a 200! I can do this repeatedly from "for loop" and always get 200's!
    • Open up Chrome debug tools and request if using fetch method, I get a 200!

Observations

@justinmoon
justinmoon / cleanse.py
Created June 22, 2016 07:06
Delete your unused git branches
import subprocess
from git import Repo
def delete_branch(branch):
branch_name = branch.name[7:] # chop off "origin/"
exit_code = subprocess.call(['git', 'push', 'origin', '--delete', branch_name])
if exit_code != 0:
print('problem deleting', branch_name)
@justinmoon
justinmoon / unimported.py
Created June 22, 2016 07:00
First-order hack at finding dead python code (unimported python files)
import os
import re
from pprint import pprint
def import_from_path(path):
try:
path, file_extension = path.split('.')
_, karmic_path = path.split(os.getcwd())
return re.sub('/', '.', karmic_path)
function doGet(e) {
// All Udacity spreadsheet are accessible by agent (the student) running this script
var fileId = e.parameters.fileId;
// Get the file, make copy with same name, and grab new URL
var existingFile = DriveApp.getFileById(fileId);
var fileName = existingFile.getName();
var copiedFile = existingFile.makeCopy(fileName);
var newUrl = copiedFile.getUrl();
@justinmoon
justinmoon / collapser.html
Created June 16, 2015 21:05
Jinja2 filter: collapse nested dictionary into HTML table
{% macro render_nested(json, key) -%}
<table>
{% if json.get(key) %}
{% for key, value in json.get(key).items() recursive %}
{% if value is mapping %}
{{ loop(value.items()) }}
{% else %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>