Skip to content

Instantly share code, notes, and snippets.

@valvallow
valvallow / wol-local.sh
Created June 30, 2012 00:15 — forked from aharisu/wol.scm
Wake-on-LANのマジックパケットを投げつけるだけ
#!/bin/sh
ssh -i /home/valvallow/.ssh/kaisha/id_rsa valvallow@kaisha-no-server '~/wol-srv.sh'
#!/bin/sh
DEVENV_PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/devenv.com"
# get last argument
SLN_PATH=`eval echo '$'{$#}`
SLN_PATH_DOS=`cygpath -d "$SLN_PATH"`
"$DEVENV_PATH" ${@:1:`expr $# - 1`} "$SLN_PATH_DOS" | nkf
@valvallow
valvallow / example.cs
Created May 30, 2012 02:24
statement to expression
void example() {
var b = Expr<bool>(() => {
switch (1) {
case 1: return true;
default: return false;
}
});
}
@valvallow
valvallow / huffman.scm
Created May 15, 2012 14:26
sicp huffman encoding tree
;; huffman encoding tree
(define (make-leaf symbol weight)
(list 'leaf symbol weight))
(define (leaf? object)
(eq? (car object) 'leaf))
(define (symbol-leaf x)
(cadr x))
(use gauche.generator)
(use gauche.lazy)
(define-syntax chain
(syntax-rules ()
((_ ls (p1 p2)) (p1 p2 ls))
((_ ls (p1 p2) x ...)
(begin (chain ls (p1 p2))
(chain ls x ...)))))
(use gauche.generator)
(use gauche.lazy)
(define-syntax chain
(syntax-rules ()
((_ ls proc)(proc ls))
((_ ls proc x ...)
(begin (chain ls proc)
(chain ls x ...)))))
public static class Values {
public static void Receive<T1, T2>(this Tuple<T1, T2> tuple, out T1 item1, out T2 item2) {
item1 = tuple.Item1;
item2 = tuple.Item2;
}
public static void CallWith<T1, T2>(this Tuple<T1, T2> tuple, Action<T1, T2> func) {
func(tuple.Item1, tuple.Item2);
}
}
@valvallow
valvallow / update_ssh_hosts.sh
Created April 23, 2012 08:21
update /etc/hosts.allow and /etc/hosts.deny
#!/bin/sh
MASK_TEXT_URL='http://nami.jp/ipv4bycc/mask.txt.gz'
WORKDIR=`mktemp -d`
cd $WORKDIR
wget "$MASK_TEXT_URL" 2> /dev/null > /dev/null
if [ $? -ne 0 ]; then
exit 1;
@valvallow
valvallow / csv2sql.scm
Last active April 6, 2022 17:11
convert csv to insert|update sql query string
#!/usr/local/bin/gosh
(use srfi-1)
(use text.csv)
(use file.util)
(use util.list)
(use gauche.parseopt)
(define (usage)
(print "Usage: csv2sql [options ...] <csv-file>")
@valvallow
valvallow / abp.sh
Created March 8, 2012 06:31
relative path to absolute path
#!/bin/sh
# http://dokonoumanohone.blog47.fc2.com/blog-entry-2.html
for ARG in "$@"
do
echo $(cd $(dirname "$ARG") && pwd)/$(basename "$ARG")
done