Skip to content

Instantly share code, notes, and snippets.

@smj10j
smj10j / OnscreenKeyboardViewer.command
Created August 19, 2016 23:51
Opens the OSX Keyboard Viewer app without having to use the toolbar menu item
#!/usr/bin/env bash
(nohup /System/Library/Input\ Methods/KeyboardViewer.app/Contents/MacOS/KeyboardViewer &> /dev/null) &
sleep 3
exit
@smj10j
smj10j / privoxy-proxy.command
Last active August 18, 2016 20:45
Create an ad-hoc privoxy proxy
#!/bin/bash
# activate debugging
#set -x
# fail on any errors
set -e
INTERFACE=Wi-Fi
HOST=localhost
@smj10j
smj10j / http-proxy.template
Last active August 23, 2016 12:11
Create an ad-hoc http/https proxy on OSX
#!/usr/bin/env bash
##################################################################################
## Change extension to .command to allow execution by double-clicking in Finder ##
##################################################################################
# activate debugging
#set -x
# fail on any errors
@smj10j
smj10j / socks5-proxy.template
Last active August 23, 2016 12:12
Opens a quick SOCKS5 tunnel over SSH and configures OSX to use the proxy
#!/usr/bin/env bash
##################################################################################
## Change extension to .command to allow execution by double-clicking in Finder ##
##################################################################################
# activate debugging
#set -x
# fail on any errors
@smj10j
smj10j / tor-proxy.command
Last active August 12, 2016 04:52
Opens a quick SOCKS5 tunnel over Tor, starts Tor, and configures OSX to use the proxy
#!/bin/bash
# activate debugging
#set -x
# fail on any errors
set -e
INTERFACE=Wi-Fi
HOST=127.0.0.1
@smj10j
smj10j / download-facebook-photos.js
Created April 11, 2016 22:09
Download your Facebook photos in Chrome
// Fetch photo URLs
urlEls = jQuery('.fbPhotoStarGridElement')
urls = []
urlEls.each(function(i, el) {
url = $(el).attr('data-starred-src')
urls.push(url);
})
// Helper for downloading files with a specified filename
@smj10j
smj10j / show-terminal-profile-colors.sh
Created February 21, 2016 04:15
Outputs hex-encoded RGB values for the colors inside an OSX Terminal profile
/usr/libexec/PlistBuddy -x -c 'Print "Window Settings":"hullabaloo"' ~/Library/Preferences/com.apple.Terminal.plist\
|tr -d '\n\t'|grep -o '[^>]*</key><data>[^<]*'\
|while read l;do \
echo ${l%%<*} $(base64 -d<<<${l##*>}|plutil -convert xml1 - -o -\
|awk '/<data>/{getline;print}'|tr -d '\t'|base64 -d\
|xargs -d ' ' -n 1 echo | xargs -I VAL echo "obase=16; (255*VAL)/1" | bc)\
; done
@smj10j
smj10j / pagespeed.conf
Created February 19, 2016 04:38
Nginx conf for mod pagespeed
# Google Pagespeed
# https://developers.google.com/speed/pagespeed/module/configuration
pagespeed on;
pagespeed FileCachePath /var/cache/ngx_pagespeed/;
# let's speed up PageSpeed by storing it in the super duper fast memcached
pagespeed MemcachedThreads 1;
pagespeed MemcachedServers "127.0.0.1:11211";
# show half the users an optimized site, half the regular site
@smj10j
smj10j / install-nginx-pagespeed.sh
Last active February 19, 2016 15:56
Build script for builiding the nginx mod_pagespeed on Ubuntu 14.04
#!/bin/bash
# From: https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
set -e
NPS_VERSION=1.10.33.5
# check http://nginx.org/en/download.html for the latest version
NGINX_VERSION=1.8.1