This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; open the current (file's) directory in Terminal.app | |
(defun mac-open-terminal () | |
(interactive) | |
(let ((dir "")) | |
(cond | |
((and (local-variable-p 'dired-directory) dired-directory) | |
(setq dir dired-directory)) | |
((stringp (buffer-file-name)) | |
(setq dir (file-name-directory (buffer-file-name)))) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun copy-current-file-name () | |
(interactive) | |
(let ((name (buffer-file-name))) | |
(shell-command (format "echo %s | pbcopy" name)) | |
(message (format "copied: %s" name)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
git push $@ | |
if [ $? = 0 ]; then | |
growlnotify Succeed -a GitX -m 'successfully pushed' | |
else | |
growlnotify Fail -a CyberDuck -m 'git push failed' | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun c++-debug-print() | |
(interactive) | |
(let* ((var-str (read-from-minibuffer "variables (space separated): ")) | |
(vars (split-string var-str)) | |
(dp "cout")) | |
(dolist (v vars) | |
(setq dp (concat dp " << " v " << \", \""))) | |
(insert (concat dp " << endl;")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use WWW::Mechanize; | |
use Config::Pit; | |
my $mech = WWW::Mechanize->new(); | |
my $login_url = "http://lang-8.com/login"; | |
my $response = $mech->get($login_url); | |
my ( $mail, $password ) = do { @{ pit_get("lang-8.com") }{qw/mail password/} }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package HTTP::RequestHandler::GET; | |
use base qw/HTTP::RequestHandler/; | |
use strict; | |
use warnings; | |
sub handle_request { | |
my ($self, $request) = @_; | |
return if $request->method ne 'GET'; | |
warn 'Requested method is GET: ' . $request->uri; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Hash::MultiValue; | |
use XXX; | |
my $h = [a => 1, a => 2, b => 3]; | |
my $hm = Hash::MultiValue->new(@$h); | |
YYY $hm; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# http://ameblo.jp/programming/entry-10001721422.html | |
class Cards: | |
@classmethod | |
def deal(cls, num, string): | |
cds = [""]*num | |
for i in xrange(len(string) / num): | |
for j in xrange(num): | |
cds[j] += string[i*num+j] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
def fact(x): | |
def factrec(f, n): | |
if n < 1: | |
return 1 | |
else: | |
return n * (f (f, (n - 1))) | |
return factrec(factrec, x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
commit = ARGV.empty? ? 'HEAD' : ARGV.shift | |
puts `git log --pretty=oneline #{commit}`.split(/\s+/)[0] | |