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
function pickRandomProperty(obj) { | |
// from http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object | |
var result; | |
var count = 0; | |
for (var prop in obj) | |
if (Math.random() < 1/++count) | |
result = prop; | |
return result; | |
} |
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
(fn y=>(fn x=>(print(x^y^x^y))))(implode[chr(34)])"(fn y=>(fn x=>(print(x^y^x^y))))(implode[chr(34)])" |
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
\clubpenalty = 10000· | |
\widowpenalty = 10000· | |
\displaywidowpenalty = 10000 | |
\setlength\parindent{2.5em} | |
\setlength\parskip{0.3\baselineskip}· | |
\usepackage{geometry} | |
\addtolength{\oddsidemargin}{.3in} |
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
[version 1.1] | |
Chatting happens in different levels, which allows for multi-threaded conversations. | |
The different conversation levels are marked with a number of parantheses. | |
Example 1: | |
A: How are you? | |
A: (And how is your family?) | |
B: Fine (and fine, too). |
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 math | |
class Num(object): | |
def __init__(self, val): | |
self.value = val | |
self.bit = False | |
def __repr__(self): | |
return str(self.value) | |
def __abs__(self): | |
return self |
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 operator as op | |
from functools import partial | |
class _getter(object): | |
def __init__(self, *, is_original=True): | |
self.is_original=is_original | |
self.__ops = [] | |
def __call__(self, something): | |
''' Maybe eventually extend to act like methodcaller, but problems exist''' |
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
license: gpl-3.0 |
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
def weighted_distance(x, y): | |
x, y = x.split(), y.split() | |
length = len(x+y)/2 | |
return editdistance.eval(x, y)/length |
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
def retry(tries): | |
def decorator(fn): | |
@functools.wraps(fn) | |
def wrapper(*args, **kwargs): | |
ex = None | |
for i in range(tries): | |
try: | |
result = fn(*args, **kwargs) | |
except Exception as e: | |
print("Failed...") |
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
Copyright (c) 2018 L3viathan | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all |
OlderNewer