Skip to content

Instantly share code, notes, and snippets.

Avatar

κeen KeenS

View GitHub Profile
@KeenS
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
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
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
do
mp3=${f%.$1}.mp3
if [ ! -f $mp3 ];then
ffmpeg -i $f $mp3
fi
rm $f
done
}
@KeenS
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
KeenS / failed tests
Last active Dec 25, 2015
Current failing tests of clack.handler.toot
View failed tests
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 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
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)))))
;(infoしか出力されない)
@KeenS
KeenS / code.rb
Created Nov 17, 2013
fluentd forward bug
View code.rb
#!/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 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: 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 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