Skip to content

Instantly share code, notes, and snippets.

@omasanori
omasanori / gist:7959952
Last active July 16, 2023 08:26
msgpack-rustをrustpkg化してTravis CIで継続的インテグレーションする話

msgpack-rustをrustpkg化してTravis CIで継続的インテグレーションする話

表題の通りです。

msgpack-rustとは

msgpack-rust_MessagePack_のRustによる実装の一つで、私が書いたものです。まだ実装していない機能が多いです。はい、がんばります。

@omasanori
omasanori / gist:7858569
Last active April 25, 2025 08:53
Rustのパターンマッチの話

Rustのパターンマッチの話

既に穴だらけですが、やれるだけやっていきます。今回はパターンマッチの話です。

TL;DR(経験者向け)

はい、あなたのよく知るパターンマッチです。ガードも使えますが、他の言語でガードを使うパターンの一部はOCamlのorパターンと同等の機能や範囲を表す機能によって置き換えることができます。

@omasanori
omasanori / rust-day-3.rst
Last active April 12, 2016 16:34
5分で分かったふりができるRust紹介

5分で分かったふりができるRust紹介

作成者にもかかわらず、いきなり遅刻しました。ごめんなさい。`Rust Advent Calendar 2013`_、今からでも参加できますのでぜひ。

今日はRustの特徴を簡潔に紹介します。

システムプログラミング & 低レイヤ

@omasanori
omasanori / tml-day-1.rst
Last active December 29, 2015 23:39
Teach Myself Lojban Advent Calendar 2013: Day 1

Teach Myself Lojban Advent Calendar 2013, Day 1

これは`Teach Myself Lojban Advent Calendar 2013`_の1日目のコラムです。

Teach Myself Lojban Advent Calenadar 2013とは

最近、私はロジバン_ (Lojban) という人工言語に興味を持ったので、アドベントカレンダー[#]_を口実にロジバンについて学び、理解したことを日々文章に書き出し、この年末を過ごそうという企画。初日から大遅刻。先が思いやられる……。

fn seq_lt<A: Eq + Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
loop {
match (a.next(), b.next()) {
(None, None) => return false,
(None, _ ) => return true,
(_, None) => return false,
(Some(x), Some(y)) => if !x.eq(&y) { return x.lt(&y) }
}
}
}
@omasanori
omasanori / gist:6137580
Created August 2, 2013 04:52
an error log when I tried to build extra::unicode.
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: using gcc
cfg: no node found, omitting docs
cfg: no llnextgen found, omitting grammar-verification
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc
error: linking with `cc` failed with code 1
@omasanori
omasanori / garbage-collection-advent-calendar-2012.mkd
Created December 20, 2012 05:42
20th article on Garbage Collection Advent Calendar 2012

PyPyのGCに挑戦した……けど……な話

これは[Garbage Collection Advent Calendar 2012][gcac2012]の20日目の文書として @omasanori がPyPyのGCを解説する……はずでしたが、期日までに理解しきれませんでした。すみません。

そこで、ここでは私が現時点でどこまで理解できたか、これからどこを読んでいくか、という途中経過を記すことにします。GC初心者視点なのでGC上級者には物足りない文章になっていると思います。

はじめに

[PyPy][pypy]はRestricted Python (RPython)と呼ばれるPythonのサブセットを中心としたインタプリタ実装ツールキットと、それを利用したPythonの処理系です。Pythonの処理系としての印象が強いですが、RPythonとツールキットの部分は他のインタプリタを実装するために利用することも可能です。

;;; See also
;; http://d.hatena.ne.jp/mkut/20111226/1324907006
;; http://blog.livedoor.jp/dankogai/archives/51763038.html
;; My straightforward but naive solution.
(defn naive-map-between
[f coll]
(lazy-seq
(let [[x y] coll]
(when (and x y)
@omasanori
omasanori / bf.clj
Created December 19, 2011 07:53
A Brainfuck interpreter written in Clojure
;;; bf.clj --- A Brainfuck interpreter written in Clojure
;; The idea to implement loop instructions without waste of stack
;; is borrowed from a interpreter by Blake Williams, available at
;; https://github.com/BlakeWilliams/Clojure-Brainfuck
;;; Data Constructors and Manipulators
;; TODO(omasanori): Consider writing a macro to remove duplication of code.
(defn valid-address?
"Returns true if `address` is valid, otherwise false."
[address]
@omasanori
omasanori / generate_boundary.clj
Created December 15, 2011 12:14
A small library to generate boundaries for multipart/form-data and so on.
(ns generate-boundary)
(defn- char-range
"Returns a lazy seq of characters between `start` and `end`.
Unlike clojure.core/range, `end` is included in the results.
e.g. (= \9 (last (char-range \0 \9)))"
[start end]
(map char (range (int start) (inc (int end)))))
(def ^:dynamic *characters*