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
select count(*) | |
into @exists | |
from information_schema.tables | |
where table_schema = 'dbs_admin' | |
and table_name = 'dbs_auto_increment'; | |
set @qry = select if(@exists<0, | |
'rename table publisher.dbs_auto_increment to dbs_admin.dbs_auto_increment', | |
'select \'table exists\' status') as querystr; |
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
"""This is main.py, where the main stuff happens. | |
""" | |
import sys | |
import os | |
# lets assume your file is in /home/oli/nuke_files/main.py | |
# | |
# __file__ is a magic variable which python automatically populates, and is the | |
# full path to the file which is currently being executed (i.e. this one), | |
# so __file__ == '/home/oli/nuke_files/main.py' |
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 parse_line(entry, e_dict): | |
leaderboard_req_re = '/api/publisher/([^/}{32}?)/proxy/.*leaderboard.*' | |
regex = re.compile(leaderboard_req_re) | |
e = entry.splt('\t') | |
for i in e: | |
if e[8] == 'loyalty.bigdoor.com': | |
match = regex.search(e[19]) | |
if match: | |
ts_slice = e_dict[e[14]] | |
ts_slice[match.group(0)] += 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
# code under test: | |
class TwitterOAuth(BaseOAuth): | |
def get_profile(self, access_token): | |
"""Retrieves the profile of the Twitter user who just authenticated. | |
Requires the raw access token from the API as Twitter returns the user | |
ID baked in. | |
""" |
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 random | |
from imagination import count_soda, restock_soda | |
available_sodas = ['Sprite', 'Coke', 'Diet Coke', 'Dr. Pepper'] | |
def take_soda(): | |
soda = random.choice(available_sodas) | |
if count_soda(soda) < 2: | |
restock_soda(soda) |
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 bigdoorkit import Client | |
app_key = 'BIGDOOR_APP_KEY' | |
secret_key = 'BIGDOOR_SECRET_KEY' | |
client = Client(secret_key, app_key) |
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 bigdoorkit import Client | |
from collections import defaultdict | |
import restkit | |
def reward_users(client, currency_id, transaction_ids): | |
"""Rewards the top 3 leaders on a specified currency's leaderboard. | |
@param client {bigdoorkit.Client} The preconfigured client to access the | |
BigDoor API. | |
@param currency_id {int} ID of the currency for the leaderboard. |
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 gevent.queue import Queue | |
from gevent.event import Event | |
import gevent | |
import logging | |
# The event which brings everything to a halt | |
stop_event = Event() | |
# set up logging | |
logging.basicConfig(filename='expire.log', level=logging.DEBUG) |
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
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other | |
# stuff too? No support for SuperColumns, but that should be easy enough to add. | |
import bisect | |
import copy | |
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn | |
class SSTable(object): |