Skip to content

Instantly share code, notes, and snippets.

View sdbondi's full-sized avatar

Stan Bondi sdbondi

View GitHub Profile
@sdbondi
sdbondi / new_host.sh
Created August 14, 2012 10:05
Add new host in local apache server
#!/bin/bash
function usage {
echo "Creates a new local virutal host."
echo "usage: newhost [-s] sitename"
echo "Parameters:"
echo " s : Create HTTPS virtual host as well."
}
function safename {
@sdbondi
sdbondi / gist:3348037
Created August 14, 2012 10:26
Control internet traffic when using a capped/restricted connection in Ubuntu/Debian
#!/bin/sh
# Thanks to Toby Kurien for this awesome trick
# Run this script then any applications launched from this terminal
# will have access to the internet, anything else will not be able to connect
# To create another terminal with the power of internet use 'sudo -g internet -s'
# NOTE: This script will create an "internet" group if one doesn't exist
# Firewall apps - only allow apps run from "internet" group to run
egrep -i "^internet$" /etc/group > /dev/null
if [ $? -ne 0 ]; then
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
@sdbondi
sdbondi / gist:8951499
Last active August 29, 2015 13:56
Create environment variables for docker containers on the host machine
#!/bin/bash
# Create environment variables for docker containers on the host machine
containers=(
"DB0:postgres"
"ES0:elasticsearch"
"REDIS0:redis"
)
@sdbondi
sdbondi / ngx-vhost-php-template
Created February 25, 2014 09:17
Setup virtual host for app in current directory using an ERB template.
server {
server_name <%= ENV['hostname'] %>;
access_log /var/log/nginx/nginx.access.log;
error_log /var/log/nginx/nginx.error.log;
default_type application/x-php;
root <%= ENV['app_root'] %>;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?it=$uri&$args;
AA: 'Afar'
AB: 'Abkhaz'
AE: 'Avestan'
AF: 'Afrikaans'
AK: 'Akan'
AM: 'Amharic'
AN: 'Aragonese'
AR: 'Arabic'
AS: 'Assamese'
AV: 'Avaric'
@sdbondi
sdbondi / config.inc.php
Last active August 29, 2015 13:58
Use PhpPgMyAdmin to detect your docker postgres instances
<?php
# phppgmyadmin/conf/config.inc.php
(...)
// Docker postgres connections
$server_i = 1;
$containers = explode("\n", trim(`docker ps`));
array_shift($containers);
foreach ($containers as $cid) {
if (!preg_match('/postgres/', $cid)) { continue; }
@sdbondi
sdbondi / gist:a6a9dc85c01cdf926dba
Last active August 29, 2015 14:02
Plugins for dokku
git clone https://github.com/statianzo/dokku-supervisord.git /var/lib/dokku/plugins/dokku-supervisord
dokku plugins-install
git clone https://github.com/scottatron/dokku-rebuild /var/lib/dokku/plugins/rebuild
dokku plugins-install
git clone https://github.com/musicglue/dokku-user-env-compile.git /var/lib/dokku/plugins/user-env-compile
dokku plugins-install
git clone https://github.com/mikexstudios/dokku-nginx-alt.git /var/lib/dokku/plugins/dokku-nginx-alt
@sdbondi
sdbondi / 0_reuse_code.js
Created June 30, 2014 07:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sdbondi
sdbondi / gist:1bea0d4bc60ddb9c76f8
Created September 4, 2014 12:18
Add 500ms delay to your localhost (useful for testing image upload progress)
# to add
tc qdisc add dev lo root netem delay 500ms
# to remove
tc qdisc delete dev lo root netem delay 500ms