Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
@mdp
mdp / watch_folder.plist
Last active August 29, 2015 13:56
Watch a folder on mac and file off a script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>im.mdp.geeknote_watch</string>
<key>ProgramArguments</key>
<array>
<string>/Users/mdp/.geeknote/sync_notes.sh</string>
</array>
@mdp
mdp / .gitignore
Created January 22, 2014 18:24
Android Studio .gitignore file
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@mdp
mdp / npmpackage.md
Last active December 14, 2015 20:59
Inspect npm packages from the server
@mdp
mdp / README.md
Last active December 14, 2015 14:29

Keep and SSH tunnel up and running on OSX

This is my trick to keep a tunnel running on an OSX host. It's setup so that a network state change will trigger the connection. In practice I've found that it's actually very reliable. Certainly beats starting them by hand.

Notes

  • This uses a 'tunnel' user on your remote host. Because we need to start the tunnel with a passwordless ssh key, it's safer to use a key that just used for this purpose.
  • The remote tunnel user should not have priviledges to login. You only need them to be able to forward ports, shell login is not needed to do this.
@mdp
mdp / gist:5021845
Created February 23, 2013 23:32
Get your servers ssh host fingerprint
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
@mdp
mdp / gist:4982024
Last active December 13, 2015 22:08
Always exciting to see who's using Node - http://m.wsj.com/articles/a/?mg=reno64-wsj
* About to connect() to m.wsj.com port 80 (#0)
* Trying 128.241.216.177...
* connected
* Connected to m.wsj.com (128.241.216.177) port 80 (#0)
> GET /articles/a/?mg=reno64-wsj HTTP/1.1
> User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)
> Host: m.wsj.com
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
@mdp
mdp / EvernoteImport.scpt
Created February 11, 2013 20:16
Evernote auto import and delete
# Place in ~/Library/Scripts/Folder Action Scripts
# Right click on Folder, Folder Actions, EvernoteImport
on adding folder items to this_folder after receiving these_items
repeat with anItem from 1 to number of items in these_items
set this_item to item anItem of these_items
set the item_info to info for this_item
set the item_path to this_item as text
mkdir -p ~/.keys
cd ~/.keys
openssl genrsa -des3 -out private.pem 2048
openssl req -new -key private.pem -out cert.csr
openssl x509 -req -days 3650 -in cert.csr -signkey private.pem -out public.pem
When you need to encrypt a file
openssl smime -encrypt -binary -aes-256-cbc -in plainfile.zip -out encrypted.zip.enc -outform DER ~/.keys/public.pem
openssl smime -decrypt -binary -in encrypted.zip.enc -inform DER -out decrypted.zip -inkey ~/.keys/private.pem
@mdp
mdp / git.rake
Created May 23, 2012 01:39
Git branch cleaner upper
# Courtesy of @molily by way of @paulmillr
# CONFIG
UNTOUCHABLES = %w(master backstage staging production development)
class BranchList < Array
def self.from_command(command)
branch_list = self.new
command_result = `#{command}`
@mdp
mdp / Usage.coffee
Created May 10, 2012 21:28
Simple node queue
q = require './simple_q'
q.add
id: 422
action: "sendWelcomeEmail"
q.process 6, (data, done) ->
doSomethingWithData data, (err) ->
done(err)