Skip to content

Instantly share code, notes, and snippets.

@cjlyth
cjlyth / serve-dir
Created June 17, 2014 01:58
This gist can be used to serve a directory using the http-server nodejs module
#!/usr/bin/env bash
DATA_DIR="$( cd ${1:-.} && pwd )"
[[ -d "${DATA_DIR?}" ]] || {
echo "Unable to find directory: ${DATA_DIR}"
exit 1
}
CONTAINER_NAME="$(basename ${2:-${DATA_DIR}})"
docker restart ${CONTAINER_NAME?} &> /dev/null && {
echo "Docker container '${CONTAINER_NAME}' restarted"
} || {
@cjlyth
cjlyth / demo.html
Last active August 29, 2015 14:02
angular directive that sync's a model to a scope var using a custom control
<pre>{{myObj | json}}</pre>
<pre>{{myProperty | json}}</pre>
<input ng-model="myObj.myVal" type="text" ></test>
<input ng-model="myObjVal" type="text" ></test>
<div bind-property="myObjVal" ng-model="myObj.myVal"></div>
git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $commit | xargs tar -rf $commit.tar
@cjlyth
cjlyth / base16-build.sh
Created January 27, 2015 20:18
Base16 Build with Docker
git clone git@github.com:chriskempson/base16-builder.git
cd base16-builder
docker run -it --rm --name base16-builder \
-v "$(pwd)":/usr/src/base16-builder \
-w /usr/src/base16-builder \
ruby /usr/src/base16-builder/base16
@cjlyth
cjlyth / replace-all.sh
Created January 30, 2015 17:19
sed snippet to replace all regex matches in a string with som eother char
variable="a b a b a x x"
echo $variable
echo $variable | sed -r '/[^[:alnum:]]+/{s/[^[:alnum:]]/_/g}'
echo
@cjlyth
cjlyth / docker
Created February 3, 2015 18:29
/etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --storage-opt dm.basesize=50G"
db.zz_an02_cache.find({an02cacheKey:"8-70273186-1465091679-1434033220871"},{outletId:-1})
db.zz_an02_cache.aggregate( [
{ $match: { an02cacheKey: "1884586746-2-96337202-1434032093666" } }
, { $group: { _id: "$outletId" } }
] );
{ $group: { _id: "$state", totalPop: { $sum: "$pop" } } },
@cjlyth
cjlyth / mvn-change-version
Created April 26, 2016 20:52
change maven version without release
mvn versions:set -DnewVersion=0.0.3-SNAPSHOT

Keybase proof

I hereby claim:

  • I am cjlyth on github.
  • I am cjlyth (https://keybase.io/cjlyth) on keybase.
  • I have a public key whose fingerprint is 558D B27C D3F7 E078 DB84 46B0 4BFF 1A62 3465 7D7F

To claim this, I am signing this object:

@cjlyth
cjlyth / mkrole.sh
Last active May 22, 2018 13:03
Bash function to create Ansible roles following (current) best practices
# http://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout
mkrole()
{
dir_name=${1:-'common'}
mkdir -p roles/$dir_name/{tasks,handlers,templates,files,vars,defaults,meta}
touch roles/$dir_name/{tasks,handlers,vars,defaults,meta}/main.yml
}