Skip to content

Instantly share code, notes, and snippets.

View kosh04's full-sized avatar
🎧

KOBAYASHI Shigeru kosh04

🎧
View GitHub Profile
;;; -*- mode: emacs-lisp -*-
;;;
;;; Lisp 関数だけに色付け
;;; http://www.bookshelf.jp/cgi-bin/goto.cgi?file=meadow&node=font-lock-func
;;; Usage:
;; (require 'elisp-font-lock)
;;; Code:
;; コンパイルしないと遅いので注意
;; 需要はなさそうだが、
;; *buffer-package* のシンボルのみ色付けにするとか
;; パッケージ::シンボル名 にも対応するとか
;; キーワードファイルの書き方 - refwiki
;; http://xyzzy.s53.xrea.com/reference/wiki.cgi?p=%A5%AD%A1%BC%A5%EF%A1%BC%A5%C9%A5%D5%A5%A1%A5%A4%A5%EB%A4%CE%BD%F1%A4%AD%CA%FD
(defun reload-keyword-file+ ()
"LISP限定追加の色付け."
(defun nalist-to-plist (list)
"連想リストをプロパティリストに変換する[破壊的]."
(if (null list)
nil
(let ((car (car list))
(cdr (cdr list)))
(rplaca list (car car))
(rplacd list car)
(rplaca (cdr list) (cdr car))
(rplacd (cdr list) cdr)
#!/usr/bin/env newlisp
;;; Usage:
;; $ ./cat.lsp cat.lsp
;; $ newlisp cat.lsp http://vt100.net/animation/xmas0.txt 50
;; $ newlisp cat.lsp http://artscene.textfiles.com/vt100/twilightzone.vt
(define (cat filename (interval 0))
"FILENAMEの中身をINTERVALミリ秒間隔で表示する."
(dolist (line (parse (read-file filename) "\n"))
(multiple-value-bind (sec min hour date month year)
(decode-universal-time 3456789012)
(format nil "~A年~A月~A日~A時~A分~A秒" year month date hour min sec))
;; => "2009年7月17日12時10分12秒"
;; SLIME終了後に補完バッファが残る場合があるので一緒に消してほしい
(eval-after-load "slime-fuzzy"
(quote (progn
(defadvice slime-fuzzy-done (around ignore-killed-buffer activate)
(when (buffer-live-p slime-fuzzy-target-buffer)
ad-do-it))
(add-hook 'slime-net-process-close-hooks
(defun slime-kill-misc-buffers (process)
(declare (ignore process))
(kill-buffer (get-buffer-create
#!/usr/bin/clisp
;;; ROT13 (rotate by 13 places) algorithm implemented Common Lisp
;;; Example:
;; CL-USER> (rot13-string "HELLO") => "URYYB"
;; or
;; [shell]$ echo 'HELLO' | clisp rot13.lisp
#!/bin/sh
curl -s http://www.jp.freebsd.org/www.FreeBSD.org/layout/images/beastie.png | pngtopnm | ppmtopgm | pgmtopbm | pbmtoascii -2x4
..
.d&9&'
.o$6H&' o\.
.+S$kM' ?&Rb.
_+S}R&H? `\&9Hb.
+Z$&&&H&D?.o/p1&S6H&&D#>\\ !k&HHH,
|Z$Z&&16&FFR/&&Sk6kMS&9H&HM&b\ H&&&HM:
@kosh04
kosh04 / brainfuck.lsp
Created November 25, 2009 13:12
Brainf*ck interpreter written in newLISP
#!/usr/bin/newlisp
;; @module brainfuck.lsp
;; @description Brainf*ck Interpreter
;; @version 1.0 - first commit
;; @version 1.1 - speedup by using array. doc changes.
;; @author KOBAYASHI Shigeru <shigeru.kb[at]gmail.com>, 2009-2011
;; @license MIT licence
;; @location https://gist.github.com/242690
;;
@kosh04
kosh04 / iconv.lsp
Created November 25, 2009 13:22
iconv library for newLISP
;;; -*- mode:newlisp; coding:utf-8 -*-
;; @module iconv.lsp
;; @description Yet Another Iconv Library
;; @version 0.5 初版
;; @version 0.6 Windows(DLL)でも使えるように
;; @version 0.7 関数を増やした
;; @version 0.8 変換後のNULL文字に対応したつもり
;; @version 0.8b newlisp_sjisでのバッファあふれ修正
;; @version 0.8c Rename iconv-handler -> call-with-iconv-descriptor