This file contains 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
if (window.location.hostname.indexOf('www.reddit.com') != -1) { | |
window.location.hostname = 'old.reddit.com'; | |
} |
This file contains 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
#!/bin/bash | |
lsof -Pi :1-65535 | awk '{print $8, $3, $1, $9}' |
This file contains 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
package main | |
import ( | |
"os" | |
"path/filepath" | |
"runtime" | |
"strings" | |
"sync" | |
"github.com/disintegration/imaging" |
This file contains 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
import random | |
import string | |
ALPHABET = string.ascii_lowercase | |
DIGITS = string.digits | |
def make_random_string(_len, seq): | |
return ''.join([random.choice(seq) for _ in range(_len)]) | |
def make_first_name(_len): |
This file contains 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
javascript:location='http://translate.google.com/translate?sl=auto&tl=bg&u='+encodeURIComponent(location); |
This file contains 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
import datetime | |
import fileinput | |
import argparse | |
class SubTime(object): | |
def __init__(self, time_as_str): | |
h, m, s, milliseconds = self.parse_time(time_as_str) | |
microseconds = milliseconds * 1000 | |
self.time = datetime.time(h, m, s, microseconds) |
This file contains 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
# prints a depth-first-search from the starting node | |
def dfs(node): | |
visited = set() | |
visited.add(node) | |
stack = [] | |
stack.append(node) | |
while len(stack) > 0: | |
current = stack.pop() | |
print current, | |
for nodes in graph[current]: |
This file contains 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
import Queue | |
# prints a breadth-first-search from the starting node | |
def bfs(node): | |
visited = set() | |
visited.add(node) | |
q = Queue.Queue() | |
q.put(node) | |
while not q.empty(): | |
current = q.get() |
This file contains 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
#draw a graph: | |
import pygraphviz as pgv | |
def graph_as_png(graph=graph): | |
G = pgv.AGraph() | |
for nodes in graph: | |
G.add_node(nodes) | |
for nodes in graph: | |
for ch_nodes in graph[nodes]: | |
G.add_edge(nodes, ch_nodes) |
This file contains 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
# a testing graph | |
graph={ | |
1:[2], | |
2:[1,3,4,5], | |
3:[2,6], | |
4:[2,12], | |
5:[2,7], | |
6:[3,7,11,12], | |
7:[5,6,10], | |
10:[7,11,12], |
NewerOlder