Skip to content

Instantly share code, notes, and snippets.

View y-yu's full-sized avatar

YOSHIMURA Yuu y-yu

View GitHub Profile
@y-yu
y-yu / hamming.ml
Last active August 29, 2015 14:00
type tree =
T of int * child list
and
child = unit -> tree
let rec mktree n =
let f i = fun () -> mktree i in
(T (n, [f (n * 2); f (n * 3); f (n * 5)]))
let less (T(v1, _)) (T(v2, _)) = v1 < v2
\linespace{\section{見出し}} % 自動で何行取るのか計算される
\linespace[3]{\section{見出し}} % 何行取るか手動で入れる
@y-yu
y-yu / pagenum.pl
Last active August 29, 2015 13:58
ページ番号を振るCGI
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use File::Copy;
@y-yu
y-yu / 8-2.ml
Created January 8, 2014 09:28
8-2
type cam_value =
| CAM_IntVal of int
| CAM_BoolVal of bool
| CAM_ClosVal of cam_code * cam_env
and cam_stack = cam_value list
and cam_env = cam_value list
and cam_instr =
| CAM_Ldi of int
| CAM_Ldb of bool
| CAM_Access of int
@y-yu
y-yu / graph.tex
Created December 14, 2013 17:17
graph
\documentclass{standalone}
\usepackage{etex}
\usepackage{metalogo}
\usepackage{tikz}
\def\pTeX{p\TeX}
\def\epTeX{$\varepsilon$-\pTeX}
\def\upTeX{u\pTeX}
\def\eupTeX{$\varepsilon$-\upTeX}
\def\pdfTeX{\lower 2pt\hbox{pdf}\TeX}
@y-yu
y-yu / code.tex
Created December 4, 2013 05:16
code inside section
\makeatletter
\def\code{%
\@ifnextchar{|}%
{\code@sect}%
{\code@inline}%
}
\def\code@inline#1{%
\lstinline[style=ocaml, basicstyle=\small\tt, keywordstyle=\small\sl, columns={fullflexible,keepspaces}, mathescape]|#1| }
@y-yu
y-yu / textarea-mode-mappning.js
Created December 3, 2013 01:25
TEXTAREA mode key mapping on Vimperator
(function () {
function textareaMap (lhs, rhs) {
let noremap = true,
silent = true,
urls = void 0;
rhs = mappings._expandLeader(rhs);
mappings.addUserMap(
[modes.TEXTAREA],
@y-yu
y-yu / unko.cpp
Created December 2, 2013 15:16
unko
void CalcLambertModel(float outColor[3], const float ViewDir[3], const float Normal[3])
{
float cos = Vec3Dot(g_LightDir, Normal) / ( Vec3Norm(g_LightDir) * Vec3Norm(Normal) );
Vec3Set(outColor,
g_AmbientColor[0] + g_LightColor[0] * g_DiffuseColor[0] * cos,
g_AmbientColor[1] + g_LightColor[1] * g_DiffuseColor[1] * cos,
g_AmbientColor[2] + g_LightColor[2] * g_DiffuseColor[2] * cos);
}
@y-yu
y-yu / hoge.pl
Last active December 29, 2015 23:59
hoge.pl
use strict;
use warnings;
my $l = <STDIN>;
chomp $l;
my ($item_num, $campaign_num) = split / /, $l;
my @items;
for (1..$item_num) {
@y-yu
y-yu / ex.cpp
Last active December 29, 2015 09:49
map example
std::array<int, 5> a = {1, 2, 3, 4, 5};
std::array<char, 5> b = {'a', 'b', 'c', 'd', 'e'};
// 前に作ったzip
auto z1 = zip<5>(a, b);
// map
auto z2 = map<5>(
[](int x, char y) -> std::tuple<int, char> {
return std::make_tuple(x, y);