Skip to content

Instantly share code, notes, and snippets.

@cjlyth
cjlyth / colors.sh
Last active September 29, 2022 00:51
Shell script to start my docker containers while im developing
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ -f "$DIR/colors.tput.sh" ]] && {
source "$DIR/colors.tput.sh"
} || {
echo "Unable to find file: $DIR/colors.tput.sh"
exit 1
}
reset="$(color)"
@cjlyth
cjlyth / dev-instance-userdata.sh
Last active November 2, 2019 07:14
dev-instance-userdata.sh
#!/usr/bin/env bash
yum update -y
yum groupinstall "Development Tools" -y
sudo -u ec2-user git config --global credential.helper '!aws codecommit credential-helper $@'
sudo -u ec2-user git config --global credential.UseHttpPath true
# Borrowed from https://forums.aws.amazon.com/thread.jspa?messageID=911050
echo "Setting up NodeJS Environment"
@cjlyth
cjlyth / core-install-script.sh
Created August 10, 2018 21:31
CoreOS install script for a vmware instance
#!/usr/bin/env bash
# thanks to this gist for getting me started
# https://gist.github.com/noonat/9fc170ea0c6ddea69c58
curl https://api.github.com/users/cjlyth/keys \
| grep -oe 'ssh-rsa[^""]*' \
>> ~/.ssh/authorized_keys
echo -e "#cloud-config\nssh_authorized_keys:\n$(sed 's/^/ - /' ~/.ssh/authorized_keys)" \
> ~/cloud-config.yaml
@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
}

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 / mvn-change-version
Created April 26, 2016 20:52
change maven version without release
mvn versions:set -DnewVersion=0.0.3-SNAPSHOT
@cjlyth
cjlyth / cors.js
Created November 19, 2013 20:43
CORS support for express
api.all('*', function(req, res, next){
if (!req.get('Origin')) return next();
// use "*" here to accept any origin
res.set('Access-Control-Allow-Origin', 'http://localhost:3000');
res.set('Access-Control-Allow-Methods', 'GET, POST');
res.set('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
// res.set('Access-Control-Allow-Max-Age', 3600);
if ('OPTIONS' == req.method) return res.send(200);
next();
@cjlyth
cjlyth / .profile
Created October 22, 2013 23:19
NVM load script, include this in .profile instead of the one they package
hash nvm 2>/dev/null
if [ "$?" == "1" ]; then
if [ -f "$HOME/.nvm/nvm.sh" ]; then
. $HOME/.nvm/nvm.sh
if [ -f "$HOME/.nvm/bash_completion" ]; then
. $HOME/.nvm/bash_completion
fi
fi
fi
@cjlyth
cjlyth / json.awk
Created October 18, 2013 22:58
gawk script to flatten and read a javascript object, built for a small use case that involved reading a node.js package.json
#!/usr/bin/gawk -f
BEGIN {
RS="(\"*[[:alnum:]*]\"[ \t]*:[ \t]*)?\"*[ \t]*(,|{)+[ \t]*|\n[ \t]+\"|(\"[[:alnum:]*]\"[ \t]*:[ \t]*)?{|\"+[\n]+";
FS="\"[ \t]*:[ \t]*|\"?[ \t]*:[ \t]*\"";
column_format ="| %-39s";
cols = 0; rows = 0;
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" } } },