Skip to content

Instantly share code, notes, and snippets.

View davidfmiller's full-sized avatar
💭
🤓

David Miller davidfmiller

💭
🤓
View GitHub Profile
@davidfmiller
davidfmiller / macos-bootstrap.sh
Last active July 17, 2017 21:20
macOS Bootstrap
#!/bin/sh
# Get your brand new Mac setup properly
# show full path in Finder title bar
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true; killall Finder
# show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder
@davidfmiller
davidfmiller / man-markdown.css
Last active January 1, 2021 15:58
BBEdit Markdown Preview CSS
@charset "UTF-8";
html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}#yui3-css-stamp.cssreset{display:none}
html {
background: #fff;
}
body {
background: #fff;
@davidfmiller
davidfmiller / NSXMLNode+StringForXPath.m
Created May 17, 2017 20:49
NSXMLNode+StringForXPath
#import "NSXMLNode+StringForXPath.h"
@implementation NSXMLNode (StringForXPath)
- (NSString *) stringForXPath:(NSString*)xpath
{
NSError *error;
NSArray *nodes = [self nodesForXPath:xpath error:&error];
if (error || nodes.count == 0)

Keybase proof

I hereby claim:

  • I am davidfmiller on github.
  • I am davidfmiller (https://keybase.io/davidfmiller) on keybase.
  • I have a public key ASAgTW_t_wT0QgKwfHaHdKfDho9YtpploXBeIIKgRckrzAo

To claim this, I am signing this object:

@davidfmiller
davidfmiller / element-scrollto.js
Created April 27, 2017 16:48
element-scrollto.js
/**
Smoothly scroll an element into the browser viewport
@param element {HTMLElement} - the element that which should be scrolled into the viewport
@param duration {Integer} - # of milliseconds the animation should take to complete
*/
var scroll = function (selector, duration) {
var
offset = function(element) {
@davidfmiller
davidfmiller / jshint-bbedit.applescript
Last active April 26, 2017 19:07
Pipe `jshint` output of BBEdit's current document into a BBEdit results window
(* https://readmeansrun.com *)
try
tell application "BBEdit"
set mydoc to file of (document 1 of window 1)
end tell
set posixPath to POSIX path of mydoc
if (posixPath ends with ".js" or posixPath ends with ".json") then
set cmd to "/usr/local/bin/node /usr/local/bin/jshint " & (quoted form of POSIX path of mydoc) & " | /usr/local/bin/bbresults -e --pattern '(?P<file>.+?):\\sline\\s(?P<line>\\d+),\\scol\\s((?P<col>\\d+),)?\\s+(?P<msg>.*)$'"
do shell script cmd
end if
@davidfmiller
davidfmiller / BBEdit Close Others.applescript
Last active April 7, 2017 00:58
Close Other Documents in Window
try
tell application "BBEdit"
set mywindow to window 1
set mydoc to (URL of document 1 of mywindow) as POSIX file
set alldocs to documents of mywindow
repeat with doc in alldocs
if ((((URL of doc) as POSIX file) as string) is equal to (mydoc as string)) then
-- active doc
else
@davidfmiller
davidfmiller / ubuntu-bootstrap.sh
Last active February 1, 2022 03:26
Ubuntu bootstrap
# https://www.linode.com/docs/security/use-public-key-authentication-with-ssh
# /etc/update-motd.d
mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/
# add node user
sudo adduser node
sudo adduser node sudo
# packages
@davidfmiller
davidfmiller / BBEdit → LaunchBar
Last active January 25, 2017 16:46
Send current BBEdit document to LaunchBar
try
tell application "BBEdit"
set mydoc to (URL of document 1 of window 1) as POSIX file
end tell
tell application "LaunchBar"
open mydoc
end tell
on error
beep
end try