This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
=# CREATE DATABASE newdb; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python console.py arg1, arg2, arg3, arg4 | |
import sys | |
def cleanString(string): | |
if string[-1] == ',': | |
return string[:-1] | |
else: | |
return string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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('?'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |