Skip to content

Instantly share code, notes, and snippets.

@liuexp
liuexp / procedures.scm
Created August 13, 2013 15:56
primitive procedures for generating testcases.
;-- test maker guideline: use dirichlet to compose 2 mixture sets of pure numeric or pure boolean functions, next start random walking in this complete bipartite graph.
;-- numeric primitives: test for gap or strict equality to make it boolean
;-- fact
;-- gcd
;-- expmod
;-- square
;-- mean
;-- +
;-- -
;-- *
@liuexp
liuexp / all.scm
Last active December 21, 2015 00:48
sample compiled testcases
(define nil '())
; this is comment
( define ( caar pair ) ( car ( car pair ) ) )
( define ( cadr pair ) ( car ( cdr pair ) ) )
( define ( cdar pair ) ( cdr ( car pair ) ) )
( define ( cddr pair ) ( cdr ( cdr pair ) ) )
( define ( caaar pair ) ( car ( car ( car pair ) ) ) )
( define ( caadr pair ) ( car ( car ( cdr pair ) ) ) )
( define ( cadar pair ) ( car ( cdr ( car pair ) ) ) )
@liuexp
liuexp / test.scm
Last active December 20, 2015 21:49
raw
(display "This is a compiled test by Liuexp.")
(display "把我打印出来")
(define LIUEXP 1)
(and
#t ;我是注释
(not #f)
(equal? (* 111111111 111111111) 12345678987654321)
(equal? (+ 11111 11111) 22222)
(
@liuexp
liuexp / stdlib.scm
Last active December 20, 2015 21:49
zzz
(define nil '())
; this is comment
( define ( caar pair ) ( car ( car pair ) ) )
( define ( cadr pair ) ( car ( cdr pair ) ) )
( define ( cdar pair ) ( cdr ( car pair ) ) )
( define ( cddr pair ) ( cdr ( cdr pair ) ) )
( define ( caaar pair ) ( car ( car ( car pair ) ) ) )
( define ( caadr pair ) ( car ( car ( cdr pair ) ) ) )
( define ( cadar pair ) ( car ( cdr ( car pair ) ) ) )
@liuexp
liuexp / z.md
Last active August 13, 2020 15:01
Building hadoop-2.0.5

If you're building hadoop-2.0.5 with JDK 7 and experience issues such as:

    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] /home/liuexp/Downloads/hadoop-2.0.5-alpha-src/hadoop-hdfs-project/hadoop-hdfs/target/generated-sources/java/org/apache/hadoop/hdfs/protocol/proto/InterDatanodeProtocolProtos.java:[122,37] error: cannot find symbol
    [ERROR]   symbol:   class Parser
      location: package com.google.protobuf
    /home/liuexp/Downloads/hadoop-2.0.5-alpha-src/hadoop-hdfs-project/hadoop-hdfs/target/generated-sources/java/org/apache/hadoop/hdfs/protocol/proto/InterDatanodeProtocolProtos.java:[133,30] error: cannot find symbol

[ERROR] symbol: class Parser

@liuexp
liuexp / agt.hs
Created June 17, 2013 10:59
agt stuff
-- Max VCG by dp (let's forget about memoization for a moment, and that actually 1D dp is enough)
-- usage : [vcg i j [13,11,1] [7,5,3,1] | i<-[0..3], j<-[0..2]]
vcg 0 _ q v = head q * (v!!1)
vcg _ 0 q v = fromIntegral (minBound :: Int)
vcg i j q v |j<i = fromIntegral (minBound :: Int)
|otherwise = max (vcg i (j-1) q v) $ vcg (i-1) (j-1) q v + (q!!j)*(fromIntegral (j+1)*v!!(j+1) - fromIntegral j*(v!!j))
vcgPrice j q v = (q!!j)*(v!!(j+1)) + sum [(v!!(t+1) - v!!t) * q!!t | t<-[j+1..(length q - 1)]]
--vcgUtility j q v =
public static Field fromBytes(byte[] y){
ByteBuffer buf = java.nio.ByteBuffer.wrap(y);
int length=0;
int type = buf.getInt();
switch(type){
case java.sql.Types.BOOLEAN:
return new BOOL(buf.get()==0?false:true);
case java.sql.Types.CHAR:
// FIXME this should be fixed-length
length = buf.getInt();
{-# OPTIONS_GHC -XFlexibleInstances #-}
{-# OPTIONS_GHC -XTypeSynonymInstances #-}
{-# OPTIONS_GHC -O2 #-}
module Main where
import Data.List.Ordered(union,minus,nub)
import Data.List hiding(union,nub)
import Data.Set(Set)
import Data.Map(Map)
import qualified Data.Set as DS
@liuexp
liuexp / gist:4036794
Created November 8, 2012 04:28
show in hex in ghci
show16 = concatMap (\x -> [(['0'..'9']++['a'..'z'])!!x]) . digits 16
@liuexp
liuexp / rev25070.patch
Created November 3, 2012 05:10
patch for xen-unstable-rev25070
diff -r bf249cd5f2c1 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Oct 30 18:12:11 2012 +0000
+++ b/tools/firmware/hvmloader/Makefile Sat Nov 03 13:05:29 2012 +0800
@@ -66,6 +66,7 @@
ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
endif
+PTVGA_ROM := ../vgabios/vgabios-pt.bin
ifeq ($(CONFIG_SEABIOS),y)