Skip to content

Instantly share code, notes, and snippets.

View abehmiel's full-sized avatar

Abraham Hmiel abehmiel

View GitHub Profile
@abehmiel
abehmiel / 0_reuse_code.js
Created March 31, 2017 15:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@abehmiel
abehmiel / starter.lua
Created April 7, 2017 05:36 — forked from byronhulcher/starter.lua
PICO-8 Starter LUA code (save this as starter.p8)
-- pico-8 starter code
-- by @hypirlink
-- _init() is called when
-- you 'run' the program
function _init()
-- states: menu, game, end
state = "menu"
end
@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
[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 / 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")

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 / memoize_decorator.py
Created July 29, 2017 19:53 — forked from eriwen/memoize_decorator.py
Memoize Decorator in Python
def memoize(fn):
cache = {}
def wrapper(*args):
try:
return cache[args]
except:
result = fn(*args)
cache[args] = result
return result
return wrapper
@abehmiel
abehmiel / beautiful_idiomatic_python.md
Created August 11, 2017 21:44 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@abehmiel
abehmiel / gist:d932a2b3028f836194db7cb3ffd49334
Created October 17, 2017 20:30 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):