Skip to content

Instantly share code, notes, and snippets.

View PavelVanecek's full-sized avatar

Pavel Vaněček PavelVanecek

View GitHub Profile
#!/bin/bash
# There are several options how to provide config to a Docker container during runtime.
# The idea is to allow flexibility in environment settings without knowing the application structure and without changing it.
# This gist shows how to configure database hostname.
# a) Pass as environment variables.
# Your script can read it too.
suite 'Constructor binding', ->
ConstructorFn = null
boundFn = null
spy = null
teardown ->
# cleanup global state after any failed tests
delete global.instanceProperty
#!/bin/bash
CONF_FILE=~/.aws/credentials
function usage {
echo "Export AWS API keys"
echo "Will read $CONF_FILE and export the api keys as environment variables"
echo "Usage: $0 --profile <profile>"
}
@PavelVanecek
PavelVanecek / avgcpuload.sh
Created August 29, 2013 14:35
A simple script to get average CPU load of a group of processes
#!/bin/bash
TMP_FILE=/tmp/cpuload
PNAME="node"
tries=0
while [ $tries -lt 100 ]
do
ps ax -o comm -o %cpu | grep $PNAME | awk '{s+=$2}END{print s}' | tee -a $TMP_FILE
sleep 1
@PavelVanecek
PavelVanecek / gist:5567350
Created May 13, 2013 10:12
A coffeescript function to trim sentence, while preserving full words
###*
@param {String} input
@param {number=} length
###
trimWithWordsPreserve = (input, length = 15) ->
if input.length <= length
input
else
regexp = new RegExp '^(.{' + length + '}[^\\s]*).*'
shorter = input.replace regexp, '$1'