Skip to content

Instantly share code, notes, and snippets.

"""Benchmarking answers to <http://stackoverflow.com/q/29481088/1014938>."""
import re
from collections import defaultdict
from functools import partial
from statistics import mean, median
from string import digits
from timeit import timeit
@Ffisegydd
Ffisegydd / .gitignore
Last active August 29, 2015 14:14
.gitignore
### Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
// ==UserScript==
// @name Share Markdown (Stack Overflow)
// @namespace about:blank
// @include http://stackoverflow.com/questions/*
// @include https://stackoverflow.com/questions/*
// @include http://meta.stackoverflow.com/questions/*
// @include https://meta.stackoverflow.com/questions/*
// @include http://*.stackexchange.com/questions/*
// @include https://*.stackexchange.com/questions/*
// @version 1
class Connection(object):
def __init__(self, *args, **kwargs):
# Do whatever
def query(self, query):
# Accept a dictionary and then use the key-value pairs
# to query the database.
def connect(self):
# Connect to your database
# These are ordered dicts because otherwise the dates end up out of order.
report = {'server_count_per_day': OrderedDict(),
'automation_count_per_day': OrderedDict(),
'total_server_cost': 0,
'total_automation_cost': 0,
'total': 0}
from itertools import permutations
import re
letters = 'abc'
perm = set(p for n in range(1, len(letters)+1) for p in permutations(letters, n))
s = r"@({})\b".format('|'.join(''.join(p) for p in perm))
@Ffisegydd
Ffisegydd / keybase.md
Last active August 29, 2015 14:06
keybase.md

Keybase proof

I hereby claim:

  • I am Ffisegydd on github.
  • I am ffisegydd (https://keybase.io/ffisegydd) on keybase.
  • I have a public key whose fingerprint is 9AC1 1D4F A243 E20B FCE4 765E 1992 4441 0DCE F242

To claim this, I am signing this object:

// ==UserScript==
// @name spoiler button adder (SO Chat)
// @namespace about:blank
// @include http://chat.stackoverflow.com/rooms/*
// @version 1.1
// @grant none
// ==/UserScript==
//adds a spoiler to the input textarea.
//inserts it wherever your cursor is.
import requests
import bs4
from datetime import date, timedelta
transcript_url = 'http://chat.stackoverflow.com/transcript/6/{year}/{month}/{day}/0-24'
today = date.today()
day = timedelta(days=1)
# d = date(year=2010, month=10, day=15)
d = date(year=2014, month=9, day=11)
@Ffisegydd
Ffisegydd / gist:982a834dbb4879cf9e88
Created August 12, 2014 18:44
Get the Revision History (originally written by Kevin Kevinson)
// ==UserScript==
// @name revision viewer
// @namespace about:blank
// @description Adds a "revisions" button to SO's post menu
// @include http://stackoverflow.com/questions/*
// @version 1
// @grant none
// ==/UserScript==
var url = document.URL;