Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / imager.pl
Created November 13, 2011 11:18
Get RGB and alpha and HSV from image
#!perl
use strict;
use warnings;
use Imager;
my $file = shift or die "Usage: $0 image";
my $img = Imager->new(file => $file) or die Imager->errstr;
my ($width, $height) = ($img->getwidth, $img->getheight);
@syohex
syohex / cperl-mib.el
Created November 14, 2011 13:54
useが書いているブロックに移動 + 元の場所に戻る elisp
;; move point to 'use section or package'
(defvar cperl/mib-orig-marker (make-marker))
(defun cperl/move-import-block ()
(interactive)
(progn
(set-marker cperl/mib-orig-marker (point-marker))
(if (re-search-backward "^\\(use\\|package\\)\[ \n\]+\[^;\]+;" nil t)
(progn
(goto-char (match-end 0))
(next-line))
@syohex
syohex / lis.pl
Created November 16, 2011 09:14
Simple Scheme interpreter in Perl(inspired by lis.py http://norvig.com/lispy.html)
#!perl
use strict;
use warnings;
package Lispl;
use Scalar::Util qw(blessed looks_like_number);
use List::Util qw(reduce);
my $global_env;
@syohex
syohex / perldoc-jp-anything.el
Created November 19, 2011 02:59
perldoc with anything in Emacs
;;
;; inspired and based on anything-vim-hacks
;;
(defconst perldoc-jp:buffer-name "*perldoc-jp*")
(defconst perldoc-jp-core:url "http://perldoc.jp/index/core")
(put 'perldoc-jp:exception-not-retrieved 'error-message "Perldoc jp - Not retrieved")
(put 'perldoc-jp:exception-not-retrieved 'error-conditions
'(perldoc-jp:exception-not-retrieved error))
@syohex
syohex / my-document.el
Created November 21, 2011 09:39
Select document command for each major-mode
;; document
(defmacro major-mode-eql (mode)
`(eql major-mode ,mode))
(defun my/man ()
(interactive)
(let* ((manual-program
(cond
((or (major-mode-eql 'cperl-mode) (major-mode-eql 'perl-mode)) "perldoc")
((or (major-mode-eql 'python-mode) (major-mode-eql 'py-mode)) "pydoc")
@syohex
syohex / woman-split-window.el
Created November 22, 2011 08:18
womanはデフォルトでは windowを丸々 switchするが, manと同様 window半分だけにするためのコード
; spliting window when opening woman buffer
(defadvice woman-really-find-file (around woman-split-window activate)
(switch-to-buffer-other-window (get-buffer-create "*woman-dummy*"))
ad-do-it)
@syohex
syohex / Crypt-SSLeay-20111123.patch
Created November 23, 2011 02:04
Crypt-SSLeay-0.58_01のパッチ
diff --git a/t/01-connect.t b/t/01-connect.t
index cf6b335..d0b79fc 100644
--- a/t/01-connect.t
+++ b/t/01-connect.t
@@ -2,6 +2,7 @@ use strict;
use Test::More tests => 8;
use Net::SSL;
+use Errno ();
@syohex
syohex / start-process.el
Created November 23, 2011 14:06
kill process which runs too long time
(progn
(setq sleep-process (start-process "test" nil "sleep" "60"))
(run-at-time 5 nil (lambda ()
(when (eq (process-status sleep-process) 'run)
(kill-process sleep-process)
(message "kill process sleep")))))
@syohex
syohex / goto-column.el
Created November 28, 2011 02:50
goto column function. This is convenient for moving very long line
;; goto-column
(defun my/goto-column (column)
(interactive
(list (read-string "Goto Column: ")))
(move-to-column (string-to-int column)))
(global-set-key (kbd "M-g c") 'my/goto-column)
@syohex
syohex / shellpop-eshell.el
Created November 29, 2011 14:21
eshellで shellpopした際にカレントディレクトリをアクティブなバッファのディレクトリにする
;; move current directory
(defadvice shell-pop-up (around shell-pop-up-around activate)
(let ((cwd (nth 1 (split-string (pwd)))))
ad-do-it
(insert cwd)
(eshell-send-input)
(recenter-top-bottom 0)))