Skip to content

Instantly share code, notes, and snippets.

View benekastah's full-sized avatar

Paul Harper benekastah

  • San Francisco
View GitHub Profile
import random
import subprocess, sys, time
FRAME_RATE = 30
def wrap_pos(pos: int, canvas_size: int):
while True:
pos %= canvas_size
yield pos
pos += 1
@benekastah
benekastah / .gitconfig
Created May 12, 2020 19:34
An automated pull request checklist
[alias]
# Pushes your branch to a remote branch of the same name
up = !git push -u origin "$(git rev-parse --abbrev-ref HEAD)"
# open a pull request, echos the url to the pr.
# Requires the `hub` command: https://github.com/github/hub.
pr = "!f(){ \
checklist -r .pr_checklist || exit 1; \
git up; \
hub pull-request -m \"$(git log -1 --pretty=format:'%B')\" --edit -b master -h \"$(git rev-parse --abbrev-ref HEAD)\"; \
@benekastah
benekastah / basic_scraper.py
Created February 17, 2020 18:51
Basic web scraping using BeautifulSoup
from bs4 import BeautifulSoup
import requests
def scrape_page(url):
r = requests.get("http://" + url)
data = r.text
soup = BeautifulSoup(data)
for link in soup.find_all('a'):
print(link.get('href'))
@benekastah
benekastah / .bash_profile
Last active February 13, 2018 02:16 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@benekastah
benekastah / dom.js
Created March 8, 2017 05:18 — forked from anonymous/dom.js
A simple dom manipulation and rendering library
(function (self) {
var old$ = self.$;
var $ = self.$ = document.querySelector.bind(document);
$.noConflict = function () {
self.$ = $.old$;
return $;
};
@benekastah
benekastah / dom.js
Created March 8, 2017 05:18 — forked from anonymous/dom.js
A simple dom manipulation and rendering library
(function (self) {
var old$ = self.$;
var $ = self.$ = document.querySelector.bind(document);
$.noConflict = function () {
self.$ = $.old$;
return $;
};
@benekastah
benekastah / such-productive.sh
Created March 10, 2016 22:10
Be such productive while you type as fast and loud as you want
#!/bin/bash
await-key () {
tput smso
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 >/dev/null 2>&1
stty "$oldstty"
}
@benekastah
benekastah / big_in_clause.sql
Created September 30, 2015 23:44
A sql file with a large in clause
SELECT
DATE_FORMAT(ca.created_at, 'Y%Y')as Year,
COUNT(DISTINCT ca.id)
FROM canada as ca
WHERE (id IN (1000,
1001,
1002,
1003,
<!doctype html>
<html>
<head>
<title>Todo App</title>
<script type="text/javascript">
var todos = [];
function Todo(title, description, done) {
this.id = null;
@benekastah
benekastah / meal_planner.py
Last active August 29, 2015 14:23
Meal planner
import random
carbs = ['noodles', 'bread', 'toast']
protein = ['egg', 'beef', 'chicken']
fruit = ['banana', 'apple', 'orange']
def meal():
# This is a list comprehension: https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions
return [random.choice(l) for l in [carbs, protein, fruit]]