Skip to content

Instantly share code, notes, and snippets.

View erkiesken's full-sized avatar

Erki Esken erkiesken

  • @StarshipRobots
  • Tallinn, Estonia
View GitHub Profile

Keybase proof

I hereby claim:

  • I am erkiesken on github.
  • I am erkiesken (https://keybase.io/erkiesken) on keybase.
  • I have a public key whose fingerprint is B2EB 926A 8B2A FA6D E919 BAA8 DFA5 3336 298B D2E4

To claim this, I am signing this object:

@erkiesken
erkiesken / sudo_something.sh
Created May 20, 2016 12:00
redirecting output of sudo command
# Can;t just do this, no permission for my shell to write that file:
sudo echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list
# So wrap it into a shell command:
sudo sh -c 'echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list'
@erkiesken
erkiesken / sample.sh
Created May 17, 2016 14:49
Pass vars from .env file to an executing program
#!/bin/bash
# From http://stackoverflow.com/a/20909045/49871
#
# Keeps the variables local
#
env $(cat .env | xargs) myprogram
@erkiesken
erkiesken / test-tee-logging.sh
Created April 22, 2016 12:52
Bash script output to stdout and teed to a file
#!/bin/bash
set -exuo pipefail
# Taken from https://alestic.com/2010/12/ec2-user-data-output/
exec > >(tee ./tmp.log) 2>&1
echo BEGIN
ls -lah .
echo END
@erkiesken
erkiesken / check-gravatar.sh
Created April 5, 2016 10:03
Counting default vs custom Gravatars
#!/bin/bash
set -euo pipefail
mkdir -p out
while read -r hash; do
if [ ! -f "out/$hash" ]; then
curl -I -s -o "out/$hash" "http://www.gravatar.com/avatar/$hash"
echo "Fetched: $hash"
@erkiesken
erkiesken / bump-version.sh
Created April 4, 2016 15:25
Simple version bumper using node-semver
#!/bin/bash
##
## Bumps semantic version using node-semver.
##
## Usage:
## ./bump-version.sh <level> <file>
##
## <level> can be: major, minor, patch,
## premajor, preminor,
@erkiesken
erkiesken / check_node_npm.sh
Last active March 17, 2016 09:32
Checking node/npm versions based on package.json
#!/bin/sh
set -e
# Needs node, npm, semver (npm -g i semver) and jq utility to be installed.
# First check if we have needed utils.
which node
which npm
which jq
@erkiesken
erkiesken / node-repl-inspect-customInspect.md
Last active February 24, 2016 20:51
Disabling node repl util.inspect customInspect

When objects implement inspect method but its not meant for inspection then problems might occur.

For example with rxjs package:

> Rx = require("rxjs/Rx")
{ Subject: { [Function: Subject] create: [Function] },
  Observable:
…
@erkiesken
erkiesken / README haproxy letsencrypt
Last active January 5, 2016 10:01
haproxy letsencrypt automation
From article:
https://blog.brixit.nl/automating-letsencrypt-and-haproxy
@erkiesken
erkiesken / heka-output
Created May 8, 2015 16:02
Simple Heka HttpListenInput debug output
2015/05/08 19:01:30 Input 'http-input': Listening on 127.0.0.1:1234
2015/05/08 19:01:36
:Timestamp: 2015-05-08 16:01:36.03994348 +0000 UTC
:Type: heka.httpdata.request
:Hostname: Erki-Mac.lan
:Pid: 83675
:Uuid: 0ad67214-8f54-4793-8e33-ba1563071db7
:Logger: http-input
:Payload: {"foo": "bar"}
:EnvVersion: 1