Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / error.log
Created October 6, 2011 14:12
Test::LeakTraceを使うテストに Test::Valgrindを使うとエラーになる
% prove --exec 'perl -Iblib/lib -Iblib/arch -MTest::Valgrind' leak.t
# Using valgrind 3.7.0 located at /usr/local/bin/valgrind
# Using suppression file /Users/syohei/.perl/Test-Valgrind/suppressions/1.13/memcheck-3.7.0-aa5062912afa3d247a5c755d0683818d.supp
# Failed test 'Leak_StillReachable'
# at /Users/syohei/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Test/Valgrind/Session.pm line 451.
# got: 1
# expected: 0
#
@syohex
syohex / fizzbuzz.el
Created October 8, 2011 05:17
Emacs lispで fizzbuzz
(require 'cl)
(defun fizzbuzz (n)
(let ((i 1) lst)
(while (<= i n)
(progn
(cond ((= (mod i 15) 0) (push "fizzbuzz" lst))
((= (mod i 5) 0) (push "buzz" lst))
((= (mod i 3) 0) (push "fizz" lst))
(t
(push i lst)))
@syohex
syohex / testgen_time.log
Created October 15, 2011 10:36
Testgenでプロセス間通信に PIPEを使った場合と、テンポラリファイルを使ったときの差
% ./runtest.pl c89.2-
[Using PIPE]
------------------------------------------
Total : 4162
Passed Compile : 4162 (100.0 %)
Failed Compile : 0 ( 0.0 %)
Passed Execute : 4162 (100.0 %)
Failed Execute : 0 ( 0.0 %)
@syohex
syohex / cdd.zsh
Created November 1, 2011 22:53
grepに alias(主に color option)をしていると、正しく動作しない問題を修正. あと Ruby => Perl
# -*- mode:shell-script -*-
# * cdd
# $ cdd WINDOW番号 でその screen の WINDOW 番号へ移動
# するための zsh function
# 他にも cdadd でショートカットの作成、cddel でショートカットの削除とか
#
# * 使い方
# 1.
# .zshrc でなにはともあれ
# autoload -U compinit
@syohex
syohex / window_move.pl
Created November 2, 2011 08:33
ウインドウを四隅へ移動 + 拡大縮小機能
#!/home/syohei/perl5/perlbrew/perls/perl-5.14.1/bin/perl
use strict;
use warnings;
use File::Which qw/which/;
use utf8;
use Encode qw(encode_utf8);
local $SIG{__DIE__} = sub {
exec qw/zenity --error --text/, encode_utf8(shift);
@syohex
syohex / set-perl5lib.el
Created November 2, 2011 15:26
set-perl5lib.plの改良. t::Util.pmのようなモジュールも認識するように環境変数 PERL5LIBを設定
;;; -*- coding: utf-8; mode:emacs-lisp -*-
;;; set-perl5lib.el --- set path into PERL5LIB if its file path includes 'lib' directory
;; Copyright (C) 2008 Taiyoh Tanaka
;; Author: Taiyoh Tanaka <sun.basix@gmail.com>
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2, or (at your
;; option) any later version.
@syohex
syohex / excel_util.pl
Created November 4, 2011 01:47
Excel列名変換問題で第2回社内プログラミングコンテストを開催してみた(前編)を素直に書いてみた
#!perl
use strict;
use warnings;
my $to_column = shift;
die "first argument is '0' or '1'" unless $to_column == 0 or $to_column == 1;
my $arg = shift or die "Usage: $0 to_column value";
$arg = uc $arg;
@syohex
syohex / imported-perl-modules.el
Created November 7, 2011 15:29
use or require しているモジュールを保管する
(defun my/imported-modules ()
(interactive)
(let (imported-modules)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\(use\\|require\\) +\\([^;]+\\);" nil t)
(push (list (buffer-substring-no-properties (match-beginning 2) (match-end 2)))
imported-modules)
(setq tms imported-modules))
(completing-read "what module? : " imported-modules))))
@syohex
syohex / cperl-perldoc-plus.el
Created November 8, 2011 03:52
cperl-perldocに補完機能をつけてみた
;; IMAKADOさんの plcmp-cmd-show-docの方がすごいのでそちらを使うべき。
(defun cperl-perldoc+ ()
(interactive)
(let* ((imported-module-alist '())
(word-at-point (cperl-word-at-point))
(word-at-point-str (if word-at-point
(substring-no-properties word-at-point)))
(module-regex "\\(use\\|require\\)\\s +\\([^ ;]+\\)"))
(save-excursion
(goto-char (point-min))
@syohex
syohex / tohoho_send_mail.txt
Created November 13, 2011 08:34
とほほさんに送るメールの下書き
とほほのwww入門 管理人 杜甫々様
吉田 昌平と申します。
貴殿のホームページにある「とほほのperl入門」の内容が
とても古いものになってしまっており, 現代的な Perlとはずいぶん
かけ離れたものとなっています。それらの多くは現在推奨されない
書き方になっています。
具体的には以下のような点が上げられます。
- use strict, use warningsが使われていない