Skip to content

Instantly share code, notes, and snippets.

View rolandcrosby's full-sized avatar

Roland Crosby rolandcrosby

View GitHub Profile
@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
{
"title": "Set up cmd and option on Nixeus keyboard",
"rules": [
{
"description": "[Nixeus] Change left cmd to option",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
{
"title": "Swap fn and left ctrl on internal keyboard",
"rules": [
{
"description": "Change fn to left ctrl",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
@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>
@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 / 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 / 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).