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 find(lis, item, first): | |
if first == len(lis): | |
return -1 | |
elif lis[first] == item: | |
return first | |
return find(lis, item, first + 1) |
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
class FbXmpp(): | |
def __init__(self, jid, api_key, access_token): | |
xmpp = sleekxmpp.ClientXMPP(jid, 'ignore') | |
self.xmpp = xmpp | |
xmpp.register_plugin('xep_0030') # Service Discovery | |
xmpp.register_plugin('xep_0199') # XMPP Ping | |
xmpp.credentials['api_key'] = api_key | |
xmpp.credentials['access_token'] = access_token |
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_number_of_leaves(self): | |
return self.left.get_number_of_leaves() + self.right.get_number_of_leaves() |
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 constants | |
""" | |
Generates a py_id prefix matching the classname and counts uniquely across | |
classes | |
""" | |
class KazooBlockMeta(type): | |
def __new__(klass, name, parents, dic): | |
dic['next_py_id'] = 1 | |
dic['py_id_prefix'] = name.lower() |
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
from mongo import Mongo | |
""" | |
Metaclass to simplify use of items stored in the database. Some of this shit could | |
be refactored into a class that can be inherited from, but this will do for now | |
""" | |
class DatabaseLinkMeta(type): | |
def __new__(metaclass, classname, bases, classdict): | |
mongo = Mongo() |
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
#!/bin/bash | |
sleep $(($1*60)) && mpc pause |
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
# On branch dev-3.20 | |
# You have unmerged paths. | |
# (fix conflicts and run "git commit") | |
# | |
# Changes to be committed: | |
# | |
# modified: applications/callflow/src/cf_route_win.erl | |
# modified: applications/crossbar/Makefile | |
# modified: applications/crossbar/priv/couchdb/account/search.json | |
# new file: applications/crossbar/priv/couchdb/views/globals_resources.json |
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
# A1 for COMPSCI340/SOFTENG370 2015 | |
# Prepared by Robert Sheehan | |
# Modified by ... | |
# You are not allowed to use any sleep calls. | |
from threading import Lock, Event | |
from process import State | |
class ProcessStack(): |
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
@Test | |
public void testAlbumResourceLongPoll() throws InterruptedException, ExecutionException, TimeoutException { | |
Client client = ClientBuilder.newClient(); | |
Client asyncClient = ClientBuilder.newClient(); | |
Client getAlbumClient = ClientBuilder.newClient(); | |
try { | |
final String albumTitle = "My Squelchy Life"; | |
AlbumDTO album = new AlbumDTO(); |
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
for (bi=0; bi<size; bi+=block_size){ | |
for (bj=0; bj<size; bj+=block_size){ | |
//Handle cases where size%block_size!=0 | |
max_j = (bi+block_size<=size)?block_size:size%block_size; | |
max_k = (bj+block_size<=size)?block_size:size%block_size; | |
for (i=0; i<block_size; i++){ | |
for (j=0; j<max_j; j++){ | |
for (k=0; k<max_k; k++){ | |
result[i*size+(bi+j)] += A[i*size+(bj+k)] * B[(bj+k)*size+(bi+j)]; | |
} |