Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
@cicorias
cicorias / dcsl
Created September 4, 2017 23:28 — forked from sheershoff/dcsl
Docker-compose logs sorted by time
#!/bin/bash
usage="Input piped docker-compose logs -t, or a file created from this command, to show logs lines sorted by time.\n\n Usage:\n\n $(basename "$0") [-h|--help] - this message\n $(basename "$0") - runs default docker-compose logs -t and sorts'em\n docker-compose logs -t|$(basename "$0") - pipe logs to this command\n $(basename "$0") my-compose.log - or choose file with logs to display\n\n"
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
case "$1" in
-h|--help) printf "$usage"
exit
;;
esac
if [ -t 0 ]; then
docker-compose logs -t|sort -t "|" -k +2d
@cicorias
cicorias / git_notes.md
Created August 30, 2017 11:03 — forked from jaygooby/git_notes.md
Git, you bloody git

Push all branches to new remote

If you've added a new remote, you might want to push all your branches to it:

git push new-remote --all

View log in different branch

Maybe you want to cherry-pick from a different branch and you need to know the commit hash:

function exponentialBackoff(toTry, max, delay, callback) {
new Promise(function(resolve, reject) {
// do a thing then…
var ret = toTry.toString();
ret = ret.substr('function '.length);
ret = ret.substr(0, ret.indexOf('('));
console.log('EB '+ret+' max',max,'next delay',delay);
var result = toTry();
if (result) {
# From PowerShell ADMINISTRATOR session run
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
# Open new PowerSheel Administrator session and run
# $cred=Get-Credential domain\username (can also use [email protected] MSA style username)
# Install-BoxstarterPackage -PackageName https://gist.githubusercontent.com/tylergibson/bd7a4c923db6bc0bd0a3ca05473dd4f7/raw -Credential $cred
# Initialize reboot log file
$reboot_log = "C:\installation.rbt"
if ( -not (Test-Path $reboot_log) ) { New-Item $reboot_log -type file }
@cicorias
cicorias / expbackoff.sh
Created June 14, 2017 17:28 — forked from nathforge/expbackoff.sh
Exponential backoff in Bash
expbackoff() {
# Exponential backoff: retries a command upon failure, scaling up the delay between retries.
# Example: "expbackoff my_command --with --some --args --maybe"
local MAX_RETRIES=${EXPBACKOFF_MAX_RETRIES:-8} # Max number of retries
local BASE=${EXPBACKOFF_BASE:-1} # Base value for backoff calculation
local MAX=${EXPBACKOFF_MAX:-300} # Max value for backoff calculation
local FAILURES=0
while ! "$@"; do
FAILURES=$(( $FAILURES + 1 ))
if (( $FAILURES > $MAX_RETRIES )); then
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"eventHubName": {
"type": "string"
}
},
"variables": {
"resourceLocation": "[resourceGroup().location]",
@cicorias
cicorias / azuredeploy.json
Created May 28, 2017 16:18 — forked from christopheranderson/azuredeploy.json
Function App ARM template with MSDeploy
{
"$schema": "http://schemas.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
@cicorias
cicorias / static_server.js
Created May 21, 2017 03:26 — forked from amejiarosario/static_server.js
Node.js quick file server (static files over HTTP) using es6+
const http = require('http');
const url = require('url');
const fs = require('fs');
const path = require('path');
const port = process.argv[2] || 9000;
http.createServer(function (req, res) {
console.log(`${req.method} ${req.url}`);
// parse URL
@cicorias
cicorias / Object Flatten
Created March 30, 2017 21:56 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@cicorias
cicorias / alternate.sh
Last active March 30, 2017 15:40 — forked from madis/gist:4650014
Testing CORS OPTIONS request with curl
curl -H "Origin: http://example.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: X-Requested-With" \
-X OPTIONS --verbose \
http://localhost:8545