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
from multiprocessing import Process, Lock | |
class ConstantlyUpdatingDict(dict): | |
updater #= Process(target=update_dict, args=(self, self.data_lock)) | |
data_lock #= | |
def __init__(self, *args): | |
dict.__init__(self,*args,**kwargs) | |
self.updater.start() | |
def __setitem__(self, key, val): | |
data_lock.acquire() |
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
venues = [] | |
others = [] | |
sims = [] | |
dictVenues = VenueToVenue.transformDict(user_ratings) | |
for venueID in dictVenues.keys(): | |
for otherID in dictVenues.keys(): | |
if otherID == venueID: | |
sim = 0 | |
else: | |
sim = dist_metric(dictVenues[venueID], dictVenues[otherID]) |
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
from multiprocessing import Process, Lock, Manager | |
from time import sleep | |
def update_dict(cls, db, lock): | |
temp_db = {} | |
while True: | |
lock.acquire() | |
try: | |
temp_db['userRatings'] = db['userRatings'] + 1 | |
temp_db['venueToVenue'] = db['venueToVenue'] +1 |
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
irb(main):001:0> a | |
NameError: undefined local variable or method `a' for main:Object | |
from (irb):1 | |
irb(main):002:0> b | |
NameError: undefined local variable or method `b' for main:Object | |
from (irb):2 | |
irb(main):003:0> a=b | |
NameError: undefined local variable or method `b' for main:Object | |
from (irb):3 | |
irb(main):004:0> a=a |
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 2012 Joseph R. Hunt | |
# All rights reserved. | |
# This is just a quick hack and is not reliable | |
# width 850,315 | |
import re | |
import urllib | |
import Image | |
import cStringIO |
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
#!/usr/bin/python | |
############################################################################### | |
# Produce a collage (grid) of friend profile images from Facebook. | |
# Inspired by Vipin "swvist" Nair @ https://gist.github.com/2692786 | |
############################################################################### | |
# Copyright (c) 2012 Madzen | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal |
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
set hostList to {"jsl1", "jsl2", "jsl3", "jsl4", "jsl5", "jsl6", "jsl7", "jsl8"} as list | |
tell application "iTerm" | |
activate | |
set myTerm to (make new terminal) | |
tell myTerm | |
repeat with hostItem in hostList | |
set Lsession to (launch session "Default Session") | |
tell Lsession | |
write text "ssh " & hostItem |
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 requests | |
import json | |
from jira.client import JIRA | |
from jira.client import raise_on_error | |
# This class is neccesary because of broken jira-python scripts from Atlassian | |
class XgenJIRA(JIRA): |
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
messages = [None, "Fizz", "Buzz", "FizzBuzz"] | |
acc = 810092048 | |
for i in xrange(1, 101): | |
c = acc & 3 | |
print messages[c] if c else i | |
acc = acc >> 2 | c << 28 |
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
> db.createCollection("newlogs", {capped: true, size: NumberLong("100000000000")}); | |
{ "ok" : 1 } | |
> db.newlogs.stats() | |
{ | |
"ns" : "buildlogs.newlogs", | |
"count" : 0, | |
"size" : 0, | |
"storageSize" : 100000001312, | |
"numExtents" : 47, | |
"nindexes" : 1, |
OlderNewer