Skip to content

Instantly share code, notes, and snippets.


Aaron Alfson aalfson

View GitHub Profile
david-torres / db_exists.js
Last active Mar 1, 2018
[mongo db_exists command] MongoDB command to check if a database exists. I use it with a puppet script to conditionally load up a database dump if one isn't detected. Useful for provisioning Vagrant. Returns with exit code zero if the database was found. #mongodb
View db_exists.js
function db_exists(db_name) {
db = db.getSiblingDB('admin');
if ( == db_name) {
// quit with exit code zero if we found our db
// quit with exit code 1 if db was not found
epicserve /
Last active Dec 28, 2022
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License:
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
View nginx.puma.conf
upstream myapp {
server unix:///myapp/tmp/puma.sock;
server {
listen 80;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in