Skip to content

Instantly share code, notes, and snippets.

@sean-kang
sean-kang / gist:8367578
Last active January 2, 2016 22:08
Volnoti Control Script.Test environment: arch linux, pulse audio, xfce4.Dependency: amixer, volnoti.volnoti: https://github.com/davidbrazdil/volnoti
#!/usr/bin/env bash
[[ "$1" == "up" ]] && amixer set Master 5%+
[[ "$1" == "down" ]] && amixer set Master 5%-
[[ "$1" == "mute" ]] && amixer sset Master toggle
FRONT_LEFT=$(amixer get Master | grep -E '^\s+Front Left')
MONO=$(amixer get Master | grep -E '^\s+Mono')
if [[ $FRONT_LEFT == "" ]]; then
@sean-kang
sean-kang / gist:7903573
Created December 11, 2013 01:26
GPG symmetric password encryption
To encrypt: gpg -c <source>
To decyprt: gpg <filenmae>
@sean-kang
sean-kang / gist:7594601
Created November 22, 2013 03:54
Example: getIpAddresses
SeanMac:temp sean$ cat test-ip
eth0 Link encap:Ethernet HWaddr 45:d3:49:60:f3:0b
inet addr:151.242.64.171 Bcast:178.22.71.255 Mask:255.255.248.0
inet6 addr: fe80::20c3:b4ff:fe6b:1fbb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:165709690 errors:0 dropped:0 overruns:0 frame:0
TX packets:17210384 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20384657573 (20.3 GB) TX bytes:5304687858 (5.3 GB)
syntax on
filetype indent plugin on
set background=light
autocmd FileType ruby set autoindent|set smartindent
autocmd FileType ruby set number
autocmd FileType ruby set tabstop=4|set shiftwidth=4|set expandtab|set softtabstop=4
au FileType python set number
@sean-kang
sean-kang / gist:5485894
Last active December 16, 2015 19:30
Quick Self-signed RSA Key and X509 Certificate
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.crt
#openssl genrsa -out mykey.pem 2048
#openssl req -new -x509 -key mykey.pem -out mycert.crt -days 730
@sean-kang
sean-kang / sudo_with_path
Last active December 15, 2015 12:28
Overrides sudo command to pass PATH to sudo. I implemented this since alias didn't work as intended in bash scripts.
function sudo() {
/usr/bin/sudo env PATH=${PATH} "$@"
}
@sean-kang
sean-kang / ignite_talk_auto_slide.sh
Last active December 14, 2015 15:19
It is to practice presentation.
#!/bin/bash
for i in $(seq 1 20); do
echo slide $i
sleep 15
xdotool click 1
done
@sean-kang
sean-kang / verify_net_addr.js
Last active December 14, 2015 00:48
Prototype for network address verification. This function should work with existing verification code using regular expression. For example, this function will try to calculate numbers even if an octet is bigger than 255.
function verify_address(cidr_addr) {
var parts = cidr_addr.split("/");
var ip = parts[0];
var prefix = parts[1];
var mask = 0xffffffff;
var ip_parts = ip.split('.');
var ip_hex = (((((((+ip_parts[0])*256)+(+ip_parts[1]))*256)+(+ip_parts[2]))*256)+(+ip_parts[3])) >>> 0;
var prefix_hex = (~(mask >>> prefix)) >>> 0;
var net_addr = (ip_hex & prefix_hex) >>> 0;