Skip to content

Instantly share code, notes, and snippets.


Eitaro Fukamachi fukamachi

Block or report user

Report or block fukamachi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View if-and-aif.lisp
(defmacro execution-time (&body body)
"Return the number of milliseconds it takes to execute `body`. Also
returns the result as the second value."
(let ((tm (gensym))
(res (gensym)))
`(let* ((,tm (get-internal-real-time))
(,res (progn ,@body))
(,tm (floor (* 1000 (- (get-internal-real-time) ,tm))
(values (float ,tm) ,res))))
fukamachi / twitpic-dl.lisp
Last active Aug 29, 2015
Twitpic backup script
View twitpic-dl.lisp
Twitpic Downloader
This Common Lisp script downloads all image/video files from Twitpic account to the current directory.
## Usage
View gist:3e4cf07c5b7331d40b64
(defmacro css (name elems)
(*standard-output* ,(string-downcase name) :direction :output :if-exists :supersede)
,@(loop for (elem attrs) in elems
`(format t "~a {~%" ,elem)
(mapcar (lambda (attr)
fukamachi / 00-benchmarking.markdown
Last active Aug 29, 2015
Benchmarking Clack, Wookie and Node.js
View 00-benchmarking.markdown

Target servers

  • Clack (Wookie handler)
  • Wookie
  • Node.js (http module)

Benchmarking environment

  • Mac OS X Mavericks (CPU: 3GHz Intel Core i7, Memory: 8GB)
  • httperf v0.9.0
View libevent-pthreads.lisp
(cffi:define-foreign-library libevent2-pthreads
(:darwin (:or
; brew's install of libevent on Mac OX X
; macports
(:unix (:or "/usr/local/lib/event2/"
fukamachi / hello.go
Created Oct 15, 2014
Go Hello World server
View hello.go
package main
import (
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World")
fukamachi / parser-utils.lisp
Created Oct 25, 2014
Common Lisp utilities for parsing a sequence
View parser-utils.lisp
(in-package :cl-user)
(defpackage parser-utils
(:use :cl)
(:import-from :alexandria
(:export :with-array-parsing
(in-package :parser-utils)
fukamachi / libbcrypt.rb
Last active Aug 29, 2015
View libbcrypt.rb
require "formula"
class Libbcrypt < Formula
homepage ""
url ""
version '1.1'
sha1 "6ad0f93367e7036e4c4c876d44c39cc00bbb584f"
def install
system "make", "library"
ext = OS.mac? ? 'dylib' : 'so'
; $ sbcl --load --eval '(sb-ext:save-lisp-and-die "a.out" :toplevel #'\''main :executable t)' && time ( echo 100000000 | ./a.out > /dev/null )
; ( echo 100000000 | ./a.out > /dev/null; ) 10.75s user 0.15s system 99% cpu 10.931 total
; $ sbcl --version
; SBCL 1.2.6
(defun main ()
(declare (optimize (speed 3) (debug 0) (safety 0) (compilation-speed 0)))
(let* ((n (1+ (the fixnum (read))))
(is-prime (make-array n :element-type 'boolean :initial-element t)))
fukamachi / 00-vector-case.lisp
Last active Aug 29, 2015
A fast sequence matching macro
View 00-vector-case.lisp
(ql:quickload :alexandria)
(import '(alexandria:ensure-cons alexandria:once-only))
(defmacro vector-case (vec-and-options &body cases)
(destructuring-bind (vec &key (start 0) end case-insensitive)
(ensure-cons vec-and-options)
(let ((otherwise (gensym "otherwise")))
(labels ((case-candidates (el)
(if (and case-insensitive
(characterp el))
You can’t perform that action at this time.