Skip to content

Instantly share code, notes, and snippets.

View abehmiel's full-sized avatar

Abraham Hmiel abehmiel

View GitHub Profile

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

Questions? See my blog post - http://dan.cx/blog/2011/06/twitter-autoreply-bot-dbznappa

Modified 2013-06-13 - Twitter API 1.0 discontinued, modified to use Twitter API 1.1

@abehmiel
abehmiel / tweet_utils.py
Created July 11, 2017 17:55 — forked from timothyrenner/tweet_utils.py
Python Utilities for Tweets
from datetime import datetime
import string
from nltk.stem.lancaster import LancasterStemmer
from nltk.corpus import stopwords
#Gets the tweet time.
def get_time(tweet):
return datetime.strptime(tweet['created_at'], "%a %b %d %H:%M:%S +0000 %Y")
@abehmiel
abehmiel / roman.lua
Last active September 14, 2017 19:02
Refucktoring: Roman numerals in LUA
--- ●●●●●●●
-- 7 successes / 0 failures / 0 errors / 0 pending : 48.994555 seconds
-- SOURCE: http://rosettacode.org/wiki/Roman_numerals/Decode#Lua
-- SOURCE: http://rosettacode.org/wiki/Roman_numerals/Encode#Lua
-- Tested with the Busted framework for lua (luarocks install busted)
local math = require "math"
function CiceroCiceroCiceroCiceroCiceroCiceroCiceroCiceroCiceroCicero()
@abehmiel
abehmiel / get_tweets.py
Last active June 23, 2017 13:09
Tweet collector for the irony-sarcasm dataset
#!/usr/bin/python3
# For the dataset (tweet ids), visit:
# http://www.romanklinger.de/ironysarcasm/
# this script lives in the same folder as the eight ID tweet identifier csv files.
import tweepy
import json
import math
import pandas as pd
import csv
[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
@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={
@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 / 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 / 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 / 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