Skip to content

Instantly share code, notes, and snippets.

@tomykaira
tomykaira / Base64.h
Created July 10, 2016 17:11
C++ single header base64 decode/encoder.
View Base64.h
#ifndef _MACARON_BASE64_H_
#define _MACARON_BASE64_H_
/**
* The MIT License (MIT)
* Copyright (c) 2016 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 / rack.md
Created May 19, 2012 17:17
Brief Introduction to Rack -- from codereading activity
View rack.md

Brief Introduction to Rack

@tomy_kaira

Rack

Specification

for communication between Server and Ruby WAF

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

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 / counting-tweet.js
Created November 28, 2011 06:08
Character count for twitter. URLs are taken into consideration. Twitter 向けの簡易語数カウンタ。t.co による URL 圧縮も考慮します。
View counting-tweet.js
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
View subpatch.sh
#!/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"
View corvusskk-kana.txt
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.
View git-rebase--interactive-full.sh
#!/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
View LICENSE
The MIT License (MIT)
Copyright (c) 2017 Rusoto Project Developers
Copyright (c) 2020 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
@tomykaira
tomykaira / wire-rack-fastener.scad
Created September 17, 2021 13:32
Wire rack fastener
View wire-rack-fastener.scad
$fn = 100;
// dimension: mm
wire_dia = 1.5;
screw_head_dia = 9.0;
screw_hole_dia = 4.0;
head_width = 25;
head_height = 25;
fillet = 2;
@tomykaira
tomykaira / wthor.rb
Created August 10, 2012 01:40
parser for WTHOR file (othello, reversi)
View wthor.rb
#!/usr/bin/env ruby
# parser for WTHOR file
# Copyrihgt (c) tomykaira 2012
# Lisence: MIT
filenames = ARGV.length == 0 ? ["WTH_2000/WTH_2000.WTB"] : ARGV
CLEAN = true
filenames.each do |fn|