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_balance(base_url, username, password): | |
| url = base_url + "/v1/client/balance" | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8')} | |
| req = ulib.Request(url, headers=headers) | |
| responseData = ulib.urlopen(req).read() | |
| balance = json.loads(responseData.decode('utf-8')) |
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_sport_odds(base_url, username, password, sport = '15'): | |
| url = base_url + '/v1/odds?sportId=' + str(sport) + '&oddsFormat=DECIMAL' | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8') | |
| } | |
| req = ulib.Request(url, headers=headers) | |
| responseData = ulib.urlopen(req).read() |
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_bet(all_odds): | |
| bet_info = {} | |
| favourable_odds = 1.91 | |
| bet_info['sportId'] = all_odds['sportId'] | |
| for i in all_odds['leagues']: | |
| bet_info['leagueId'] = i['id'] | |
| for j in i['events']: | |
| bet_info['eventId'] = j['id'] | |
| for k in j['periods']: | |
| bet_info['period'] = k['number'] |
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_bet_info(base_url, username, password, bet, favourable_odds = 1.91): | |
| b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8')) | |
| headers = {'Content-length' : '0', | |
| 'Content-type' : 'application/json', | |
| 'Authorization' : "Basic " + b64str.decode('utf-8')} | |
| url_without_team = base_url + "/v1/line?sportId={0}&leagueId={1}&eventId={2}&periodNumber={3}&betType=MONEYLINE&OddsFormat=DECIMAL"\ | |
| .format(bet['sportId'], bet['leagueId'], bet['eventId'],bet['period']) | |
| url = url_without_team + "&Team=Team1" |
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_subreddit_comments(reddit_agent, subreddit, comments_out = [], count = 100): | |
| #surrounded by try catch in case API calls get exceed | |
| try: | |
| sub = reddit_agent.get_subreddit(subreddit) | |
| comments_raw = sub.get_comments(sub, limit=count) | |
| comments_flat = praw.helpers.flatten_tree(comments_raw) | |
| for comment in comments_flat: | |
| #try catch handles end of reply tree containing a null comment | |
| try: | |
| if hasattr(comment, 'comments'): |
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
| if __name__ == "__main__": | |
| client_id = 'your_client_id' | |
| client_secret = 'your_client_secret' | |
| reddit_agent = get_reddit_agent('custom name for app', client_id, client_secret) | |
| #list of canadian reddits to search | |
| canada_reddits = ['canada','alberta','britishcolumbia','Manitoba','NewBrunswickCanada', 'newfoundland', | |
| 'NovaScotia','nunavut','NWT','ontario','PEI', 'saskatchewan','Yukon'] | |
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_sorry_and_word_count(comment_list, apologies = ['sorry', 'apologies']): | |
| sorry_count = 0 | |
| word_count = 0 | |
| for comment in comment_list: | |
| words = comment.split(' ') | |
| word_count += int(len(words)) | |
| for word in words: | |
| for apology in apologies: | |
| sorry_count += word.lower().count(apology) | |
| return sorry_count, word_count |
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 praw | |
| import sys | |
| def get_subreddit_comments(reddit_agent, subreddit, comments_out = [], count = 100): | |
| try: | |
| sub = reddit_agent.get_subreddit(subreddit) | |
| comments_raw = sub.get_comments(sub, limit=count) | |
| comments_flat = praw.helpers.flatten_tree(comments_raw) | |
| for comment in comments_flat: | |
| try: |
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
| #planet info which can be added as parameters | |
| sun = {"location":point(0,0,0), "mass":2e30, "velocity":point(0,0,0)} | |
| mercury = {"location":point(0,5.0e7,0), "mass":3.285e23, "velocity":point(47000,0,0)} | |
| venus = {"location":point(0,1.1e11,0), "mass":4.8e24, "velocity":point(35000,0,0)} | |
| earth = {"location":point(0,1.5e11,0), "mass":6e24, "velocity":point(30000,0,0)} | |
| mars = {"location":point(0,2.2e11,0), "mass":2.4e24, "velocity":point(24000,0,0)} | |
| jupiter = {"location":point(0,7.7e11,0), "mass":1e28, "velocity":point(13000,0,0)} | |
| saturn = {"location":point(0,1.4e12,0), "mass":5.7e26, "velocity":point(9000,0,0)} | |
| uranus = {"location":point(0,2.8e12,0), "mass":8.7e25, "velocity":point(6835,0,0)} | |
| neptune = {"location":point(0,4.5e12,0), "mass":1e26, "velocity":point(5477,0,0)} |
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 calculate_single_body_acceleration(bodies, body_index): | |
| G_const = 6.67408e-11 #m3 kg-1 s-2 | |
| acceleration = point(0,0,0) | |
| target_body = bodies[body_index] | |
| for index, external_body in enumerate(bodies): | |
| if index != body_index: | |
| r = (target_body.location.x - external_body.location.x)**2 + (target_body.location.y - external_body.location.y)**2 + (target_body.location.z - external_body.location.z)**2 | |
| r = math.sqrt(r) | |
| tmp = G_const * external_body.mass / r**3 | |
| acceleration.x += tmp * (external_body.location.x - target_body.location.x) |
OlderNewer