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 / test.cpp
Created October 20, 2011 17:44
IORef Int <-> Ptr CInt in FFI
#include "test.h"
void mutateint( int* p )
{
(*p) = 10 ;
}
@wavewave
wavewave / button.hs
Created December 25, 2011 10:29
gtk2hs: button example
import Graphics.UI.Gtk
import Control.Monad.Trans
main :: IO ()
main = do
putStrLn "file open test"
initGUI
window <- windowNew
@wavewave
wavewave / fileopen.hs
Created December 25, 2011 10:31
gtk2hs: fileChooserDialog example
import Graphics.UI.Gtk
import Control.Monad.Trans
import System.Directory
main :: IO ()
main = do
putStrLn "file open test"
initGUI
@wavewave
wavewave / listtest.hs
Created December 25, 2011 10:33
gtk2hs: ListStore and TreeView example
module Main where
{- an example how to select from a list
not satisfactory yet:
- there should be a simpler way to render a simple list
- i could not convert the model i got back to a list
from which to get the value
- the interface offers a great number of functions
and it is very difficult to find which ones are
really needed for simple tasks
@wavewave
wavewave / generator coroutine example
Created December 25, 2011 10:37
coroutine: generator example
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Data.Functor.Identity (Identity(..))
import Control.Monad.Coroutine
import Control.Monad.Trans
import Control.Concurrent hiding (yield)
import Data.IORef
@wavewave
wavewave / drawnotebook.hs
Created December 25, 2011 10:43
cairo: ruled notebook drawing example
module Main where
import Control.Applicative
import System.IO
import System.Environment
import Graphics.Rendering.Cairo
data RGBA = RGBA {
colorR :: Double,
@wavewave
wavewave / InitDevice.hs
Created December 25, 2011 10:50
gtk2hs: wacom xinput test
{-# LANGUAGE ForeignFunctionInterface #-}
module InitDevice (
initdevice
-- , extEventCanvas
) where
import Foreign.Ptr
import Foreign.C
@wavewave
wavewave / gunzip.hs
Created December 29, 2011 00:28
simple gunzip test
import Control.Monad
import qualified Data.ByteString.Lazy as B
import qualified Codec.Compression.GZip as GZip
import System.IO
main :: IO ()
main = do
putStrLn "gzip test"
withFile "testtest.hs.gz" ReadMode $ \h -> do
bcontents <- B.hGetContents h
@wavewave
wavewave / uuidtest.hs
Created December 29, 2011 02:26
uuid generation test
{-# LANGUAGE OverloadedStrings #-}
import Data.UUID.V5
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C
main :: IO ()
main = do
putStrLn "uuid creation test"
@wavewave
wavewave / script.hs
Created January 9, 2012 04:13
script for change absolute link to relative link
module Main where
import Control.Concurrent
import Control.Monad
import Data.UUID
import System.Directory
import System.FilePath
import System.Process
import System.Posix.Files