Skip to content

Instantly share code, notes, and snippets.

View wavewave's full-sized avatar

Ian-Woo Kim wavewave

  • San Francisco, CA, USA
View GitHub Profile
@wavewave
wavewave / typelittest.hs
Created May 18, 2014 20:20
Haskell type-level literal test (ghc 7.8.2)
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ExplicitForAll #-}
import GHC.TypeLits
data Proxy (a :: Nat) = Proxy
@wavewave
wavewave / ATLAS2011.yaml
Last active August 29, 2015 13:56
atlas2011 yaml description
Name: ATLAS2011
Class: TopLevel
Description: ATLAS 2011 detector description
Reference: arXiv:xxxx.yyyy
Comment: extracted the efficiencies from the plot 3,4,5 in the reference
ValidationInfo: Validated on 2014/02
Object:
Electron:
Import: Electron_Loose_ATLAS
Photon:
@wavewave
wavewave / test.cpp
Last active December 22, 2015 02:39
closure in C++ : capturing a variable and send it as a function pointer
#include <boost/optional.hpp>
#include <boost/bind.hpp>
#include <boost/preprocessor/slot/counter.hpp>
#include <iostream>
#include <ostream>
using namespace std;
template<unsigned ID,typename Functor>
boost::optional<Functor> &get_local()
{
@wavewave
wavewave / CallBacker.hs
Created September 1, 2013 15:10
haskell callback with captured variable
module Main where
import Foreign.C.Types
import Foreign.Ptr
foreign import ccall "wrapper"
wrap :: (CDouble -> CDouble) -> IO (FunPtr (CDouble -> CDouble))
foreign import ccall "callerback.h twice"
twice :: FunPtr (CDouble -> CDouble) -> CDouble -> IO CDouble
@wavewave
wavewave / comonad.hs
Created July 10, 2013 17:35
Store comonad idiom study with arrow combinators
import Control.Applicative
import Control.Arrow
import Control.Comonad
import Control.Comonad.Trans.Store
cget :: Store Int a -> Int
cget = pos
cput :: Store Int Int -> Store Int Int
cput wf = seek (extract wf) wf
@wavewave
wavewave / SnappyGen.hs
Created June 9, 2013 04:54
fficxx example for snappy library
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Monoid (mempty)
import System.FilePath ((</>))
import System.Directory (getCurrentDirectory)
import Text.StringTemplate hiding (render)
--
import FFICXX.Generate.Code.Cabal
import FFICXX.Generate.Code.Cpp
import FFICXX.Generate.Code.Dependency
@wavewave
wavewave / index.html
Last active October 14, 2018 16:47
ghcjs canvas example
<!DOCTYPE html>
<html>
<head>
<script language="javascript" src="lib.js"></script>
<script language="javascript" src="rts.js"></script>
<script language="javascript" src="lib1.js"></script>
<script language="javascript" src="out.js"></script>
</head>
<body>
<canvas id="mycanvas" width="600" height="400"></canvas>
@wavewave
wavewave / HistFactorySchema.dtd
Last active December 17, 2015 14:08
hist2workspace (RooFit/RooStats) simplest example
<!-- The top level combination spec -->
<!-- OutputFilePrefix: Prefix to the output root file to be created (inspection histograms) -->
<!-- Mode: Type of the analysis -->
<!ELEMENT Combination (Function*,Input+,Measurement*)>
<!ATTLIST Combination
OutputFilePrefix CDATA #REQUIRED
Mode CDATA #IMPLIED
>
@wavewave
wavewave / A.hs
Created May 19, 2013 23:27
recursive module import using hs-boot and cabal
module A where
import {-# SOURCE #-} B
data Atyp = Atyp Btyp
@wavewave
wavewave / createlink.hs
Last active December 15, 2015 17:39
Create a hyperlink in pdf file using pdf-toolbox