This file contains hidden or 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 disjoint2(A, B, C): | |
"""Return True if there is no element common to all three lists.""" | |
for a in A: | |
for b in B: | |
if a == b: # only check C if we found match from A and B | |
for c in C: | |
if a == c # (and thus a == b == c) | |
return False # we found a common value | |
return True # if we reach this, sets are disjoint |
This file contains hidden or 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 os | |
import re | |
DIR = '' # Directory containing chat logs | |
FILENAMES = ('#python',) # Substring that chat logs to searched should contain | |
NICKS = ('tristaneuan',) # Nicknames expected to be upvoted | |
LAUGHS = ('[ha]{6,}', '[lo]{6,}', 'lmao', 'lmfao', 'rofl') | |
fileregex = re.compile('|'.join(FILENAMES)) | |
laughregex = re.compile('|'.join(LAUGHS), flags=re.I) |
This file contains hidden or 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 get_location_uid(name, country_code): | |
# TODO: DRY, figure out a better way to do this | |
cursor.execute("SELECT uid FROM location WHERE name = '%s' AND country_code = '%s'" % (name, country_code)) | |
result = cursor.fetchone() | |
if result is not None: | |
return result[0] | |
cursor.execute("INSERT INTO location (name, country_code) VALUES ('%s', '%s')" % (name, country_code)) | |
db.commit() | |
cursor.execute("SELECT uid FROM location WHERE name = '%s' AND country_code = '%s'" % (name, country_code)) | |
result = cursor.fetchone() |
This file contains hidden or 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
module Lita | |
module Handlers | |
class Temp < Handler | |
http.post '/foo/:bar', :foo | |
def foo(request, response) | |
bar = request.env['router.params'][:bar] | |
baz = request.params['baz'] | |
response.write("#{bar}\n#{baz}") | |
end |
This file contains hidden or 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
tristan@15th:~/Code/lita-dev/workspace/lita-github$ bi | |
Resolving dependencies... | |
Using rake 10.4.2 | |
Using addressable 2.3.8 | |
Using ast 2.1.0 | |
Using parser 2.2.2.6 | |
Using astrolabe 1.3.1 | |
Using bundler 1.10.6 | |
Using docile 1.1.5 | |
Using json 1.8.3 |