Skip to content

Instantly share code, notes, and snippets.

Avatar

Abraham Hmiel abehmiel

View GitHub Profile
@abehmiel
abehmiel / API_request.py
Last active Aug 19, 2019
Basic Python API request
View API_request.py
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
View recurse_week_01.org

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!

View fitbit_clean.py
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
Title Case in JS
View titlecase.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
JSON concatenate, dump to CSV
View json_concat_to_csv.py
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
Exploratory data analysis and model selection with TPOT
View exploratory_model_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
Confusion matrix in scikit-learn
View Confusionmatrix.py
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 — forked from eevee/extract-music.py
Python script to reconstitute music from a PICO-8 cartridge
View extract-music.py
# 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 Jun 7, 2017
Pico-8 communic8 interface to JS
View communic8
----
---- 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={
View xps-touchscreen-workaround.service
[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
You can’t perform that action at this time.