Skip to content

Instantly share code, notes, and snippets.

@awolski
awolski / gist:9189680
Created February 24, 2014 14:49
Recursive delete in Linux
find . -name "*.java" -print0 | xargs -0 rm -rf
@awolski
awolski / gist:245fe470e70726e0049f
Created July 16, 2014 10:48
MySQL Schema Export & Import (Copy)
mysqldump -h 127.0.0.1 -u root -p database_name > export_file.sql
mysql -h 127.0.0.1 -u root -p
> create schema new_schema;
> exit
mysql -h 127.0.0.1 -u root -p new_schema < export_file.sql
@awolski
awolski / gist:4759d338c08287f7bef2
Created November 26, 2014 09:15
Remove old docker images
docker rm `docker ps --no-trunc -aq`
#!/usr/bin/env bash
function abort {
echo $1;
exit -1;
}
[ -z "$1" ] && abort "Please supply a node version."
VERSION=$1;
@awolski
awolski / gist:26c11a955503bbc220ac
Created December 2, 2015 23:50
Capturing groups using grep and sed
instanceName=$(grep "instanceName.*" $config | sed -e 's/.*: "\([a-zA-Z0-9\-]*\)",/\1/')
// Extracting some-name from a file $config containing this line
// "instanceName" : "some-name",
@awolski
awolski / gist:769e7045216f70766f84
Created December 30, 2015 15:31
Creating a basic authentication token from username:password on OS X
# stdin
echo -n 'username:password' | openssl base64
# file
openssl base64 -in auth.txt -out encoded.txt
@awolski
awolski / dependencies.sh
Created January 18, 2016 11:32
Bash script to list modules and all module versions in sinopia storage
#!/bin/bash
for d in */ ; do
echo "$d"
cd "$d"
for f in $(ls *.tgz) ; do
tempfile="${f##*/}";
echo " ${tempfile%.*}"
done
cd ..
@awolski
awolski / gist:4b19349a73deeb83a313
Created January 22, 2016 23:18
Get dynamically expose container port using docker inspect
docker inspect --format '{{ (index (index .NetworkSettings.Ports "8000/tcp") 0).HostPort }}' <containerid>
@awolski
awolski / getS3ObjectsWithNode.js
Created February 9, 2016 21:23
Node.js script to download s3 objects using aws-sdk, async and elegant-status
var async = require('async'),
AWS = require('aws-sdk'),
status = require("elegant-status"),
fs = require('fs'),
path = require('path'),
sh = require('shelljs');
var s3 = new AWS.S3();
async.series([
@awolski
awolski / README.md
Last active June 16, 2016 07:58
Command line tips and tricks

Unset multiple environment variables

unset ${!DOCKER_*}