Skip to content

Instantly share code, notes, and snippets.

if (window.location.hostname.indexOf('www.reddit.com') != -1) {
window.location.hostname = 'old.reddit.com';
}
#!/bin/bash
lsof -Pi :1-65535 | awk '{print $8, $3, $1, $9}'
package main
import (
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"github.com/disintegration/imaging"
@aeter
aeter / gist:3392763
Created August 19, 2012 06:37
db random data
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):
@aeter
aeter / gist:1302563
Created October 20, 2011 22:21
Translate webpages to bg
javascript:location='http://translate.google.com/translate?sl=auto&tl=bg&u='+encodeURIComponent(location);
@aeter
aeter / subs.py
Created May 22, 2011 21:23
srt files timing
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)
# 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]:
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()
#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)
# 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],