Skip to content

Instantly share code, notes, and snippets.

View joshwnj's full-sized avatar

Josh Johnston joshwnj

View GitHub Profile
@joshwnj
joshwnj / socks.sh
Last active February 21, 2017 14:34
toggle osx socks proxy
#!/bin/bash
# source: http://richardkmiller.com/925/script-to-enabledisable-socks-proxy-on-mac-os-x
disable_proxy()
{
sudo networksetup -setsocksfirewallproxystate Wi-Fi off
echo "SOCKS proxy disabled."
}
trap disable_proxy INT
sudo networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 9999
;; Very quick hack to use `grasp` for searching js tokens in emacs.
;; Uses (compile) so when you get search results you can quickly step through them with (next-error) and (previous-error)
;; to install:
;; $ npm install -g grasp strip-ansi
(defun grasp-current-buffer (arg)
(interactive "MGrasp: ")
(compile (concat "grasp -H '" arg "' " (buffer-file-name) " | strip-ansi")))
alias encrypt="openssl enc -aes-256-cbc -a -salt"
alias decrypt="openssl enc -d -aes-256-cbc -a -salt"
@joshwnj
joshwnj / jslint
Last active December 14, 2015 03:19
Options for npm jslint
#!/bin/bash
/usr/local/share/npm/bin/jslint --browser --continue --devel --node --nomen --sloppy --vars --white --es5 false $@
@joshwnj
joshwnj / UrlShortener.php
Created February 14, 2013 09:21
using the bitly api
<?php
class UrlShortener {
const API_URL = 'http://api.bitly.com/v3/shorten';
private $_config;
function __construct ($config) {
$this->_config = $config;
}
####
## path
export PATH='$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/share/npm/bin'
####
## bash
alias ll='ls -halG'
@joshwnj
joshwnj / .osx
Created December 18, 2012 10:07
## source: https://github.com/hij1nx/dotfiles/blob/master/.osx
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
@joshwnj
joshwnj / nav.html
Created September 6, 2012 09:04
Create a select element from a bunch of links
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id="nav-select"></select>
<nav id="nav" class="nav" role="navigation">
@joshwnj
joshwnj / example.html
Created October 9, 2015 03:37
css modules + scoped styles?
<div>
<style scoped>
& {
background: #00F;
}
span {
color #FFF;
}
@joshwnj
joshwnj / files-from-month.sh
Created May 21, 2012 22:17
give me a list of files from the month of May 2011
## give me a list of files from the month of May 2011
ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /'
## move them to a separate directory
mkdir may-2011; ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /' | xargs -I {} mv {} may-2011/