Skip to content

Instantly share code, notes, and snippets.

@knzm
knzm / gist:5326271
Last active December 15, 2015 21:29
Sphinx で生成した HTML に改ページを埋め込む方法
  1. conf.py に以下の設定を追加する

    html_theme_options = {
        'nosidebar': True,
    }
    
  2. ドキュメントの先頭に以下の内容を書く

@knzm
knzm / gist:5364563
Created April 11, 2013 15:52
Memo: How to create a CentOS 4.8 VM image on VirtualBox using vagrant
# add vagrant box with using veewee
$ cd ~/vagrant
$ vagrant basebox define centos_48_i386 CentOS-4.8-i386
$ vi definitions/centos_48_i386/ks.cfg
$ vi definitions/centos_48_i386/definition.rb
$ cp /path/to/CentOS-4.8-i386-bin-DVD.iso iso/
$ vagrant basebox build centos_48_i386
$ vagrant basebox export centos_48_i386
$ vagrant box add centos_48_i386 centos_48_i386.box
@knzm
knzm / data.py
Last active December 16, 2015 10:48
tree traversal and transformation
class a0:
class b0:
class c0:
text = "1-1"
children = [0, 1, 2]
class c1:
text = "1-2"
children = [3, 4]
text = "1"
children = [c0, c1]
@knzm
knzm / Vagrantfile
Last active December 16, 2015 11:59
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
; て ゙ -> で
(while (re-search-forward "\\(.\\)゙" nil t)
(replace-match (char-to-string (1+ (string-to-char (match-string 1))))))
@knzm
knzm / haskell.py
Last active December 17, 2015 00:49
from __future__ import print_function
import operator
__all__ = [
"Monad",
"MonadPlus",
"Maybe",
"Just",
"Nothing",
@knzm
knzm / gist:5539689
Last active December 17, 2015 02:58
はじめての Cello

こんなコードを書いて

#include "Cello.h"

var hello = $(String, "Hello");

マクロを展開すると、こうなる (一部のみ)

@knzm
knzm / example.c
Last active December 17, 2015 03:08
Cello で lambda
#include "Cello.h"
int main(int argc, char** argv) {
lambda(add_print, args) {
int fst = as_long(cast(at(args, 0), Int));
int snd = as_long(cast(at(args, 1), Int));
println("%i + %i = %i", $(Int, fst), $(Int, snd), $(Int, fst + snd));
return None;
}
@knzm
knzm / example.c
Last active December 17, 2015 03:08
Cello で部分適用
#include "Cello.h"
int main(int argc, char** argv) {
lambda(add_print, args) {
int fst = as_long(cast(at(args, 0), Int));
int snd = as_long(cast(at(args, 1), Int));
println("%i + %i = %i", $(Int, fst), $(Int, snd), $(Int, fst + snd));
return None;
}
@knzm
knzm / example.c
Last active December 17, 2015 03:08
Cello で例外処理
#include "Cello.h"
try {
do_some_work();
} catch (e in TypeError, ClassError) {
if (e is TypeError) { print("Got TypeError!\n"); }
if (e is ClassError) { print("Got ClassError!\n"); }
}