Skip to content

Instantly share code, notes, and snippets.

View leoh0's full-sized avatar
🕶️
Working

Eohyung Lee leoh0

🕶️
Working
View GitHub Profile
# TODO throwing error:
# Cannot find a resource for to_ary on ubuntu version 12.04
require 'set'
file "/root/chef_resources-#{node.name}.json" do
resource_clxn = Chef::ResourceCollection.new
run_context.resource_collection.each do |r|
next if r.class.to_s == 'Chef::Resource::NodeMetadata'
r = r.dup
@leoh0
leoh0 / knife.sh
Last active August 29, 2015 13:56 — forked from nukemberg/knife.sh
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
SED=sed
# first argument set the command level
_get_knife_completions() {
n=$1
shift
# first argument is knife, so shift it
#!/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 "$@"
@leoh0
leoh0 / 0-add-user.sh
Last active August 29, 2015 14:03
swift saio install script for ubuntu trusty
#!/bin/bash
# vagrant@vagrant-ubuntu-trusty-64:~$ sudo adduser swift
# Adding user `swift' ...
# Adding new group `swift' (1002) ...
# Adding new user `swift' (1002) with group `swift' ...
# Creating home directory `/home/swift' ...
# Copying files from `/etc/skel' ...
# Enter new UNIX password:
# Retype new UNIX password:
# passwd: password updated successfully
'''Implements a straight Jenkins lookup hash - http://burtleburtle.net/bob/hash/doobs.html
Usage:
from jhash import jhash
print jhash('My hovercraft is full of eels')
Returns: unsigned 32 bit integer value
Prereqs: None
git fetch origin && git fetch origin --tags && git reset --hard $(git ls-remote | grep -w 'refs/heads/master' | awk '{print $1}')
@leoh0
leoh0 / hping.sh
Last active December 23, 2015 10:36
ping openstack vms in specific host
#!/usr/bin/env bash
declare -A vm_ip
declare -A vm_id
declare -A vm_status
while read -r _ id _ name _ ip _ ; do
ip=$(echo $ip|cut -d'=' -f2)
vm_ip[$name]=$ip
vm_id[$name]=$id
@leoh0
leoh0 / drawl2path.sh
Created April 2, 2015 17:28
openstack l2path draw
#!/bin/bash
sudo apt-get install -qqy ethtool libgraph-easy-perl graphviz > /dev/null
EXCEPT=/tmp/exceptlist
echo '' > $EXCEPT
result=""
function on_exit() {
rm -f $EXCEPT
#!/bin/bash
while true; do
disk=$(ls -al /dev/ | awk '/ disk[0-9]$/{print $10}' | grep -Ev "(disk0|disk1)" | head -n1)
if [ "x${disk}" = "x" ]; then
sleep 2
continue
fi
diskpath=/dev/${disk}
@leoh0
leoh0 / ntfs_mount.sh
Created October 31, 2015 12:20
write access ntfs disk for mac os
#!/usr/bin/env bash
if mount | grep -q 'ntfs' ; then
if ! mount | grep -q 'read-only' ; then
echo -e "\033[01;36mExist already in /etc/fstab.\033[00m"
VOLUME=$(mount | grep "(ntfs, " | sed 's|/dev/disk[0-9]s[0-9] on \(.*\) (ntfs,.*$|\1|g')
open "$VOLUME"
exit
fi