Skip to content

Instantly share code, notes, and snippets.

View k14i's full-sized avatar

kt k14i

View GitHub Profile
@k14i
k14i / aa.sh
Created August 10, 2013 18:28
Convert an image file into an ascii art and show it in the terminal. This script requires netpbm.
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
exit 1
fi
filetype=`file -b "$1" | awk '{print $1}'`
if [ x$filetype == x ]; then
msg="ERROR: Could not determine the file type of \"$1\""
@k14i
k14i / get_password.sh
Last active December 20, 2015 21:58
You should not save your passwords anywhare and should not forget them! This thesis will be solved only by algorithm.
#!/usr/bin/env bash
DIR=$HOME/etc/get_password
. $DIR/get_password_string.txt
. $DIR/get_password_cycle.txt
ALGORITHM="sha1" # md4, md5, sha, sha1, ripemd160 and so on.
count=1
@k14i
k14i / send_global-ipaddr-info.py
Created August 10, 2013 18:01
This may be useful when you don't use dynamic DNS sevices.
#!/usr/bin/env python
import urllib2
import re
import os
import socket
#hostname = socket.gethostname()
hostname = ""
urlprovider = 'http://www.ugtop.com/'
@k14i
k14i / cloudstack.sh
Last active January 11, 2020 22:56
CloudStack API client shell script.
#!/usr/bin/env bash
ADDRESS="https://"
API_KEY=""
SECRET_KEY=""
USE_XMLLINT=0 # true => 1, false => 0
if [ x$ADDRESS == x ] || [ x$API_KEY == x ] || [ x$SECRET_KEY == x ] || [ x$USE_XMLLINT == x ]; then
echo 'ERROR: Set all required valiables.'
exit 1
@k14i
k14i / delete_dropbox-conflicted-copies.sh
Created August 10, 2013 17:32
Delete all conflicted copies on your Dropbox.
#!/usr/bin/env bash
DROPBOX_PATH="$HOME/Dropbox"
PREEXEC='sudo'
DUSTBOX='/tmp/rm'
DELETE_METHOD="$PREEXEC mv {} $DUSTBOX"
mkdir -p $DUSTBOX
$PREEXEC find $DROPBOX_PATH -name '*conflicted copy*' -exec $DELETE_METHOD \;
@k14i
k14i / set_iptables.py
Created June 27, 2013 07:18
This script makes iptables ACCEPT specific CIDRs in a list file. Python >= 2.4 is required (so this can work on legacy OS like CentOS 5.x). It is good to call this script in the start() function of /etc/init.d/iptables.
#!/usr/bin/env python
import re
import os
file = "/root/etc/iptables/accept/cidr"
regex = re.compile('^([0-9]{1,3})(\.([0-9]{1,3})){3}/[0-9]{1,2}')
os.system("iptables -F")
os.system("iptables -A INPUT -i lo -p all -j ACCEPT")
@k14i
k14i / setup_cachefilesd.sh
Last active December 17, 2015 18:09
cachefilesd properly works with Gluster's NFS, not only with kernel's one. It would be a waste not to match them up :-) #glusterfs https://twitter.com/keithseahus/status/337902379762601984
#!/usr/bin/env bash
NFS_SERVER=192.168.1.100
MOUNT_POINT=/mnt/nfs
yum install -y cachefilesd
if test `grep 'SELINUX=disabled' /etc/selinux/config > /dev/null; echo $?` -ne 0; then
sed -i 's/^secctx/#secctx/g' /etc/cachefilesd.conf
fi
chkconfig cachefilesd on