Skip to content

Instantly share code, notes, and snippets.

@tomykaira
tomykaira / partial_evaluation.md
Created July 22, 2012 14:55
Partial Evaluation, Futamura Projection And Their Applications

Partial Evaluation, Futamura Projection And Their Applications

What Partial Evaluation Is?

Partial evaluation means to fix some variables in the given code before execution. With a traditional implementation of a compiler or an interpreter, all variables are replaced with its value on each evaluation of that variable. This is because a variable can change at any timing. This is, however, not always true in actual applications. Almost all of large applications has setting variables and data

@tomykaira
tomykaira / core.clj
Created October 29, 2011 01:20
save your followers in neo4j
(ns friends-relationship-twitter.core
(:require [borneo.core :as neo]
twitter
[oauth.client :as oauth]))
(def oauth-consumer (oauth/make-consumer "KEY"
"SECRET"
"https://api.twitter.com/oauth/request_token"
"https://api.twitter.com/oauth/access_token"
"https://api.twitter.com/oauth/authorize"
@tomykaira
tomykaira / cljdoc.el
Created November 22, 2011 18:35
cljdoc.el --- eldoc mode for clojure
;;; cljdoc.el --- eldoc mode for clojure
;; Copyright (C) 2011 tomykaira
;; Version 0.1.0
;; Keywords: eldoc clojure
;; Author: tomykaira <tomykaira@gmail.com>
;; URL: https://gist.github.com/1386472
;; This file is not part of GNU Emacs.
@tomykaira
tomykaira / Base64.h
Last active July 17, 2024 19:35
C++ single header base64 decode/encoder for C++ 11 and above.
#ifndef _MACARON_BASE64_H_
#define _MACARON_BASE64_H_
/**
* The MIT License (MIT)
* Copyright (c) 2016-2024 tomykaira
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@tomykaira
tomykaira / white_balance.cpp
Last active June 1, 2023 08:46
Simplest white balance in OpenCV
// The MIT License (MIT)
// Copyright (c) 2015 tomykaira
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON
@tomykaira
tomykaira / rack.md
Created May 19, 2012 17:17
Brief Introduction to Rack -- from codereading activity

Brief Introduction to Rack

@tomy_kaira

Rack

Specification

for communication between Server and Ruby WAF

@tomykaira
tomykaira / counting-tweet.js
Created November 28, 2011 06:08
Character count for twitter. URLs are taken into consideration. Twitter 向けの簡易語数カウンタ。t.co による URL 圧縮も考慮します。
function count_rest (text) {
var limit = 140;
// take t.co shorten into account
// https://dev.twitter.com/blog/next-steps-with-the-tco-link-wrapper
var regex = /(?:https?\:\/\/|www\.)[^\s]+/g;
var noURL = text.replace(regex, "");
var URLs = text.match(regex);
var length = noURL.length;
@tomykaira
tomykaira / subpatch.sh
Created July 10, 2015 06:55
save and apply patches for git submodules
#!/bin/sh -e
separator="----8<----8<----8<----8<----"
function make_chunk {
cd $1
if ! git diff --exit-code --ignore-submodules --quiet; then
echo "${PWD#$root}/"
git --no-pager diff --no-color --ignore-submodules
echo "$separator"
a あ ア ア 0
i い イ イ 0
u う ウ ウ 0
e え エ エ 0
o お オ オ 0
ka か カ カ 0
ki き キ キ 0
ku く ク ク 0
ke け ケ ケ 0
ko こ コ コ 0
@tomykaira
tomykaira / git-rebase--interactive-full.sh
Created September 27, 2012 14:24
Specify rebase comment in git-rebase-todo instantly. \\ in the comment will be replaced with \n on commit.
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
# SHORT DESCRIPTION
#
# This script makes it easy to fix up commits in the middle of a series,
# and rearrange commits.
#
# The original idea comes from Eric W. Biederman, in