From | To | Expression |
---|
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
from __future__ import print_function, division | |
from math import ceil | |
from operator import xor, getitem | |
from functools import reduce | |
from struct import unpack, pack | |
two64 = 0x10000000000000000 | |
def hexToBytes(hexes): | |
hexes = hexes.replace(' ', '') | |
return bytes(int(hexes[i:i+2], 16) for i in range(0, len(hexes), 2)) |
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
#!/usr/bin/env python3 | |
import random | |
from collections import Counter, OrderedDict | |
class OrderedCounter(Counter, OrderedDict): | |
pass | |
class FakeEtcd: |
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
8 Spruce Street, Lake Placid, NY 12946 | |
$247,500 purchase price | |
20% down | |
$198,000 mortgage | |
30 year fixed | |
Primary Residence | |
First home purchase | |
Single family home | |
Do not need to escrow taxes and insurance, | |
but will if it is lowers interest rate. |
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
class TransposedMatrix(object): | |
def __init__(self, matrix, index = None): | |
self.matrix = matrix | |
self.index = index | |
def __getitem__(self, index): | |
if self.index is None: | |
return TransposedMatrix(self.matrix, index) | |
return self.matrix[index][self.index] |
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
from collections import OrderedDict | |
from pprint import pprint | |
def greedy_reduction(weights, capacities): | |
weights = [{'weight': weight, 'used': False} for weight in sorted(weights, reverse = True)] | |
knapsacks = [{'capacity': capacity, 'load': 0, 'weights': []} for capacity in sorted(capacities, reverse = True)] | |
for knapsack in knapsacks: | |
for weight in weights: | |
if weight['used']: |
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
# First install tmux | |
brew install tmux | |
# For mouse support (for switching panes and windows) | |
# Only needed if you are using Terminal.app (iTerm has mouse support) | |
Install http://www.culater.net/software/SIMBL/SIMBL.php | |
Then install https://bitheap.org/mouseterm/ | |
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/ |
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
#!/usr/bin/env python3 | |
#from tkFileDialog import askopenfilenames | |
from tkinter.filedialog import askopenfilename | |
import os, os.path | |
from itertools import chain, repeat | |
from operator import itemgetter, sub, pow, truediv | |
from array import array | |
from math import sqrt | |
from sys import argv |
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
from __future__ import print_function | |
from collections import defaultdict | |
import functools | |
def Y(f): | |
@functools.wraps(f) | |
def Yf(*args): | |
return inner(*args) | |
inner = f(Yf) |
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
from collections import OrderedDict | |
class OrderedSet(object): | |
def __init__(self, iterable = None): | |
self.storage = OrderedDict() | |
if iterable: | |
self.storage.update((elem, True) for elem in iterable) | |
def __contains__(self, elem): | |
return elem in self.storage | |
def __iter__(self): | |
return iter(self.storage) |
NewerOlder