Skip to content

Instantly share code, notes, and snippets.

@pirapira
pirapira / gist:1506987
Created December 21, 2011 17:58
gather commit
UNSORTED = "/Users/yh/unsorted.txt"
require "shell"
require "find"
def emit(path)
s = Shell.new
s.cd path
@pirapira
pirapira / log
Created October 26, 2011 22:25
Async reading memo
async_core.mli:
deferred.mli: value to be determined later (that forms monad) / enable choose mechanism
clock.mli: defer until certain times
typed_tcp.mli: would be fun to use
writer.mli: reducing number of write() calls
#use "topfind";;
@pirapira
pirapira / gist:1307648
Created October 23, 2011 18:03
AudioInput.java
import java.io.*;
import java.io.BufferedWriter;
import java.text.*;
import java.util.*;
import javax.sound.sampled.*;
public class AudioInput implements Runnable{
public static void main(String args[]) {
AudioInput audioinput = new AudioInput();
@pirapira
pirapira / monitor.rb
Created July 14, 2011 13:44
http server monitor
#! /usr/local/bin/ruby
require 'net/http'
Net::HTTP.version_1_2
begin
r = Net::HTTP.start('example.com', 80) {|http|
res = http.get('/directory/file')
}
rescue
system('echo "NG" | mail -c addr@example.com -s "server faillure" addr2@example.com')
@pirapira
pirapira / gist:1045359
Created June 24, 2011 18:23
found the owner
Parameter person :Set.
Parameter thing: Set.
Parameter bottle: thing.
Parameter own: person -> thing -> Prop.
Parameter capitalist: forall (x: thing), { p:person & own p x }.
Definition owner: person.
generalize (capitalist bottle).
intros.
@pirapira
pirapira / gist:1045282
Created June 24, 2011 17:47
find the owner
Parameter person thing : Set.
Parameter own: person -> thing -> Prop.
Parameter capitalist: forall (x: thing), exists p:person, own p x.
Parameter bottle: thing.
Definition owner: person.
Admitted.
@pirapira
pirapira / Alg.v
Created May 4, 2011 13:54
Category of T-algebra in ConCaT
Require Import ConCaT.CATEGORY_THEORY.FUNCTOR.Functor.
Section alg_def.
Variables (A : Category) (T : Functor A A).
Structure Alg_ob : Type := {Ob_alg_ob : A; Mor_alg_ob : T Ob_alg_ob --> Ob_alg_ob}.
Section alg_arrow_def.

function-data/relation mapper

スキーマ

table mail {
    id int primary key,
    from_addr varchar[50],
    date datetime,
    mailbox varchar[50]

}

require 'rubygems'
require 'grit'
include Grit
repo = Repo.new(".")
def date(head)
head.commit.committed_date
end
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
enum dir {North, West, East, South, NONE};
unsigned int look_alt(int h, int w, int H, int W, enum dir dir, unsigned int *alt_map) {
#define ALT(m,n) *(alt_map + (m) * W + (n))
if (dir == North) {
if (h == 0)