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 | |
data = { | |
'view_name': 'discover_artist_subpages_content_block', | |
'view_display_id': 'block_1', | |
'view_args': '46,51,56/all/206/all/all', | |
'view_path': 'discover/artists', | |
'view_dom_id': '95603486a7f8f13392af1f532e99b6ad', | |
'pager_element': '0', | |
'featured': 'all', |
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
coins = [ | |
{'name': 'ETH', 'qty': 0.81945672, 'price': 215.15}, | |
{'name': 'USDT', 'qty': 125.99, 'price': .99}, | |
{'name': 'BTC', 'qty': 0.02497291, 'price': 6895.15}, | |
{'name': 'BNB', 'qty': 20.91476451, 'price': 10.25}, | |
] | |
def generate_balance(coins, prec=8): | |
min = 999*999 | |
max = 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
import os, sys | |
import Image | |
size = 128, 128 | |
for infile in sys.argv[1:]: | |
outfile = os.path.splitext(infile)[0] + ".thumbnail" | |
if infile != outfile: | |
try: | |
im = Image.open(infile) |
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 xlsxwriter import Workbook | |
players = [ | |
{'dailyWinners': 3, 'dailyFree': 2, 'user': 'Player1', 'bank': 0.06}, | |
{'dailyWinners': 3, 'dailyFree': 2, 'user': 'Player2', 'bank': 4.0, 'level': 'Gold'}, | |
{'dailyWinners': 1, 'dailyFree': 2, 'user': 'Player3', 'bank': 3.1}, | |
{'dailyWinners': 3, 'dailyFree': 2, 'user': 'Player4', 'bank': 0.32, 'time': 'AM'} | |
] | |
def write_excel(dict_objects, filename, sheetname=None): | |
ordered_list = [] |
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 | |
from glob import glob | |
def save_data(data): | |
try: | |
asin = data['asin'] | |
file_loc = 'data/{}.json'.format(asin) | |
file = open(file_loc, 'w+') | |
json.dump(data, file) | |
except KeyError: |
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
user_agent_list = [ | |
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.0 Safari/536.3", | |
"Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko", | |
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" | |
] | |
num = random.randint(0, (len(user_agent_list) - 1)) | |
def get_page_object(url): | |
response = requests.get( |
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 pandas as pd | |
df = pd.read_csv('file.tab', sep='\t', lineterminator='\r') | |
import pandas as pd | |
fwidths = [34, 4, 4, 34, 11, 1, 1, 1, 1, 1, 8, 8, 2, 11, 1, 40, 1, 40, 1, 7, 7, 1, 1, 1, 4, 40, 40, 40, 40, 40, 2, 12, 1, 8, 40, 1, 11, 11, 11, 11, 1 ] | |
df = pd.read_fwf('file.tab', widths = fwidths, names = ['ACCOUNT', 'YEAR', 'JURISDICTION', 'TAX-UNIT-ACCT', 'LEVY', 'HOMESTEAD', 'OVER65', 'VETERAN', 'DISABLED', 'AG', 'DATE-PAID', 'DUE-DATE', 'OMIT-FLAG', 'LEVY-BALANCE', 'SUIT', 'CAUSENO', 'BANKCODE', 'BANKRUPTNO', 'ATTORNEY', 'COURT-COST', 'ABSTRACT-FEE', 'DEFERRAL', 'BILLSUPP', 'SPLIT-PMTFLAG', 'CATEGORY-CODE', 'OWNER', 'ADDRESS2', 'ADDRESS3', 'ADDRESS4', 'CITY', 'STATE', 'ZIP', 'ROLL-CODE', 'PARCEL NO.', 'PARCEL NAME', 'PAYMENT AGREEMENT', 'TOT_AMT_DUE', 'TOT_AMT_DUE-30', 'TOT_AMT_DUE-60', 'TOT_AMT_DUE-90', 'AMOUNT INDICATOR']) | |
df[:10] |
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 item.item, | |
qty AS inventory_level, | |
description, | |
product_code, | |
family_code, | |
plan_code, | |
unit_weight, | |
weight_units, | |
charfld1 AS upc, | |
stat, |
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 nltk, string | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
nltk.download('punkt') # if necessary... | |
stemmer = nltk.stem.porter.PorterStemmer() | |
remove_punctuation_map = dict((ord(char), None) for char in string.punctuation) | |
def stem_tokens(tokens): |
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 tempfile | |
import win32api | |
import win32print | |
filename = tempfile.mktemp (".txt") | |
open (filename, "w").write (str(df)) | |
win32api.ShellExecute ( | |
0, | |
"print", |