Skip to content

Instantly share code, notes, and snippets.

@alexhogak
alexhogak / lenniandalex.py
Created October 18, 2016 11:23
Pillow Talk Bots
__author__ = 'We are Content Providers'
import json
from twython import Twython, TwythonError, TwythonStreamer
import pymongo
import re
from time import sleep, gmtime, strftime
import random
import numpy as np
from botcontrol import My_Bot
@alexhogak
alexhogak / mongounwind.py
Created May 10, 2016 16:23
MONGO UNWIND EXAMPLE
db.newwolverhampton.aggregate([{$unwind: "$Appeals"},{$project: {_id: 0, BAReference: 1, Postcode: 1, EffectDate: 1, TotalArea: 1, BillingAuthority: 1, RateableValue: 1, Address: 1, Description: 1, Appeal_Reference: "$Appeals.ReferenceNo", Appeal_Applicant: "$Appeals.Applicant", Appeal_Agent: "$Appeals.Agent", Grounds: "$Appeals.Grounds_for_Appeal", Appeal_Start: "$Appeals.Start_Date", Appeal_End: "$Appeals.End_Date", Appeal_Settlement: "$Appeals.Settlement"}},{$out: "newwolvesappeals"}])
@alexhogak
alexhogak / dictinsert.py
Created May 10, 2016 16:23
DICTIONARY INSERT CODE
import pymongo
from time import gmtime, strftime, sleep
connection = pymongo.Connection('localhost', 27017) #connect to database host
db = connection.ratesdb #connect to rates database
results = {}
@alexhogak
alexhogak / nestedappeal.py
Created May 10, 2016 16:22
NESTED APPEAL STRUCTURE CODE
def appeal_scrape(soup, appeal_no):
appeals_array = []
top_dict = {}
appeal_cursor = 1
rating_cursor = 1
#print "looking for appeals"
@alexhogak
alexhogak / BCStreamer.py
Created February 12, 2014 16:59
Black Country Informetrics Twitter Streamer Example
import json
from twython import Twython, TwythonError, TwythonStreamer
import pymongo
# Setup Authentification Settings
APP_KEY = 'YOURKEY'
APP_SECRET = 'YOURSECRET'
OAUTH_TOKEN = 'YOURTOKEN'
OAUTH_TOKEN_SECRET = 'YOURTOKENSECRET'