Skip to content

Instantly share code, notes, and snippets.

View abelsonlive's full-sized avatar
🕳️
[ o o ]

Brian Abelson abelsonlive

🕳️
[ o o ]
View GitHub Profile
@abelsonlive
abelsonlive / try_or_die.sh
Created January 17, 2017 23:17 — forked from dotike/try_or_die.sh
3 finger claw technique for POSIX shell programming. Three one-line functions which greatly enhance shell programming, enabling reliable UNIX-style programming in an extremely concise fashion.
#!/bin/sh
##############################################################################
# This code known is distributed under the following terms:
#
# Copyright (c) 2013 Isaac (.ike) Levy <ike@blackskyresearch.net>.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@abelsonlive
abelsonlive / gist:3899832
Created October 16, 2012 15:05
coefplot.R
require("RColorBrewer")
# not run:
# model = lm(y~x1+x2+x3+x4...)
# Construct quantile table for varialbes of interest
# t value: n-p=df.residual=634, alpha=5%,50%. t(1-alpha/2, n-p)
t.05 <- qt(1-0.025, 634, lower.tail = TRUE, log.p=FALSE)
t.5 <- qt(1-0.25, 634, lower.tail = TRUE, log.p=FALSE)
coef.quantil <- data.frame(matrix(0, nrow=length(model$coefficients)-1, ncol=8))
@abelsonlive
abelsonlive / submit_receipts.py
Last active January 4, 2016 07:09
Load a folder of images / pdfs / documents / etc, and send them one at a time as a attachments via gmail.
import smtplib
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from email import Encoders
import time
import os
def load_attachments(folder):
# clean up folder name
@abelsonlive
abelsonlive / img_crawler.py
Last active January 3, 2016 21:38
sample img crawler
from mrjob.job import MRJob
from mrjob.protocol import JSONValueProtocol, JSONProtocol, RawProtocol
import json
from urlparse import urlparse
img_formats = [
'jpg',
'gif',
'png'
]
list_of_dicts = [{'a':1}, {'b':2}]
list_of_dicts[-1]['b'] = 3
print list_of_dicts[-1]
@abelsonlive
abelsonlive / streaming_link_tracker.py
Created December 17, 2013 08:39
hack to find links on twitter
@abelsonlive
abelsonlive / csv2json.py
Created December 12, 2013 17:31
convert a csv file into a json list of dicts
import pandas as pd
import json
import sys
def csv2json(file_path):
df = pd.read_csv(file_path, encoding='latin1')
output = []
for i in df.index:
row = {}
@abelsonlive
abelsonlive / known_tlds
Created November 26, 2013 04:31
Known TLDS
var KNOWN_TLDS = [
'aero', 'asia', 'biz', 'cat', 'com', 'coop', 'info',
'int', 'jobs', 'mobi', 'museum', 'name', 'net', 'org', 'post', 'pro',
'tel', 'travel', 'xxx', 'edu', 'gov', 'mil', 'nyc', 'ac',
'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar',
'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf',
'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv',
'no', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci',
'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cs', 'cu', 'cv', 'cx', 'cy',
'cz', 'dd', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg',
@abelsonlive
abelsonlive / meat_listener.py
Last active December 29, 2015 09:49
listen to the chat.meatspac.es socket
#!/usr/bin/python
# -*- coding: utf-8 -*-
from socketIO_client import SocketIO
ADDRESS = "https://chat.meatspac.es"
class MeatListener(object):
def __init__(self):
# connect to socket
@abelsonlive
abelsonlive / taskrabbit.py
Created November 24, 2013 08:04
# TaskRabbit Api Submit a json-formatted task to taskrabbit via python selenium
from selenium import webdriver
from datetime import datetime
import os, time
# TASK OBJECT
def taskrabbit(task):
"""
taskrabbit works by taking in a task dictionary with the following key value pairs: