Skip to content

Instantly share code, notes, and snippets.

View longlostnick's full-sized avatar

Nick Larson longlostnick

View GitHub Profile
@longlostnick
longlostnick / .bashrc
Created March 19, 2016 04:19 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@longlostnick
longlostnick / values_pointers.go
Created April 5, 2016 06:50 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Hillary", 28} stores the value
@longlostnick
longlostnick / migrate_redis.rb
Created June 27, 2016 23:51
Migrate redis key/values by key match
require 'redis'
redisSrc = Redis.connect url: "redis://<src>:6379"
redisDest = Redis.connect url: "redis://<dest>:6379"
redisSrc.keys("*").each do |key|
begin
data = redisSrc.dump key
ttl = redisSrc.pttl key # milleseconds
redisDest.restore key, ttl, data

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@longlostnick
longlostnick / oauth_dance.rb
Created August 27, 2016 19:29
Quick script for OAuth2 dancin'
require 'oauth2'
client_id = ''
client_secret = ''
login_server = 'https://test.salesforce.com'
redirect_uri = 'https://login.salesforce.com/services/oauth2/callback'
client = OAuth2::Client.new(
client_id,
client_secret,
@longlostnick
longlostnick / splunk_to_slack.js
Created February 10, 2017 01:35
Transform a Splunk webhook and send to Slack
var util = require("util");
var https = require("https");
var title_template = "Alert - <%s|%s>";
var body_template = "\`\`\`%s\`\`\`";
var request_options = {
hostname: 'hooks.slack.com',
path: '<slack_url>',
method: 'POST',
@longlostnick
longlostnick / log_exceptions.rb
Created May 12, 2017 21:23
Ruby logger helper method for friendly logging of exceptions with stack trace.
class Logger
def exception(e, level=:error)
self.send level, "#{e.inspect} #{e.message}"
self.send level, " #{e.backtrace.first(25).join("\n ")}"
end
end
@longlostnick
longlostnick / Dockerfile
Created August 6, 2017 21:51 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@longlostnick
longlostnick / page_scraper.py
Last active August 10, 2017 18:18
Scrape a list of urls from a file
import io
import urllib.request
opener = urllib.request.FancyURLopener({})
pages_to_scrape = []
file = open("/Users/<user>/Downloads/random_slugs.txt", "r")
pages_to_scrape = file.readlines()
for url in pages_to_scrape:
@longlostnick
longlostnick / authorized_keys.md
Last active October 30, 2017 05:40
Simple set of bash scripts for uploading public keys to remote servers via GitHub usernames

authorized_keys

A method for managing and giving team members access to remote servers without needing to pass around the master .pem key. Generates and sends authorized key files to a list of hosts based on a set of permissions.

fetch_keys_from_github.sh

Generates a new keys/*.txt file for each user defined in permissions.txt when one doesn't already exist. Gets the list by calling out to https://github.com/<user>.keys. After first fetching a set of keys, the list can be paired down if necessary before running upload_keys.sh.

./fetch_keys_from_github.sh