Skip to content

Instantly share code, notes, and snippets.

@johnagan
johnagan / auth.test.json
Last active April 29, 2017 18:50
OAuth Medium post snippets
{
"ok": true,
"url": "https:\/\/myteam.slack.com\/",
"team": "My Team",
"user": "cal",
"team_id": "T12345",
"user_id": "U12345"
}
@johnagan
johnagan / server.rb
Last active February 14, 2016 04:15
require 'net/http'
require 'sinatra'
require 'json'
require 'uri'
CONTEXT = "spoof check"
GITHUB_ROOT = "https://api.github.com"
HEADERS = {
'Content-Type' => 'text/json',
'Authorization' => "token #{ENV['GITHUB_TOKEN']}"
@johnagan
johnagan / html2slim.rb
Last active December 20, 2015 11:19
HTML2Slim
require 'html2slim'
html_path = ""
slim_path = ""
Dir.mkdir(slim_path) unless File.exists?(slim_path)
Dir["#{html_path}/*.html"].each do |file_name|
html = File.read(file_name).encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
File.open("#{slim_path}/#{File.basename(file_name)}.slim", 'w') do |f|
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
color: #333;
}
#!/bin/bash
disable_proxy()
{
networksetup -setsocksfirewallproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Ethernet off
echo "SOCKS proxy disabled."
}
trap disable_proxy INT
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 9999
# Usage
# git config --global core.excludesfile ~/.global_ignore
# General ------------------------------
*.psd
# OSX ----------------------------------
.DS_Store
@johnagan
johnagan / githook.sh
Created May 22, 2011 22:55
A sample git hook to update webroot on commit
# Bring in Source Control
mkdir ~/repo
cd ~/repo
git init --bare
# Create a git hook
cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/www