Skip to content

Instantly share code, notes, and snippets.

View abehmiel's full-sized avatar

Abraham Hmiel abehmiel

View GitHub Profile
@abehmiel
abehmiel / API_request.py
Last active August 19, 2019 08:30
Basic Python API request
import requests
headers = {"token": "API TOKEN"}
params = {"something": "SOMETHING"}
response = requests.get("https://www.something.com", headers=headers, params=params)
json_data = response.json()
status = response.status_code

Monday, May 22

Weather/Transportation

Rainy. I took the 6 from GCS to Canal St and walked about 4 blocks.

Plans

General

Intense! Met a lot of people!

@abehmiel
abehmiel / fitbit_clean.py
Created May 23, 2017 20:04
Fitbit cleaner
import pandas as pd
from datetime import datetime, date
"""
Cleaning time!
This script will clean data downloaded from the fitbit website.
A little bit of preprocessing is useful. First, Separate the activities
and sleep data into different csv files and make sure there's only
one header row in each. Multiple months may be concatenated together,
@abehmiel
abehmiel / titlecase.js
Created May 25, 2017 14:49
Title Case in JS
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
@abehmiel
abehmiel / json_concat_to_csv.py
Created May 26, 2017 15:07
JSON concatenate, dump to CSV
import json
import csv
# open a file for writing
data = open('trumptweets.csv', 'w')
# create the csv writer object
csvwriter = csv.writer(data)
#write the header
@abehmiel
abehmiel / exploratory_model_tpot
Created May 26, 2017 17:02
Exploratory data analysis and model selection with TPOT
# conversion rate exploratory analysis and ML algorithm hyperparameter optimization
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from tpot import TPOTClassifier
# load the data
df = pd.read_csv("conversion_data.csv")
@abehmiel
abehmiel / Confusionmatrix.py
Created May 29, 2017 16:03
Confusion matrix in scikit-learn
from sklearn.metrics import confusion_matrix
#type of classifier is not important
clf = GradientBoostingClassifier(loss='deviance', learning_rate=0.075, n_estimators=150, max_depth=3)
grbfit = clf.fit(X_train, y_train)
y_pred = grbfit.predict(X_test)
print(clf.score(X_test, y_test))
class_names = [0,1]
@abehmiel
abehmiel / extract-music.py
Created May 29, 2017 19:39 — forked from eevee/extract-music.py
Python script to reconstitute music from a PICO-8 cartridge
# script to extract music from a pico-8
# requires exporting sounds from the pico-8 first!
# run as: python extract-music.py mygame.p8 sound%d.wav music%d.wav
# by eevee, do what you like with this code
from __future__ import print_function
import argparse
import struct
import wave
@abehmiel
abehmiel / communic8
Created June 7, 2017 15:26
Pico-8 communic8 interface to JS
----
---- library code
----
_communic8_chars = "\n\32\33\34\35\36\37\38\39\40\41\42\43\44\45\46\47\48\49\50\51\52\53\54\55\56\57\58\59\60\61\62\63\64\65\66\67\68\69\70\71\72\73\74\75\76\77\78\79\80\81\82\83\84\85\86\87\88\89\90\91\92\93\94\95\96\97\98\99\100\101\102\103\104\105\106\107\108\109\110\111\112\113\114\115\116\117\118\119\120\121\122\123\124\125\126\127\128\129\130\131\132\133\134\135\136\137\138\139\140\141\142\143\144\145\146\147\148\149\150\151\152\153"
_communic8_charindices = {}
for i = 1, #_communic8_chars do
_communic8_charindices[sub(_communic8_chars, i, i)] = 30 + i
end
arg_types = {
byte={
[Unit]
Description=Potentially dangerous fix touchscreen after resume on the XPS 13 9350
After=suspend.target
[Service]
Type=simple
ExecStart=/home/anthony/path/to/xps-touchscreen-workaround.sh
[Install]
WantedBy=suspend.target