Skip to content

Instantly share code, notes, and snippets.

View apexskier's full-sized avatar

Cameron Little apexskier

View GitHub Profile
@apexskier
apexskier / example.txt
Last active January 11, 2018 17:19
Tagged Template Literal URI library
$ node
> uri = require("./tturi")
[Function: uri]
> base = uri`https://api.example.com`
{ [Function: uriInstance] toString: [Function], toParameterizedPath: [Function] }
> t = base`/payment_profiles/${() => "someid"}/mutate/${{param: "value"}}`
{ [Function: uriInstance] toString: [Function], toParameterizedPath: [Function] }
> t.toString()
'https://api.example.com/payment_profiles/someid/mutate/?param=value'
> t.toParameterizedPath()
#!/bin/bash
set -e
# day of week (1..7); 1 is Monday
exit $(test "$(date +%u)" -le "5")
@apexskier
apexskier / {HOSTNAME}.conf
Created December 31, 2016 23:03
nginx configuration
# location: /etc/nginx/sites-available/{HOSTNAME}
server {
listen 443 ssl;
server_name {HOSTNAME};
ssl_certificate /etc/letsencrypt/live/{HOSTNAME}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{HOSTNAME}/privkey.pem;
@apexskier
apexskier / README.md
Last active September 22, 2016 21:47
Cameron's Guide to SVGs in Sketch

We want

  • Crisp edges
  • Small files
  • The ability to animate and tweak with CSS and javascript

To do this...

  • Flatten paths/groups/objects as much as possible
  • Pixel align everything (position/borders/points)
  • Don't use a border set to center positioning unless the thickness is even
  • Create tidy and well named groups
@apexskier
apexskier / README.md
Last active July 7, 2017 22:18
changelog emoji

Deployment Emoji Guide

I like to prepend each line of the list of changes in a deployment note with an emoji. This adds something that can be scanned without reading to deployment notes and emails to get a quick idea of what the deployment's about (bugfixes, new features, ...).

  • 🐛 Bugfix
  • ✨ New feature
  • 🐎 Performance improvement
@apexskier
apexskier / no-whitespace.js
Created November 5, 2015 22:32
View GitHub diffs without whitespace changes
// Like git's --no-whitespace flag
(function() {
if (location.origin === 'https://github.com') {
const search = location.search;
if (search) {
const params = search.substring(1).split('&').map(p => p.split('='));
if (!params.find(p => p[0] == 'w')) {
location.search = location.search + '&w=1';
} else {
@apexskier
apexskier / switch-base.js
Last active October 15, 2015 21:23
GitHub Switch Base Bookmarklet
// Switch base and head when comparing branchs/forks on GitHub
// https://github.com/apexskier/portal/compare/master...apexskier:css-gulp-2?expand=1
(function() {
if (location.origin === 'https://github.com') {
var match = /^\/(\S+)\/(\S+)\/compare\/(\S+)\.\.\.(\S+):(\S+)$/.exec(location.pathname);
if (match) {
location.pathname = `/${match[4]}/${match[2]}/compare/${match[5]}...${match[1]}:${match[3]}`;
} else {
match = /^\/(\S+)\/(\S+)\/compare\/(\S+)\.\.\.(\S+)$/.exec(location.pathname);
@apexskier
apexskier / c.py
Last active August 29, 2015 14:08 — forked from shortenda/py.c
#include <stdio.h>
#define print puts
#define exit return
#define pass }
#define one \
if __name__ == "__main__":
#define two "\
"""
int main(int argc, char ** argv) {
@apexskier
apexskier / fab
Last active August 29, 2015 14:07
#!bash
#
# bash/zsh completion support for Fabric
#
# Copyright (C) 2013 Danilo Dellaquila <danilo@dellaquila.es>
# 2014 Cameron Little <cameron@camlittle.com>
# Distributed under the GNU General Public License, version 3.0.
# http://www.gnu.org/licenses/gpl.html
#
# To install just save the script at /etc/bash_completion.d or
@apexskier
apexskier / cleanup.bash
Last active May 8, 2017 18:45
Dokuwiki Clean up
#!/usr/local/bin/bash
# find all files that should be start pages
for dir in `find . -type d`
do
file="${dir}.txt"
if [ `ls "${dir}.txt" 2> /dev/null ` ]
then
# generate the link to the file
dokulink=$(sed "s|^\./\(.*\)\.txt|\1|" <<< "${file}" | sed "s|/|:|g")