Skip to content

Instantly share code, notes, and snippets.

View nanasess's full-sized avatar
🍣
Sushi chef

Kentaro Ohkouchi nanasess

🍣
Sushi chef
View GitHub Profile
@nanasess
nanasess / .zaliases
Created October 12, 2011 01:33 — forked from kiwanami/.zaliases
Small aliases to get along with Emacs buffer.
## Invoke the ``dired'' of current working directory in Emacs buffer.
function dired () {
emacsclient -e "(dired \"${1:a}\")"
}
## Chdir to the ``default-directory'' of currently opened in Emacs buffer.
function cde () {
EMACS_CWD=`emacsclient -e "
(expand-file-name
(with-current-buffer (e2wm:current-buffer) default-directory))" | sed 's/^"\(.*\)"$/\1/'`
@nanasess
nanasess / cmew.sh
Created October 12, 2011 04:32
cmew.sh
#!/bin/sh
PATH=$PATH:/opt/local/bin:/bin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin
export PATH
LOG=/tmp/cmew.log
nice -n 19 $HOME/.cabal/bin/cmew 1> $LOG
if [ ! "$?" -eq 0 ]; then
cat $LOG >&2
exit 1
@nanasess
nanasess / tcpserver-pop3
Created October 12, 2011 04:33
tcpserver startup scripts
#!/bin/sh
#
# $Id$
#
# PROVIDE: tcpserver-pop3
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
@nanasess
nanasess / Makefile
Created October 12, 2011 04:53
cocoa-emacs package Makefile
#################################################################################
#
# Cocoa-Emacs Makefile
#
#################################################################################
PREFIX = /Users/nanasess/src/cocoa-emacs
RM = /bin/rm -rfv
TAR = tar xvzf
CURL = curl -O
@nanasess
nanasess / gist:1294627
Created October 18, 2011 04:47
format the sql of region.
(defun sqlf (s end)
"format the sql of region."
(interactive "r")
(let ((case-fold-search t))
(let* ((s (buffer-substring-no-properties s end))
(s (replace-regexp-in-string "\\(select \\)" "\n\\1\n " s))
(s (replace-regexp-in-string "\\(update \\)" "\n\\1\n " s))
(s (replace-regexp-in-string "\\(insert into \\)\\(fuga\\)\\(fuga\\)" "\n\\2\n " s))
(s (replace-regexp-in-string "\\(delete from \\)" "\n\\1\n " s))
(s (replace-regexp-in-string "\\(create table \\)" "\n\\1\n " s))
@nanasess
nanasess / csv2tsv.pl
Created October 18, 2011 06:13
csv2tsv
#!/usr/bin/perl
use strict;
use warnings;
my $column = '';
while (my $line = <STDIN>) {
my $count = 0;
$line .= <STDIN> while ($line =~ tr/"// % 2 and !eof(STDIN));
$line =~ s/(?:\x0D\x0A|[\x0D\x0A])?$/,/;
my @values = map {/^"(.*)"$/s ? scalar($_ = $1, s/""/"/g, $_) : $_}
@nanasess
nanasess / bazaar.conf
Created November 11, 2011 05:42
dvc-bzr multilingual patch
[ALIASES]
diff=diff --diff-options '--strip-trailing-cr'
@nanasess
nanasess / .ackrc
Created November 15, 2011 00:50
dot.ackrc
--type-add=php=.inc
--ignore-dir=log
--ignore-dir=logs
@nanasess
nanasess / gtags.conf
Created November 29, 2011 10:34
configration for gtags
#
# Copyright (c) 1998, 1999, 2000, 2001, 2002, 2003, 2010, 2011
# Tama Communications Corporation
#
# This file is part of GNU GLOBAL.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
@nanasess
nanasess / easy_copy_protection.pl
Created February 17, 2012 00:17
Easy copy protection for perl.
#!/usr/bin/perl
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
my $document_root = $ENV{'DOCUMENT_ROOT'};
my $addr = $ENV{'SERVER_ADDR'};
my $v = sha1_hex($document_root,$addr);
if ($v ne '01f9ee68866f973e95c6c379afa9ab6e4a7a4395') {
print "Content-type: text/plain\n\n";
print "hehehe\n";
exit;