Skip to content

Instantly share code, notes, and snippets.

@robcarrington
robcarrington / simple_server.py
Created December 25, 2018 06:46
Simple Python 3 HTTP server that can store one key-value pair per request, as given in query string.
#!/usr/bin/python3
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse, parse_qs
import json
HOST_NAME = ""
HOST_PORT = 4000
WRITE_SUCCESS_TEMPLATE = "Key '{}' now storing value '{}'"
WRITE_FAILURE_TEMPLATE = "Unable to store key '{}' and value '{}'"
@robcarrington
robcarrington / depth_first_search.py
Created July 25, 2018 03:53
Depth First Search in Python
class Node():
def __init__(self, name):
self.name = name
self.children = None
def depth_first_search(start_node, name):
print("Evaluating node: {}".format(start_node.name))
if start_node.name == name:
return start_node
elif start_node.children:
@robcarrington
robcarrington / TerminalVim.scpt
Last active October 23, 2017 20:58 — forked from charlietran/TerminalVim.scpt
Open file in iTerm vim for MacOS Sierra
-- TerminalVim.app
-- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm
-- To use this script:
-- 1. Open Automator and create a new Application
-- 2. Add the "Run Applescript" action
-- 3. Paste this script into the Run Applescript section
-- 4. Save the application as TerminalVim.app in your Applications folder
-- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default