Skip to content

Instantly share code, notes, and snippets.

@stanaka
stanaka / elscreen.el.patch
Created March 21, 2013 04:01
a patch for elscreen.el to use last-command-event instead of last-command-char, which is removed since emacs 24.3.
--- elscreen.el.original 2013-03-21 12:58:17.000000000 +0900
+++ elscreen.el 2013-03-21 12:59:05.000000000 +0900
@@ -984,7 +984,7 @@
(defun elscreen-jump ()
"Switch to specified screen."
(interactive)
- (let ((next-screen (string-to-number (string last-command-char))))
+ (let ((next-screen (string-to-number (string last-command-event))))
(if (and (<= 0 next-screen) (<= next-screen 9))
(elscreen-goto next-screen))))
@stanaka
stanaka / moped_test.rb
Created February 22, 2013 09:41
a sample script to send LARGE requests to mongodb. note: mongodb cannot deal with this request properly.
require 'moped'
session = Moped::Session.new([ "127.0.0.1:27017" ])
session.use "test"
str = ''
1_000_000.times do
str << '0123456789'
end
@stanaka
stanaka / ltsv2json.rb
Created February 16, 2013 15:36
a converter from LTSV to JSON.
#!/usr/bin/env ruby
require 'optparse'
require 'json'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: ltsv2json.rb [options]"
opts.on("-f", "--format FORMAT", "Select format.") do |v|
@stanaka
stanaka / ltsv.rb
Created February 8, 2013 12:53
Simple parser for a LTSV (Labeled Tab-separated Values: http://ltsv.org) file
#!/usr/bin/env ruby
while gets
record = Hash[$_.split("\t").map{|p| p.split(":", 2)}]
p record
end
@stanaka
stanaka / gist:4139081
Created November 24, 2012 09:58
weechat patch for enabling charset plugin
diff --git a/Library/Formula/weechat.rb b/Library/Formula/weechat.rb
index 52eee04..8fdbb0d 100644
--- a/Library/Formula/weechat.rb
+++ b/Library/Formula/weechat.rb
@@ -20,6 +20,10 @@ class Weechat < Formula
option 'python', 'Build the python module (requires framework Python)'
option 'aspell', 'Build the aspell module that checks your spelling'
+ def patches
+ DATA
@stanaka
stanaka / generate_pdf.pl
Created October 15, 2012 15:05
Generate pdf for analyzing kindle paperwhite resolution
#!/usr/bin/env perl
use strict;
use warnings;
use GD;
sub draw_page {
my ($width, $height) = @_;
return unless $width && $height;
cat idm_export.xml | nkf -w | sed 's/encoding="shift-jis"/encoding="utf-8"/'| idm2keepassx.rb > keepassx.xml
@stanaka
stanaka / idm2keepassx.rb
Created August 5, 2012 10:17
Convert IDM export XML to KeepassX XML
#! /usr/bin/env ruby
# idm2keepassx.rb
# convert IDM export XML to KeepassX XML
#
# usage:
# cat idm_export.xml | idm2keepassx.rb > keepassx.xml
require "rexml/document"
require "date"
diff -u libevent-1.4.14b-stable.orig/event.c libevent-1.4.14b-stable/event.c
--- libevent-1.4.14b-stable.orig/event.c 2010-06-20 22:06:04.000000000 +0900
+++ libevent-1.4.14b-stable/event.c 2010-08-15 02:34:35.000000000 +0900
@@ -50,6 +50,7 @@
#include <string.h>
#include <assert.h>
#include <time.h>
+#include <pthread.h>
#include "event.h"