Skip to content

Instantly share code, notes, and snippets.

View ainame's full-sized avatar

Satoshi Namai ainame

View GitHub Profile
(defun func1 (func)
(funcall func))
(defun func2 (func)
(func1
(lambda ()
(funcall func))))
(func2
(lambda ()
(defun func1 (func)
(funcall func))
(defun func2 (func)
(func1
(lambda ()
(funcall func))))
(func2
(lambda ()
(require 'cl-lib)
(defvar newline-or-open-line/open-line-count 0)
(make-variable-buffer-local 'newline-or-open-line/open-line-count)
(defun newline-or-open-line/increment-open-line ()
(setq newline-or-open-line/open-line-count (+ newline-or-open-line/open-line-count 1)))
(defun newline-or-open-line/clear-open-line-count ()
(setq newline-or-open-line/open-line-count 0))
(require 'cl-lib)
(defvar newline-or-open-line/open-line-count nil)
(make-variable-buffer-local 'newline-or-open-line/open-line-count)
(defun newline-or-open-line/increment-open-line ()
(push 'open-line newline-or-open-line/open-line-count))
(defun newline-or-open-line/clear-open-line-count ()
(progn
(defun newline-or-open-line ()
"newline-or-openline is a new command for merging C-m and C-o"
(interactive)
(let ((string-exists-before-cursor (string-match "[^\\\s\\\n\\\t]" (buffer-substring (point-at-bol) (point))))
(string-exists-after-cursor (string-match "[^\\\s\\\n\\\t]" (buffer-substring (point) (point-at-eol)))))
(cond ((or (eolp)
(not string-exists-after-cursor)
(and string-exists-before-cursor string-exists-after-cursor))
(progn (newline) (indent-according-to-mode)))
(t (progn (open-line 1) (indent-according-to-mode))))))
(defun newline-or-open-line ()
"newline-or-openline is a new command for merging C-m and C-o"
(interactive)
(cond ((or (eolp)
(not (string-match "[^\\\s\\\n\\\t]" (buffer-substring (point) (point-at-eol)))))
(progn (newline) (indent-according-to-mode)))
(t (progn (open-line 1) (indent-according-to-mode)))))
(define-key global-map (kbd "C-m") 'newline-or-open-line)
(defun newline-or-open-line ()
"newline-or-openline is a new command for merging C-m and C-o"
(interactive)
(cond ((or (eolp)
(not (string-match "[^\\\s\\\n]" (buffer-substring (point) (point-at-eol)))))
(progn (newline) (indent-according-to-mode)))
(t (progn (open-line 1) (indent-according-to-mode)))))
(define-key global-map (kbd "C-m") 'newline-or-open-line)
use strict;
use warnings;
use Plack::Test;
use HTTP::Request;
use Benchmark qw/timethis/;
my $app = sub { [200, [], ['Hello, World!']] };
test_psgi $app, sub {
my $cb = shift;
/Users/namai/workspace/prog/perl/bench:
total used in directory 0 available 9773356
drwxr-xr-x 2 namai staff 68 9 14 00:36 .
drwxr-xr-x 17 namai staff 578 9 14 00:36 ..
@ainame
ainame / pre-commit
Last active December 22, 2015 17:08
ある歴史(BASE_COMMIT)以降に新規追加されたファイルが150行を超えたときにcommitをしないための、決意のpre-commit hookを書きました。
#!/usr/bin/env perl
use strict;
use warnings;
use Perl::Metrics::Simple;
use constant {
EXIT_STATUS_SUCCESS => 0,
PERL_MODULE_FILENAME_PATTERN => qr/\.(pm|pl)$/,
LIMIT_LINES_OF_CODE => 150,
BASE_COMMIT => '9e732c2',