Skip to content

Instantly share code, notes, and snippets.

@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 / inverse-fizzbuzz.lisp
Created May 17, 2012 15:16
Inverse FizzBuzz in Common Lisp
;; http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html
;; http://d.hatena.ne.jp/matarillo/20120515/p1
#.(progn
(ql:quickload :optima)
(ql:quickload :alexandria)
(ql:quickload :cl-test-more)
(values))
(setq *print-circle* t)
@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:4109258
Last active May 27, 2016 21:05
Pretty lambda/nil for Emacs
;; This function is quoted from this page. Thanks to Tomohiro Matsuyama.
;; http://dev.ariel-networks.com/Members/matsuyama/pretty-lambda-in-emacs/
(defun set-pretty-patterns (patterns)
(loop for (glyph . pairs) in patterns do
(loop for (regexp . major-modes) in pairs do
(loop for major-mode in major-modes do
(let ((major-mode (intern (concat (symbol-name major-mode) "-mode")))
(n (if (string-match "\\\\([^?]" regexp) 1 0)))
(font-lock-add-keywords major-mode
`((,regexp (0 (prog1 ()
@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 / less-watch.py
Last active December 12, 2015 06:39
LESS watch & compile.
import os
import re
import shutil
import time
import sys
from watchdog.observers import Observer
from watchdog.tricks import Trick
@fukamachi
fukamachi / gist:4744978
Created February 9, 2013 11:40
Toodledo Redesigned
@charset "UTF-8";
body {
font-family: "Trebuchet MS", Arial, Helvetica, san-serif;
background: none;
}
#logo {
width: 120px;
height: 27px;
@fukamachi
fukamachi / gist:5545090
Last active December 17, 2015 03:39
「↓の部分を追加」以下の部分を追加してください
/* <system section="theme" selected="11696248318752473050"> */
@import url("http://hatenablog.com/theme/11696248318752473050.css");
/* </system> */
/* <system section="background" selected="a5b095"> */
body{background:#a5b095;}
/* </system> */
/* ↓の部分を追加 */
.entry-content p {
@fukamachi
fukamachi / g.hatena.ne.jp.js
Last active December 20, 2015 16:38
はてなグループで本文のはてな記法をコピーするdotjs
$(function() {
$('.section h3').each(function() {
var entry = $(this);
var permalink = entry.find('a').first().attr('href');
$.get(permalink + '?mode=json').success(function(data) {
var button = $('<button>').text('コピー');
button.on('click', function() {
window.prompt("Copy to clipboard: Ctrl+C, Enter", data['body']);
(defun git-blame-current-line ()
(interactive)
(let ((blame-result
(shell-command-to-string
(format "git blame -p -L %d,+1 %s" (line-number-at-pos) (buffer-file-name))))
(result (make-hash-table :test 'equal)))
(loop with (commit . lines) = (split-string blame-result "\n")
for line in lines
for (key . values) = (split-string (or line "") " ")
do (setf (gethash key result) (mapconcat 'identity values " "))