Skip to content

Instantly share code, notes, and snippets.

View rolandcrosby's full-sized avatar

Roland Crosby rolandcrosby

View GitHub Profile
@rolandcrosby
rolandcrosby / mvim
Created May 19, 2015 12:09
single instance mvim script
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007. Some mediocre hacking by Paul Kehrer Sep 30 2009).
@rolandcrosby
rolandcrosby / pinstagram.js
Created May 25, 2015 16:38
Bookmarklet to pin to Pinterest from an Instagram web page
(
function() {
function getSrcUri() {
return window.location;
}
function getSrc() {
return document.getElementsByClassName('lfFrame')[0].getAttribute('src');
}
@rolandcrosby
rolandcrosby / instagramurl.js
Created June 20, 2015 16:00
get instagram url
(
function() {
function getSrc() {
var el = document.querySelector('div[role=dialog]');
if (el == null) {
el = document;
}
var media = el.querySelector('video');
if (media == null) {
{
"title": "Swap fn and left ctrl on internal keyboard",
"rules": [
{
"description": "Change fn to left ctrl",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
{
"title": "Set up cmd and option on Nixeus keyboard",
"rules": [
{
"description": "[Nixeus] Change left cmd to option",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
@rolandcrosby
rolandcrosby / sausage.rb
Created September 25, 2018 16:04
get place names and addresses from eater articles
t = open('sausage.html').read.gsub('&', '&')
matches = t.scan(/(?:<h3>([^<]*)<\/h3>)|<strong>([^<]*)<\/strong>\s*\(([^)]*)\)/)
def addr(str)
str.sub!(/,\s+(no phone|\d{3}-\d{3}-\d{4}).*/, '')
last = str.split(', ')[-1]
return str if last == "NJ"
return str + ", NY" if ["Brooklyn", "Queens", "Bronx", "Staten Island"].include? last
return str + ", New York, NY"
end
@rolandcrosby
rolandcrosby / co2.csv
Last active November 9, 2018 14:41
co2/temp anomaly data for coffee stain plot
year ppm
1679 276.712
1680 276.669
1681 276.627
1682 276.587
1683 276.549
1684 276.512
1685 276.478
1686 276.447
1687 276.418
@rolandcrosby
rolandcrosby / twittermedia.sh
Created December 2, 2018 22:46
get recent media posted by a twitter user
#!/bin/bash
set -eu
set -o pipefail
screen_name=$1
twurl "/1.1/statuses/user_timeline.json?screen_name=$screen_name&trim_user=true&exclude_replies=true&count=200&include_rts=false" |
jq -r '.[]
| select(.extended_entities.media != null)
| .id_str as $tweet_id
| .extended_entities.media
@rolandcrosby
rolandcrosby / csvfix.py
Last active December 12, 2018 21:05
csv preprocessor
import sys
# CSV cleaner-upper to change CRLF terminations to LF, and to avoid quoting empty strings
# inspired by https://github.com/mhus/mhus-lib/blob/master/mhu-lib-core/src/main/java/de/mhus/lib/core/io/CSVReader.java
# usage: python csvfix.py < in.csv > out.csv
def parse_field(char, state="start", acc=""): # returns (new_state, new_acc)
if state == "start":
if char == ",":
return ("eof_u", acc)
@rolandcrosby
rolandcrosby / twitter-archive-search.sh
Created January 26, 2019 18:22
search your twitter archives
#!/usr/bin/env bash
# expects you to have your twitter archive folders in $dir
# with folder names like "acct1 2019-01-26" so they sort nicely
set -euo pipefail
dir='path/to/archives'
accts='acct1 acct2'
query="$*"