Skip to content

Instantly share code, notes, and snippets.

@fukamachi
fukamachi / gist:6462977
Last active December 22, 2015 10:59
"Autoload" facility for Common Lisp which is similar to what Emacs Lisp has.
;; Macros in this file provides a "autoload" facility like Emacs Lisp has.
;; These are supposed to be used in a Lisp init file.
;;
;; Without those, you have to load all libraries you not sure whether they will be used or not.
;;
;; (ql:quickload :repl-utilities)
;; (use-package :repl-utilities)
;;
;; "Autoload" facility delays loading libraries until they are needed.
;; See the following 3 macros and their documentations.
@fukamachi
fukamachi / hello-world.lisp
Last active December 22, 2015 08:38
Print "Hello World" to the *standard-output* without using integer, string and character literals in Common Lisp.
;; This is a answer for a question of CodeIQ.
;; https://codeiq.jp/ace/cielavenir/q431
(in-package :cl-user)
(defmacro print-capitalized (symbol &rest symbols)
`(progn
(princ ,(string-capitalize symbol))
,@(loop for s in symbols
collect `(princ ,(name-char 'space))
@fukamachi
fukamachi / gist:6364983
Last active May 8, 2022 03:04
A Common Lisp function to extract a tarball (.tar.gz) file to a directory (*default-pathname-defaults*).
(ql:quickload '(chipz archive))
(defun extract-tarball (pathname)
"Extract a tarball (.tar.gz) file to a directory (*default-pathname-defaults*)."
(with-open-file (tarball-stream pathname
:direction :input
:element-type '(unsigned-byte 8))
(archive::extract-files-from-archive
(archive:open-archive 'archive:tar-archive
(chipz:make-decompressing-stream 'chipz:gzip tarball-stream)
@fukamachi
fukamachi / shlyfile.lisp
Created August 27, 2013 00:09
A small Common Lisp program to sum up file sizes from `ls -l`.
;; https://twitter.com/potix2/status/371962749246394368
;; Usage
;; $ ls -l | shly sumsize
(ql:quickload :cl-ppcre)
(defun sumsize ()
(loop with sum = 0
for line = (read-line *standard-input* nil)
while line
(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 " "))
@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']);
@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 / 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 / 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: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))))