Skip to content

Instantly share code, notes, and snippets.

View ichiban's full-sized avatar

Yutaka Ichibangase ichiban

View GitHub Profile
@ichiban
ichiban / base64tweet.el
Created June 11, 2012 09:24
おおっぴらに言いにくい事でも難読化すればどこにだって書ける。
(defun base64 (&optional b e)
"base64 encode/decode"
(interactive "r")
(shell-command-on-region b e "ruby -rbase64 -e 's = $stdin.gets; print Base64.send(/^[A-Za-z0-9\\+\\/=]+$/ =~ s ? :decode64 : :encode64, s).split($/).join'" nil t))
@ichiban
ichiban / gist:1833038
Created February 15, 2012 03:50
こんなので.ssh/config切り替えると便利な気がする
#!/usr/bin/env ruby
require 'thor'
class SSHEnv < Thor
SSH_DIR = "~/.ssh"
desc 'use PRESET', 'Switch SSH config preset to PRESET'
method_option :dry, :type => :boolean, :aliases => '-d'
def use(name="default")
ichiban:example$ m2sh version
Mongrel2/1.7.5
ichiban:example$ sqlite3 config.sqlite
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from setting;
1|control_port|ipc://tmp/mongrel2_control
2|zeromq.threads|1
3|upload.temp_store|/tmp/mongrel2.upload.XXXXXX
@ichiban
ichiban / app.rb
Created January 20, 2012 16:17
example for big-upload
require 'sinatra'
require 'yajl/json_gem'
set(:mongrel2_upload) do |value|
condition do
case value
when :start
request.env.key?('x-mongrel2-upload-start')
when :done
request.env.key?('x-mongrel2-upload-done')
@ichiban
ichiban / xor_texture.lisp
Created January 6, 2012 13:57
XOR texture in Common Lisp
(require :lispbuilder-sdl)
(defun run ()
(sdl:with-init ()
(sdl:window 320 240)
(draw-xor-texture)
(sdl:with-events ()
(:quit-event () t)
(:idle
(sdl:update-display)))))
@ichiban
ichiban / gist:1350361
Created November 9, 2011 04:19
これ聴きながら仕事してます
$ cat > kiku.c
#include <pthread.h>
char c;f(){while(1)c=~getchar();}main(t,p){pthread_create(&p,NULL,f,NULL);for(t=0;;t++)putchar(t>>~c|t>>5|t>>1000-c|t>>c);}
$ make kiku
cc kiku.c -o kiku
kiku.c: In function ‘main’:
kiku.c:2: warning: passing argument 1 of ‘pthread_create’ from incompatible pointer type
kiku.c:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
$ sudo tcpdump | ./kiku | sox -traw -r8k -c1 -eunsigned -b8 - -d
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
;;; make cffi to dlopen homebrewed libraries
(require :cffi)
@ichiban
ichiban / gist:1290650
Created October 16, 2011 08:21
Flymake Ocaml settings that doesn't hang my GNU Emacs 23.3.1 (x86_64-apple-darwin10.7.0, NS apple-appkit-1038.35)
;; Flymake Ocaml
(add-to-list 'exec-path "~/bin")
(defun flymake-ocaml-init ()
(flymake-simple-make-init-impl
'flymake-create-temp-with-folder-structure nil nil
(file-name-nondirectory buffer-file-name)
'flymake-get-ocaml-cmdline))
(defun flymake-get-ocaml-cmdline (source base-dir)
(list "ocaml_flycheck.pl"
(list source base-dir)))
@ichiban
ichiban / cat.ml
Created September 21, 2011 15:32
simple 'cat' command in O'Caml
(* cat.ml *)
(* simple cat command in O'Caml *)
open Sys
open Array
open List
let print_channel in_channel =
let rec iter _ =
print_endline (input_line in_channel);
@ichiban
ichiban / WhatIsJavaLibraryPaty.java
Created August 1, 2011 11:25
script to see what java.library.path is.
import static java.lang.System.*;
public class WhatIsJavaLibraryPath {
public static void main(String[] args) {
out.println(getProperty("java.library.path"));
}
}