Skip to content

Instantly share code, notes, and snippets.

(defvar accelerated-move:buffer nil)
(defvar accelerated-move:count 0)
(defvar accelerated-move:point (make-hash-table))
(defvar accelerated-move:table '(7 12 17 21 24 26 28 30))
(defun accelerated-move:previous (&optional arg try-vscroll)
(interactive "^p\np")
(accelerated-move:do 'previous-line "previous" arg try-vscroll))
(defun accelerated-move:next (&optional arg try-vscroll)
@hanabokuro
hanabokuro / gist:6547442
Created September 13, 2013 06:55
elisp : fetch and save
(defun fetch-and-save (url filename)
(let (buffer)
(setq buffer (url-retrieve-synchronously url))
(switch-to-buffer buffer)
(goto-char (point-min))(search-forward "\n\n")(kill-region (point-min) (point)) ;; delete http headers
(write-file filename)
(kill-buffer buffer)
))
use strict;
use warnings;
use utf8;
use Test::More;
use Test::Builder;
BEGIN {
use_ok('AvoidCoreTextBug');
package AvoidCoreTextBug;
use strict;
use warnings;
our %SEPARATORS = map { $_ => 1 } (0x20, 0xa0,
0x1680, 0x180e,
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a,
0x202f, 0x205f,
0x3000,
@hanabokuro
hanabokuro / mysql client wrapper
Created May 30, 2013 09:31
予期せず本番DBを更新してしまわないようにするためのwrapper 本物のmysqlよりもPATHの先頭にくるようにしておく。 DBを更新したいときは /usr/bin/msql とfull pathで起動する。
#!/usr/bin/perl
use strict;
use warnings;
use Expect;
my $MYSQL_COMMAND = '/usr/bin/mysql';
my $expect = new Expect;
@hanabokuro
hanabokuro / gist:3031761
Created July 2, 2012 07:54
Text::Xslate::_magic_token
sub _magic_token {
my($self, $fullpath) = @_;
$self->{serial_opt} ||= Data::MessagePack->pack([
ref($self->{compiler}) || $self->{compiler},
$self->_filter_options_for_magic_token($self->_extract_options($self->parser_option)),
$self->_filter_options_for_magic_token($self->_extract_options($self->compiler_option)),
$self->input_layer,
[sort keys %{ $self->{function} }],
]);
@hanabokuro
hanabokuro / gist:2709534
Created May 16, 2012 11:00
pnotes leak (perl5.8 + mod_perl-2.0.4)
#!/usr/bin/perl
use strict;
use warnings;
use B;
use Apache2::RequestUtil;
print <<"END;";
Content-type: text/plain
@hanabokuro
hanabokuro / gist:1108805
Created July 27, 2011 06:46
memcached-1.4.6
よく似た症状を再現させる方法
・memcachedを起動
・gdb -p <PID> で attach
(gdb) call pthread_mutex_lock(&conn_lock)
(gdb) call pthread_mutex_lock(&conn_lock)
2回目はlockするので Ctrl-C で中断
(gdb) detach
これで同じ症状になります。
@hanabokuro
hanabokuro / gist:1042248
Created June 23, 2011 09:40
Text::Xslate enable to write 'func()' instead of '$func()'
sub _generate_call {
my($self, $node) = @_;
my $callable = $node->first; # function or macro
my $args = $node->second;
my @code = $self->SUPER::_generate_call($node);
if($callable->arity eq 'name'){
my @code_fetch_symbol = $self->compile_ast($callable);
@code = (
@hanabokuro
hanabokuro / gist:1042245
Created June 23, 2011 09:39
Text::Xslate::Compiler simulate global_vars
sub _generate_variable {
my($self, $node) = @_;
if(defined(my $lvar_id = $self->lvar->{$node->value})) {
return $self->opcode( load_lvar => $lvar_id, symbol => $node );
}
else {
my $name = $self->_variable_to_value($node);
my @code;