Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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: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 / IOtt.v
Created September 27, 2012 07:53
proving monad laws for something.
(**
IOtt functor from
Swierstra, Wouter, and Thorsten Altenkirch. "Beauty in the Beast."
In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop.
Haskell '07. ACM, 2007. http://doi.acm.org/10.1145/1291201.1291206.
**)
Require Import Logic.FunctionalExtensionality.
Inductive IOtt (a: Set) : Set :=
/usr/bin/ld: cannot find -lLLVMLinker
/usr/bin/ld: cannot find -lLLVMX86Disassembler
/usr/bin/ld: cannot find -lLLVMX86AsmParser
/usr/bin/ld: cannot find -lLLVMX86CodeGen
/usr/bin/ld: cannot find -lLLVMSelectionDAG
/usr/bin/ld: cannot find -lLLVMAsmPrinter
/usr/bin/ld: cannot find -lLLVMX86Desc
/usr/bin/ld: cannot find -lLLVMMCDisassembler
/usr/bin/ld: cannot find -lLLVMX86Info
/usr/bin/ld: cannot find -lLLVMX86AsmPrinter
Require Import ssreflect ssrbool eqtype ssrnat seq ssrfun fintype.
Ltac 破 := case.
Ltac 解 := elim.
Ltac 動 := move.
Ltac 割 := split.
Ltac 矣 := done.
Ltac 用 := apply.
Ltac 在 := exists.
@pirapira
pirapira / example1.v
Last active August 30, 2016 19:38
An analysis of an Ethereum contract.
(* Coq 8.5pl5 with ssreflect 1.5. *)
(* Can be interesting to read this in Emacs with ProofGeneral 4.3pre150930. *)
(* There, maybe repeat `proof-assert-next-command-interactive`. *)
Require Import String.
Require Import List.
Require Import FMapInterface.
Require Import ssreflect ssrbool.
> src0 = "contract Events { function getEvent(bytes32 eventHash) returns (int a, int b, int c, int d, int e) {}}"
> src1 = "contract Events { function getEvent(bytes32 eventHash) returns (int a, int b, int c, int d, int e);} contract test { function foo(address addr) { Events events = Events(addr); var (,,,,) = events.getEvent(0); } }"
> admin.setSolc("./src/solidity/build-develop/solc/solc")
> eth.compile.solidity(src0)
> contracts0 = eth.compile.solidity(src0)
> contracts1 = eth.compile.solidity(src1)
TIMESTAMP
JUMPDEST
BALANCE
DUP1
JUMP
JUMPDEST
BALANCE
DUP1
JUMP
JUMPDEST