Skip to content

Instantly share code, notes, and snippets.


κeen KeenS

View GitHub Profile
KeenS / BGM
Last active Dec 21, 2015
A script for playing BGM and notify the title of BGM now playing. You are to have `BGM.list` of a file which lists filenames you want to play in music directory.
View BGM
#!/usr/bin/env ruby -Ku
# _*_ coding:UTF-8 _*_
require 'mplayer-ruby'
require 'libnotify'
class MPlayer::Slave
def now_playing
summary = ""
summary += get(:meta_title).chomp
summary += " -- " + get(:meta_artist).chomp
KeenS / script.lisp
Last active Dec 13, 2016
A function for shelly to load a file ignoring shebang. This is useful to write a script with Common Lisp.
View script.lisp
(in-package :shelly)
(export (defvar *argv* nil))
(in-package :cl-user)
(defun script (file argv)
"Execute a file as script ignoring shebang"
(setf shelly:*argv* argv)
(let* ((in (open file :if-does-not-exist :error))
(first-char (read-char in))
(second-char (read-char in)))
KeenS / gist:6751314
Created Sep 29, 2013
A shell function to migrate music files to mp3.
View gist:6751314
function migrate_to_mp3 (){
for f in *.$1
if [ ! -f $mp3 ];then
ffmpeg -i $f $mp3
rm $f
KeenS / dired-tar.el
Created Oct 4, 2013
A dired-mode extension to archive files marked. To use, mark files with `m` and then `T`. Notice that you can uncompress and/or expand wth `!` default command (`tar xzvf`).
View dired-tar.el
(defun dired-tar (tarname files &optional arg)
"A dired-mode extension to archive files marked. With prefix argument, the tarball is gziped."
(interactive (let ((files (dired-get-marked-files)))
(list (read-string "Tarball name: " (concat (file-relative-name (car files)) ".tar.gz"))
files "P")))
(let ((tar (if arg
(if dired-guess-shell-gnutar
(concat dired-guess-shell-gnutar " zcf %s %s")
"tar cf - %2s | gzip > %1s")
"tar cf %s %s")))
KeenS / failed tests
Last active Dec 25, 2015
Current failing tests of clack.handler.toot
View failed tests - [2013-10-09 20:48:20] "GET / HTTP/1.1" 304 0 "-" "Drakma/1.3.4 (SBCL; Linux; 3.8.0-32-generic;"
ok 1
not ok 2
# got: NIL
# expected: #()
not ok 3 - No Content-Type
# got: T
# expected: NIL
not ok 4 - No Content-Length
# got: T
KeenS / shelly_shell_utils.lisp
Last active Dec 13, 2016
Usage: $ shly script [options] scriptfile argv Options are like those of ruby's.
View shelly_shell_utils.lisp
(ql:quickload :unix-options)
(defvar *argv* nil)
(defvar *argf* *standard-input*)
(defvar *-i* nil)
(defvar *-F*)
(defvar *_*)
(defvar *?*)
(defmacro $ (sym &optional arg)
(etypecase sym
(fixnum (if (zerop sym)
KeenS / demo1.lisp
Last active Dec 26, 2015
Shibuya.lispのLisp Meet Up #10 で発表したときのデモのソースです
View demo1.lisp
(ql:quickload :bordeaux-threads)
(ql:quickload :log4cl)
; debugとinfoのログレベルのメッセージを交互に吐き続けるスレッドを作成
(defparameter thrd (bordeaux-threads:make-thread
(lambda () (loop
(log:debug "this is debug")
(log:info "this is ~{~a~}" '(#\i #\n #\f #\o))
(sleep 1)))))
KeenS / code.rb
Created Nov 17, 2013
fluentd forward bug
View code.rb
#!/usr/bin/env ruby
# _*_ coding:UTF-8 _*_
require 'msgpack'
require 'socket' "", "24224" do |sock|
sock.write ["debug.access", [1308466941, {"a"=>1}], [1308466942, {"b"=>2}]].to_msgpack
KeenS / gist:8039353
Last active Dec 31, 2015
Installing sudo from FreeBSD ports causes this error
View gist:8039353
/usr/ports/security/sudo # make install clean
===> sudo-1.8.8 depends on shared library: - not found
===> Verifying for in /usr/ports/devel/gettext
===> Building for gettext-
Making all in gnulib-local
Making all in gettext-runtime
/usr/bin/make all-recursive
Making all in doc
Making all in intl
Making all in intl-java
KeenS / gist:8141286
Created Dec 27, 2013
The Errors I got when building mirah by `rake gem`
View gist:8141286
$ git pull
Already up-to-date.
$ rake clean clobber
Deleting directory /home/kim/compile/mirah/build
rm -f javalib/mirah-bootstrap.jar
rm -f javalib/mirah-compiler.jar
rm -f javalib/mirah-builtins.jar
rm -f javalib/mirah-util.jar
rm -f javalib/mirah-mirrors.jar
rm -rf tmp