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) {
@rolandcrosby
rolandcrosby / gist:c26571bf4e263f695d2f
Last active March 27, 2023 18:34
Convert rich text on the clipboard to Markdown
if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi
# for my .vimrc:
# command PasteMarkdown :read !if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi
# nnoremap ,pmd :PasteMarkdown<CR>
{
"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('&amp;', '&')
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
manufacturer model name width depth thickness weight screensize screenwidth screenheight
Lenovo 20KH002KUS X1 Carbon 6th Gen 12.73 8.54 0.62 2.49 14 2560 1440
Lenovo X1 Carbon 7th Gen 12.71 8.54 0.58 2.4 14 3840 2160
Apple A1466 MacBook Air 13" 2013 12.8 8.94 0.68 2.96 13.3 1440 900
Apple A1534 MacBook 12" 2017 11.04 7.74 0.52 2.03 12 2304 1440
Apple A1932 MacBook Air 13" 2018 11.97 8.36 0.61 2.75 13.3 2560 1600
Apple MacBook Air 13" 2020 11.97 8.36 0.63 2.8 13.3 2560 1600
Apple MacBook Pro 16" 2019 14.09 9.68 0.64 4.3 16 3072 1920
Dell 9380 XPS 13 2019 11.9 7.8 0.46 2.7 13.3 3840 2160
Dell XPS 13 2020 11.64 7.82 0.58 2.64 13.4 1920 1200
@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