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 / wait_browser.py
Last active June 18, 2019 16:12
Waiting For responses in selenium
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
class WaitBrowser(object):
def __init__(self, **kw):
self.browser = webdriver.PhantomJS()
def readystate_complete(self):
@abelsonlive
abelsonlive / mongo_import.sh
Created November 17, 2012 09:36
import csv into mongodb from command line
#!/usr/bin/bash
## include --upsert if adding to a prexistitng collection
mongoimport -d db_name -c coll_name --type csv --file file.csv --headerline
@abelsonlive
abelsonlive / cosine_similarity.R
Last active August 20, 2018 13:38
Cosine Distance Recommendation / Collaborative Filtering Example
# lets make some dummy data
n_rows <- 1000
n_cols <- 100
mat <- matrix(0, nrow=n_rows, ncol=n_cols)
mat <- apply(mat, 2, function(x) { return(rbinom(n_rows, size=1, prob=0.1))})
colnames(mat) <- paste0("event", 1:n_cols)
rownames(mat) <- paste0("pol", 1:n_rows)
# lets take a look at it before we do some math
head(mat)
@abelsonlive
abelsonlive / dot-cat.sh
Last active May 11, 2018 08:03
dot-cat.sh
#!/bin/sh
curl http://cat.www.$1.com.meowbify.com/ > index.html
s3cmd put index.html s3://$1.cat/
@abelsonlive
abelsonlive / phase-say.py
Created April 14, 2018 05:14
generative phase music with say
import os
import sys
import time
import random
VOICES = [
"Agnes",
"Alex",
"Alice",
"Alva",
@abelsonlive
abelsonlive / thai-spicy.txt
Created January 23, 2018 17:40
thai spicy instructions
thai spicy เผ็ดร้อนไทย, pik nam pla (พริกน้ำปลา) on the side
@abelsonlive
abelsonlive / entarteur.py
Created December 5, 2012 05:35
use facepy for facebook feed dumps
from facepy import GraphAPI
import facepy
import re
import json
#meta variables
access_token = 'your_token'
page_id = 'the_page' # input page id here
base_query = page_id + '/feed?limit=300'
import requests
import urllib
import json
ZIP_CODES = [
'11211'
]
def get_rect_from_zip(session, zip_code):
"""
@abelsonlive
abelsonlive / gist:9822089
Created March 28, 2014 00:11
put this in `etc/conf` ... redirect facebook to nytimes' ip address
170.149.168.130 www.facebook.com
170.149.168.130 facebook.com
170.149.168.130 static.ak.fbcdn.net
170.149.168.130 www.static.ak.fbcdn.net
170.149.168.130 login.facebook.com
170.149.168.130 www.login.facebook.com
170.149.168.130 fbcdn.net
170.149.168.130 www.fbcdn.net
170.149.168.130 fbcdn.com
170.149.168.130 www.fbcdn.com
@abelsonlive
abelsonlive / getInsights.R
Created May 27, 2012 20:09
getInsights - an R API for Google Insights
#see below for query specifications
getInsights <- function(
username = "Insights4R@gmail.com",
password = "googleinsights4r",
text_query = "'hello world'",
date_query = "1/2004 108m",
geo_query = "US",
search_type= "all",
filter_category="none"){