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 yalies | |
| import os | |
| import csv | |
| api = yalies.API(os.environ['YALIES_API_KEY']) | |
| people = api.people(filters={'school_code': 'YC'}) | |
| columns = [ | |
| 'first_name', 'last_name', 'email', 'college', 'college_code', 'year', 'leave', 'major', 'address', |
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 yalies | |
| import os | |
| api = yalies.API(os.environ['YALIES_API_KEY']) | |
| months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] | |
| people = api.people(filters={'school_code': 'YC'}) | |
| birth_months = [0] * 12 | |
| for person in people: | |
| birth_month = person.birth_month |
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 yalies | |
| api = yalies.API('YALIES_API_KEY_HERE') | |
| for person in api.people(): | |
| if 'kilo' in person.first_name.lower(): | |
| print(person.first_name + ' ' + person.last_name) |
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 | |
| with open('answers.js', 'r') as f: | |
| lines = f.readlines() | |
| first = lines.pop(0) | |
| last = lines.pop() | |
| random.shuffle(lines) | |
| lines.insert(0, first) | |
| lines.append(last) |
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
| with open('/tmp/list', 'r') as f: | |
| l = f.read().strip() | |
| print(l) | |
| for raw in l.split('\n'): | |
| year, name = raw.split(': ') | |
| print("{name: '" + name + "', year: " + year + "},") |
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 requests | |
| r = requests.get( | |
| #'https://gw.its.yale.edu/soa-gateway/course/webservice/index', | |
| #'https://vm-gwprd-02.internal.yale.edu/soa-gateway/courses/webservice/v2/index', | |
| 'https://vm-gwprd-01.internal.yale.edu/soa-gateway/courses/webservice/v2/index', | |
| params={ | |
| 'mode': 'json', | |
| 'subjectCode': 'CPSC', | |
| 'termCode': '202101', |
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 ocrspace | |
| import os | |
| import time | |
| filenames = os.listdir('buttery_images') | |
| print(filenames) | |
| api = ocrspace.API() | |
| for filename in filenames: | |
| print(filename) | |
| txt_filename = 'buttery_texts/' + filename.replace('jpg', 'txt') |
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
| UPDATE meals SET transfers = FALSE WHERE hall_id != 'CM'; | |
| UPDATE meals SET transfers = TRUE WHERE hall_id != 'CM' AND date >= '2021-09-01'; | |
| UPDATE meals SET transfers = FALSE WHERE hall_id != 'CM' AND name = 'Dinner' AND date IN ('2021-11-07', '2021-10-31', '2021-10-24', '2021-10-17', '2021-10-10', '2021-10-03', '2021-09-26', '2021-09-19', '2021-09-12'); |
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 requests | |
| cookies = { | |
| 'csrftoken': 'oMf6Oy9UmwlpCtveOB3bo4S1aU0t5Mv5n6HSyxx0NhF9D7AiQG9ORerg3QIJTz84', | |
| 'sessionid': '4w8ipimaz3h57dpr19693xe5juvtmkck', | |
| } | |
| headers = { | |
| 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:89.0) Gecko/20100101 Firefox/89.0', | |
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.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
| import json | |
| def clean_one(person: dict): | |
| """ | |
| Remove empty properties from person record. | |
| :param person: single person record. | |
| """ | |
| return {k: v for k, v in person.items() if v or type(v) == bool} | |
| def clean(people): |
NewerOlder