Skip to content

Instantly share code, notes, and snippets.

@whitekid
whitekid / python-simple-webserver.sh
Created October 29, 2013 16:02
just on line python web server
#!/bin/bash
python -m SimpleHTTPServer
@whitekid
whitekid / get_vip_from_fixed_ip.py
Last active December 28, 2015 23:08
fixed ip를 기준으로 해당 인스턴스 연결된 vip 찾아내기
from quantumclient.v2_0.client import Client
def get_vip_from_fixed_ip(fixed_ip):
client = Client(
username = app.config['USERNAME'],
password = app.config['PASSWORD'],
tenant_name = app.config['TENANT_NAME'],
auth_url = app.config['AUTH_URL']
)
members = client.list_members(address = fixed_ip)['members']
#!/bin/bash
# Get current swap usage for all running processes
#
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
#!/bin/sh
sync; echo 3 > /proc/sys/vm/drop_caches
@whitekid
whitekid / os-ovs-vif-update.sh
Created February 11, 2014 19:55
LibvirtHybridOVSBridgeDriver로 구성된 ovs port 구성을 LibvirtOpenVswitchDriver 구성으로 모두 변경하는 스크립트...
#!/bin/bash
for device in `ovs-vsctl list-ports br-int | grep ^qvo`; do
dev=${device:3}
echo $device
prop=`ovs-vsctl -- --columns=external_ids list Interface ${device}`
mac=`echo "$prop" | sed 's/.*attached-mac="\([a-z0-9:]*\).*/\1/g'`
iface_id=`echo "$prop" | sed 's/.*iface-id="\([a-z0-9-]*\).*/\1/g'`
iface_status=`echo "$prop" | sed 's/.*iface-status=\([a-z]*\).*/\1/g'`
@whitekid
whitekid / gs.sh
Last active August 29, 2015 13:56
git repo 아래에 또 다른 repo가 많을 때, 한번에 git 명령 내리기..
#!/bin/bash
# Usage: gs.sh git checkout master
cwd=`pwd`
for repo in `find . -name .git`; do
repo=${repo/.git}
cd $cwd/$repo
echo "==== $repo ===="
@whitekid
whitekid / genpass.sh
Created March 26, 2014 06:01
Random Password Generator
#!/bin/sh
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
cat /dev/urandom | LC_CTYPE=C tr -dc A-Za-z0-9_ | head -c ${l}
echo
}
genpasswd "$@"
@whitekid
whitekid / docker.sh
Last active August 29, 2015 14:21
automatically update boot2docker ip in /etc/hosts
#!/bin/bash
# Usage:
# git clone https://gist.github.com/ea78bb56d5bd901187dc.git docker.gist
# mkdir ~/bin
# ln -s docker.gist/docker.sh ~/bin/docker
# export PATH=$PATH:~/bin
/usr/local/bin/docker "$@"
r=$?
update_boot2docker_ip() {
@whitekid
whitekid / docker_netns_sync.go
Last active August 29, 2015 14:22
sync docker container network namespace
package main
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"time"
@whitekid
whitekid / basic_auth.py
Created June 23, 2015 05:01
OpenStask python client snippt
import os
import keystoneclient.v2_0.client as kclient
from neutronclient.v2_0 import client as neutronclient
def basic_auth():
keystone = kclient.Client(
auth_url = os.environ.get('OS_AUTH_URL'),
username = os.environ.get('OS_USERNAME'),
tenant_name = os.environ.get('OS_TENANT_NAME'),