Skip to content

Instantly share code, notes, and snippets.

# 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():
# 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
#!/bin/bash
sleep $(($1*60)) && mpc pause
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()
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()
def get_number_of_leaves(self):
return self.left.get_number_of_leaves() + self.right.get_number_of_leaves()
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
def find(lis, item, first):
if first == len(lis):
return -1
elif lis[first] == item:
return first
return find(lis, item, first + 1)
class Facbook:
def __init__(self, token):
self.token = token
self.graph = facebook.GraphAPI(token)
self.profile = self.graph.get_object("me")
def get_friends(self):
friends = self.graph.get_connections("me", "friends")
# To extract names
# friend_list = [friend['name'] for friend in friends['data']]
#!/usr/bin/bash
get_focus() { [[ $1 == "true" ]] && echo 1 || echo 0; }
# read workspace data into an associative array
i=0
focus=0
declare -A ws_data
prior_monitor=0
while read line; do