Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
@jaymecd
jaymecd / reinvent.md
Created November 16, 2017 20:07 — forked from henrysher/reinvent.md
link for reinvent slides
@jaymecd
jaymecd / Makefile
Created October 13, 2017 08:43 — forked from mcastilho/Makefile
Makefile for Medium article
.PHONY: all tags clean test build install generate image release
REGISTRY_REPO = <..redacted..>
OK_COLOR=\033[32;01m
NO_COLOR=\033[0m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
# Build Flags
@jaymecd
jaymecd / snake_camel.sh
Created September 28, 2017 19:09
replace snake-case with camel-case in file
#!/usr/bin/env bash
set -eo pipefail
SNAKE="${1:-}"
[ -n "${SNAKE//}" ] || {
echo >&2 "provide snake case string"
exit 2
}
@jaymecd
jaymecd / include_covers.sh
Last active September 28, 2017 12:50
include covers annotation to the php class files
#!/usr/bin/env bash
#
# include_covers.sh test/unit/My/Path/To/TheTest.php
#
set -eo pipefail
WRITE="${WRITE:-}"
FILE="${1:-}"
@jaymecd
jaymecd / README.md
Created September 22, 2017 10:29 — forked from brandt/README.md
Creates a loopback alias with IP 127.0.0.2 at startup on Mac OS X

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP 127.0.0.2 on macOS.

Installation

  1. Install the plist to: /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  2. Set mode: sudo chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  3. Set owner: sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  4. Load: sudo launchctl load /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
@jaymecd
jaymecd / build_caddy.sh
Last active October 27, 2017 20:26
Build Caddy w/ plugins from sources
#!/usr/bin/env bash
#
# Author: @nikolaizujev
#
# Big respect to @mholt6 for making Caddy
#
# This script is based on:
# - https://www.calhoun.io/building-caddy-server-from-source/
# - https://g.liams.io/liam/simple-build-caddy.git
#
@jaymecd
jaymecd / gist:32903e1cc9ac1c8e9aa415b25f95c646
Created September 12, 2017 17:45 — forked from telent/gist:9742059
12 factor app configuration vs leaking environment variables
App configuration in environment variables: for and against
For (some of these as per the 12 factor principles)
1) they are are easy to change between deploys without changing any code
2) unlike config files, there is little chance of them being checked
into the code repo accidentally
3) unlike custom config files, or other config mechanisms such as Java
@jaymecd
jaymecd / brew-go-get
Created August 27, 2017 19:55
OSX brew-like GO apps install
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: brew-go-get github.com/foo/bar ..."
exit 1
fi
NAME=$(basename "${1}")
<?php
$formatter = \NumberFormatter::create($locale, \NumberFormatter::CURRENCY);
if ('en' === $this->formatter->getLocale(\Locale::ACTUAL_LOCALE)) {
// use non-breakable space (U+00A0) as delimiter
$formatter->setPattern(str_replace('¤#', "¤\u{00A0}#", $formatter->getPattern()));
}
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $fraction ?? 2);
@jaymecd
jaymecd / jo_json_cli.md
Created June 16, 2017 12:22
jo json from cli

Run https://github.com/jpmens/jo to generate JSON structure:

$ jo -p ref=ref-123 title="my title" items=$(jo -a $(jo ref=item-1 title=item points=$(jo -a $(jo label=point-1 x=1.1 y=1.1) $(jo label=point-2 x=1.2 y=1.2))))

Output:

{