Skip to content

Instantly share code, notes, and snippets.

@townie
townie / interesting_3_letter_words.py
Last active May 4, 2021 00:26
get all permutations of 3 letters
import string
import itertools
all_3_raw = list(itertools.permutations([chr(i) for i in range(97, 123)], 3))
all_3 = [''.join(w) for w in all_3_raw]
scrabble_3words_raw = 'aah aal aas aba abo abs aby ace act add ado ads adz aff aft aga age ago ags aha ahi ahs aid ail aim ain air ais ait ala alb ale all alp als alt ama ami amp amu ana and ane ani ant any ape apo app apt arb arc are arf ark arm ars art ash ask asp ate att auk ava ave avo awa awe awl awn axe aye ays azo baa bad bag bah bal bam ban bap bar bas bat bay bed bee beg bel ben bes bet bey bib bid big bin bio bis bit biz boa bob bod bog boo bop bos bot bow box boy bra bro brr bub bud bug bun bur bus but buy bye bys cab cad cam can cap car cat caw cay cee cel cep chi cig cis cob cod cog col con coo cop cor cos cot cow coy coz cru cry cub cud cue cup cur cut cwm dab dad dag dah dak dal
from threading import Thread
q = []
running = True
def publish(thing):
print('publishing: {}'.format(thing))
q.append(thing)
# WHY parameters that are mutable in params
def foo_str(l='A', a=None):
print('BEFORE')
print(l)
print("AFTER")
l + a
print(l)
@townie
townie / test.md
Last active October 30, 2017 19:19

Current

prediction row_id class_1 class_2 class_3
1 0 0.998750 0.000002 0.00003

Reason codes approach

| prediction | row_id | class_1_label | class_1_probability | class_2_label | class_2_probability |class_3_label | class_3_probability |

@townie
townie / test
Created October 30, 2017 19:17
| prediction | row_id | class_1 | class_2 | class_3 |
| ---|---------|-----|----|--- |
| 1 | 0 | 0.998750 | 0.000002 | 0.00003 |
| prediction | row_id | class_1_label | class_1_probability | class_2_label | class_2_probability |class_3_label | class_3_probability |
| ---|---------|-----|----|--- | ---| ---| --|
public class UserHistory_CreateUpdateFromUser {
static final String NEWUSERLIST = 'newUserList';
static final String LOBCHANNELLIST = 'lOBChannelList';
static final String ISACTIVELIST = 'isActiveList';
static final String UMANAGERLIST = 'uManagerList';
class KitchenSink(object):
def drain(self):
print('wash')
class NoSink(object):
def noop(self):
print('noop')
def __getattr__(self, name):
if hasattr(KitchenSink, name):
@townie
townie / collect.js
Last active August 31, 2017 21:58
Get all of the collections and records out of a database
// mongo 127.0.0.1/MMApp collect.js >> collects.txt
var collects= db.getCollectionNames();
collects.forEach(function(name, i) {
var c = db[name].find();
while(c.hasNext()) {
printjson(c.next())
}
});
@townie
townie / __init__.py
Last active August 25, 2017 19:12
py2_3_enum.py
# put in __init__.py
def enum(*vals, **enums):
"""
Enum without third party libs and compatible with py2 and py3 versions.
"""
enums.update(dict(zip(vals, vals)))
return type('Enum', (), enums)
# Implict return
class SomeClass(Object):
def implicit_do_stuff(self, val):
if self.some_value:
return val + 1
return val
def implicit_do_stuff(self, val):
if self.some_value: