Skip to content

Instantly share code, notes, and snippets.

@eidantoei
eidantoei / gist:383141
Created April 29, 2010 04:30
timeout()
# timeout()
# fork from http://d.hatena.ne.jp/hcr/20050803/1123025377
# 2010-04-29
timeout()
{
count_timeout=$1
shift 1;
echo exec \'$@\'
$@ &
@eidantoei
eidantoei / itunesautocutting-20110116.scpt
Created January 15, 2011 15:23
iTunes auto cutting
tell application "iTunes"
play
repeat
next track
set l to duration of current track
repeat 16 times
set p to random number from (l - 1)
set r to random number from 1 to 4
set d to 2 ^ (4 - r) / 10
repeat 2 ^ r times
while :; do clear; uptime; echo; /usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /; if [ $? -eq 0 ]; then echo -e "\e[0;32m[OK]\e[0m"; elif [ $? -eq 1 ]; then echo -e "\e[0;33m[WARNING]\e[0m"; elif [ $? -eq 2 ]; then echo -e "\e[0;31m[CRITICAL]\e[0m"; fi; sleep 1; done
@eidantoei
eidantoei / c2g.rb
Created May 30, 2011 16:48
Visualizing `uniq -c` result
#!/usr/bin/env ruby
require 'optparse'
bar_string = "|"
bar_max = 30
max = 0
$es_s=["\033[34m","\033[36m","\033[32m","\033[33m","\033[35m","\033[31m"]
$es_b="\033[30m"
@eidantoei
eidantoei / example.com.js
Created January 29, 2012 18:05
Nagiosのサービス詳細ページで[A]キー押すとackにするページに連れてってくれるdotjs
pattern=/https:\/\/([^\/]+)\/(.+)\/extinfo.cgi\?type=2&host=([^&]+)&service=(.+)$/
$(".extinfo").keypress(function(event) {
if ( event.which == 97 ) {
url_from = location.href;
if ( url_from.match(pattern)){
url_to = url_from.replace(pattern,"https://$1/$2/cmd.cgi?cmd_typ=34&host=$3&service=$4");
location.href = url_to;
}
}
@eidantoei
eidantoei / exmample.pde
Created April 6, 2012 19:20
generate animated gif from Proce55ing saveFrame()
void setup(){
// iroiro
}
void draw(){
// arekore
saveFrame("out-####.gif");
}
@eidantoei
eidantoei / README
Created May 31, 2012 07:44
tailf+awk: Add timestamp
Shell 1
=======
# ./logger.sh
Shell 2
=======
# tailf log | awk -f add_timestamp.awk
@eidantoei
eidantoei / gist:2873634
Created June 5, 2012 08:28
Quick mute Thunderbird notification sound
alias thunderbird-sound-off='cp -p ~/Music/silent.wav ~/Music/thunderbird_notify.wav'
alias thunderbird-sound-on='cp -p ~/Music/win95.wav ~/Music/thunderbird_notify.wav'
@eidantoei
eidantoei / thunderbird-sound-control.sh
Created June 8, 2012 07:52
Quick mute Thunderbird notification sound (bash script)
#!/bin/bash
SND_ON="/Users/me/Music/win95.wav"
SND_OFF="/Users/me/Music/silent.wav"
SND_ALIAS="/Users/me/Music/thunderbird_notify.wav"
HASH_ON=$(md5 -q ${SND_ON})
HASH_OFF=$(md5 -q ${SND_OFF})
HASH_ALIAS=$(md5 -q ${SND_ALIAS})
@eidantoei
eidantoei / disable_temporary_hosts.sh
Created July 6, 2012 09:54
余計なhostsコメントアウトして帰るやつ
#!/bin/bash
BORDER="# -------- TEMPORARY_HOSTS --------"
L=$(( $(fgrep -n "${BORDER}" /etc/hosts | cut -d: -f1) + 1 ))
sudo sed -i.$(date +%F-%H-%M-%S) "${L},\$s/^\([^#]\)/#\1/g" /etc/hosts
cat /etc/hosts