Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Nick Brady nick-brady

🏠
Working from home
Block or report user

Report or block nick-brady

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nick-brady
nick-brady / battleship.py
Created Apr 1, 2018
A terminal battleship implementation to practice object oriented concepts
View battleship.py
from random import randint
from time import sleep
# ALG_DEBUG = True
ALG_DEBUG = False
def blue(string):
return '\x1b[0;34;40m' + string + '\x1b[0m'
def green(string):
@nick-brady
nick-brady / console.py
Last active Mar 20, 2018
dumb script for writing the boilerplate javascript to log out the arguments in a function
View console.py
# python console.py arg1, arg2, arg3, arg4
import sys
def cleanString(string):
if string[-1] == ',':
return string[:-1]
else:
return string
View query-string-parser.js
/**
* modified code of gist - https://gist.github.com/Manc/9409355
* - 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
nick-brady / python-dijkstras.py
Last active Jul 17, 2017
simple Python implementation of Dijkstra's Algorithm
View python-dijkstras.py
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.