This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Works on OS X | |
ping -c 2 -i 2 255.255.255.255 | awk ' $4 ~ /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{print $4}' \ | |
| sed 's/\(.*\):/\1/g' | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dpkg -l | grep mysql | awk '{ print $2 }' | xargs -I {} apt-get purge -y {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
diff <(awk -v FS='\t' '{ print $1 }' a1.txt) <(awk -v FS='\t' '{ print $1 }' a2.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat bundle.txt | xargs -I {} bash -c 'name={}; printf "[submodule \".vim/bundle/%s\"]\n\tpath = .vim/bundle/%s\n\turl = %s\n\n" ${name##*/} ${name##*/} $name' > .gitmodules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Result: | |
# job_id date command | |
atq | awk '{ printf("%s %s %s %s %s ", $1, $5, $3, $4, $6); \ | |
system("at -c "$1"| tail -2 | head -1"); }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
escape() { | |
local raw="$1" | |
local quoted=$(printf %s "$raw" | sed 's/[][()\.^$?*+]/\\&/g') | |
echo "$quoted" | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RequestException(IOError): | |
"""There was an ambiguous exception that occurred while handling your | |
request.""" | |
def __init__(self, *args, **kwargs): | |
""" | |
Initialize RequestException with `request` and `response` objects. | |
""" | |
response = kwargs.pop('response', None) | |
self.response = response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4 smarttab textwidth=78 | |
from __future__ import print_function | |
import os | |
import sys | |
from u115 import API, File, Directory | |
ARGV = sys.argv | |
GLOB_ALL = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -qO - https://gist.githubusercontent.com/shichao-an/c55ba272567b44f50fb6/raw/2edec4ad9b090d78c9690c245dfe0493a7d9f8aa/wb.sh | bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set hostname on Ubuntu 12.04 and 14.04 | |
usage='Usage: set-hostname.sh HOSTNAME' | |
[ $# -ne 1 ] && { echo "$usage" >&2; exit 1; } | |
echo 'Updating hostname...' | |
if which hostnamectl > /dev/null | |
then | |
# Ubuntu 14.04 that ships with hostnamectl |