Skip to content

Instantly share code, notes, and snippets.

View KeenS's full-sized avatar

κeen KeenS

View GitHub Profile
@KeenS
KeenS / BGM
Last active December 21, 2015 12:58
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.
#!/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
KeenS / script.lisp
Last active December 13, 2016 07:13
A function for shelly to load a file ignoring shebang. This is useful to write a script with Common 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
KeenS / gist:6751314
Created September 29, 2013 10:32
A shell function to migrate music files to mp3.
function migrate_to_mp3 (){
for f in *.$1
do
mp3=${f%.$1}.mp3
if [ ! -f $mp3 ];then
ffmpeg -i $f $mp3
fi
rm $f
done
}
@KeenS
KeenS / dired-tar.el
Created October 4, 2013 15:53
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`).
(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
KeenS / failed tests
Last active December 25, 2015 01:58
Current failing tests of clack.handler.toot
127.0.0.1 - [2013-10-09 20:48:20] "GET / HTTP/1.1" 304 0 "-" "Drakma/1.3.4 (SBCL 1.1.12.9-83de338; Linux; 3.8.0-32-generic; http://weitz.de/drakma/)"
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
KeenS / shelly_shell_utils.lisp
Last active December 13, 2016 07:12
Usage: $ shly script [options] scriptfile argv Options are like those of ruby's.
(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
KeenS / demo1.lisp
Last active December 26, 2015 04:59
Shibuya.lispのLisp Meet Up #10 で発表したときのデモのソースです
(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)))))
;(infoしか出力されない)
@KeenS
KeenS / code.rb
Created November 17, 2013 09:35
fluentd forward bug
#!/usr/bin/env ruby
# _*_ coding:UTF-8 _*_
require 'msgpack'
require 'socket'
TCPSocket.open "127.0.0.1", "24224" do |sock|
sock.write ["debug.access", [1308466941, {"a"=>1}], [1308466942, {"b"=>2}]].to_msgpack
end
@KeenS
KeenS / gist:8039353
Last active December 31, 2015 20:19
Installing sudo from FreeBSD ports causes this error
/usr/ports/security/sudo # make install clean
===> sudo-1.8.8 depends on shared library: libintl.so - not found
===> Verifying for libintl.so in /usr/ports/devel/gettext
===> Building for gettext-0.18.3.1
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
KeenS / gist:8141286
Created December 27, 2013 01:43
The Errors I got when building mirah by `rake gem`
$ 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