Skip to content

Instantly share code, notes, and snippets.

View superstructor's full-sized avatar
🎯
Focusing

Isaac Johnston superstructor

🎯
Focusing
View GitHub Profile
@superstructor
superstructor / gist:5754903
Last active December 18, 2015 08:29
"/rels/delete" could tell the client "this is the link to follow to delete the context resource", whereas "/profiles/delete" could tell the client that to do so you DELETE /api/customer/42 ? Since there is no entity body the generic /profiles/delete provides enough semantics for any resource i.e. just use the DELETE method. "/rels/update-form" c…
{
"_links": {
"self": {
"href": "/api/customers/42"
},
"profile": {
"href": "/profiles/customer"
},
"/rels/delete": {
"href": "/api/customers/42",
@superstructor
superstructor / gist:5754905
Created June 11, 2013 06:47
Or for a coffee order maybe consider that the order and the payment could be independent resources, thus you get
{
"_links": {
"self": {
"href": "/api/orders/123"
},
"profile": {
"href": "/profiles/order"
}
"/rels/payments": {
"href": "/api/orders/123/payments",
// This systemd runs iptables-restore on boot:
[Unit]
Description=Packet Filtering Framework
DefaultDependencies=no
After=systemd-sysctl.service
Before=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore /opt/docker/scripts/iptables/iptables.rules
function errexit() {
local err=$?
set +o xtrace
local code="${1:-1}"
echo "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err"
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
echo "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
@superstructor
superstructor / gist:765df8bd2eddb02d21eb
Created September 14, 2014 09:58
etcd+git install via Docker
#!/bin/bash
docker run -v /opt/bin:/opt/bin --rm quay.io/joukou/golang /bin/bash -c "git clone https://github.com/coreos/etcd.git && cd etcd && ./build && cp bin/etcd /opt/bin"
[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit
logola = log --graph --decorate --pretty=oneline --abbrev-commit --all
[user]
name = Isaac Johnston
email = isaac.johnston@joukou.com
[core]
excludesfile = /Users/isaac/.gitignore_global
editor = vim
[color]

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

Docker stats collection for collectd

This script can be used to feed collectd with cpu and memory usage statistics for running docker containers using the collectd exec plugin.

This script will report the used and cached memory as well as the user and system cpu usage by inspecting the appropriate cgroup stat file for each running container.

Usage

This script is intented to be executed by collectd on a host with running docker containers. To use, simply configure the exec plugin in collectd to execute the collectd-docker.sh script. You may need to adjust the script to match your particulars, such as the mount location for cgroup.

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@superstructor
superstructor / README.md
Last active June 13, 2019 03:54
shadow-cljs

shadow-cljs Notes

Use as a library with Leiningen, not the default Node.js CLI. This is because lein has a lot of other stuff the Node.js CLI does not; e.g.

  • garden CSS compilation
  • publishing to Clojars
  • lein ancient
  • lein deps :tree

When used as a library with lein, dependencies and source paths in shadow-cljs.edn are ignored.