Skip to content

Instantly share code, notes, and snippets.

@fukamachi
fukamachi / gist:4109289
Created November 19, 2012 06:42
Make the color of parenthesis gray.
(defvar paren-face 'paren-face)
(make-face 'paren-face)
(set-face-foreground 'paren-face "#666666")
(dolist (mode '(lisp-mode
emacs-lisp-mode
scheme-mode))
(font-lock-add-keywords mode
'(("(\\|)" . paren-face))))
@fukamachi
fukamachi / gist:3964573
Created October 27, 2012 13:08
Tutorial of cl-string-complete

This is a tutorial of cl-string-complete.

CL-USER> (ql:quickload :cl-string-complete)
To load "cl-string-complete":
  Install 1 Quicklisp release:
    cl-string-complete
; Fetching #<URL "http://beta.quicklisp.org/archive/cl-string-complete/2012-01-07/cl-string-complete-20120107-hg.tgz">
; 5.14KB
==================================================
@fukamachi
fukamachi / gist:2514283
Created April 27, 2012 23:34
Clack uploading sample
(import 'clack.request:make-request 'clack.request:body-parameter)
(clack:clackup
#'(lambda (env)
(format t "~S~%"
(body-parameter (make-request env)))
'(200
(:content-type "text/html")
("<form method='POST' enctype='multipart/form-data'><input type='file' name='pdf'><input type='submit'></form>"))))
@fukamachi
fukamachi / gist:2514290
Created April 27, 2012 23:36
Clack uploading sample
(import 'clack.request:make-request 'clack.request:body-parameter)
(clack:clackup
#'(lambda (env)
(format t "~S~%"
(body-parameter (make-request env)))
'(200
(:content-type "text/html")
("<form method='POST' enctype='multipart/form-data'><input type='file' name='pdf'><input type='submit'></form>"))))
@fukamachi
fukamachi / gist:2050237
Created March 16, 2012 14:16
Find port number not in use
(defun port-available-p (port)
(handler-case (let ((socket (usocket:socket-listen "127.0.0.1" port :reuse-address t)))
(usocket:socket-close socket))
(usocket:address-in-use-error (e) (declare (ignore e)) nil)))
;; Find port number not in use from 50000 to 60000.
(loop for port from (+ 50000 (random 1000)) upto 60000
if (port-available-p port)
return port)
@fukamachi
fukamachi / gist:1922987
Created February 27, 2012 10:22
Emacs settings for Clack developers
(defun clack-slime-search-buffer-package ()
(let ((case-fold-search t)
(regexp (concat "^(\\(clack.util:\\)?namespace\\>[ \t']*"
"\\([^\n)]+\\)")))
(save-excursion
(if (or (re-search-backward regexp nil t)
(re-search-forward regexp nil t))
(match-string-no-properties 2)
(slime-search-buffer-package)))))
(setq slime-find-buffer-package-function 'clack-slime-search-buffer-package)
@fukamachi
fukamachi / test-utils.lisp
Created October 27, 2011 11:56
Useful utilities for CL testing.
(in-package :cl-user)
(ql:quickload :cl-test-more)
(defun asdf-component-files (comp)
(etypecase comp
(asdf::cl-source-file
(list (asdf:component-pathname comp)))
(asdf::static-file nil)
(asdf::component
(loop for c in (asdf:module-components comp)
@fukamachi
fukamachi / gist:766438
Created January 5, 2011 15:20
groupBy for CL
(defun group-by (pred list)
(loop
while list
for cur = (pop list)
collect
(nreverse
(loop with acc = (list cur)
while list
for x = (pop list)
if (funcall pred cur x)
;; anything-ari.el - Show animated Ari.
;; Copyright (C) 2010 Eitarow Fukamachi <fukamachi_e@ariel-networks.com>
;; Author: Eitarow Fukamachi <fukamachi_e@ariel-networks.com>
;; Twitter: http://twitter.com/nitro_idiot
;; Blog: http://e-arrows.sakura.ne.jp/
;;
;; Created: Dec 9, 2010
;; Version: 0.0.1
(let ((default-directory (expand-file-name "~/Dropbox/home/.emacs.d")))
(add-to-list 'load-path default-directory)
(load (expand-file-name "~/Dropbox/home/.emacs.d/subdirs.el") t t t))
(if (file-exists-p (locate-library "init"))
(load (locate-library "init") nil t nil))