Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / clhs.lisp
Last active December 24, 2015 17:39
Common Lisp script to open a HyperSpec HTML which corresponds to a specified symbol. (Works only with SBCL on Mac)
#!/usr/bin/env sbcl --script
;; -*- mode: common-lisp -*-
;; Usage:
;; clhs [SYMBOL]
(require 'asdf)
(defparameter *hyperspec-home*
(merge-pathnames "Dropbox/Documents/HyperSpec/" (user-homedir-pathname))
@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 / 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