Skip to content

Instantly share code, notes, and snippets.

Working from home

Nick Brady nick-brady

Working from home
View GitHub Profile
nick-brady /
Last active Jul 28, 2020
Blow away all Django migrations in Postgres and start over - the easy way
# This file is not meant to be executed. Merely a reference for doing this step by step.
# dump the postgres database (DATA ONLY)
pg_dump --data-only dbname > dump.sql
# Create a new database that will replace your old one
psql -U pguser --password
nick-brady /
Created Apr 1, 2018
A terminal battleship implementation to practice object oriented concepts
from random import randint
from time import sleep
# ALG_DEBUG = True
def blue(string):
return '\x1b[0;34;40m' + string + '\x1b[0m'
def green(string):
nick-brady /
Last active Mar 20, 2018
dumb script for writing the boilerplate javascript to log out the arguments in a function
# python arg1, arg2, arg3, arg4
import sys
def cleanString(string):
if string[-1] == ',':
return string[:-1]
return string
View query-string-parser.js
* modified code of gist -
* - newer syntax
* - decodeURIComponent instead of generic decoding function (unescape)
* keys with name name defined after will take priority
export function parseQueryString(location) {
const query = decodeURIComponent(location).trim();
const obj = {};
const qPos = query.indexOf('?');
nick-brady /
Last active Jul 17, 2017
simple Python implementation of Dijkstra's Algorithm
from collections import defaultdict
import math
class DirectedGraph(dict):
"""Create a directed Graph. Root keys contain a dictionary of other nodes they are directed to with
corresponding weight"""
def __missing__(self, key):
value = self[key] = {key: 0} # A keys distance to itself is always 0
return value
You can’t perform that action at this time.