This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ForeignFunctionInterface #-} | |
import Foreign | |
import Foreign.C.Types | |
import Control.Applicative | |
foreign import ccall "stdlib.h qsort" | |
c_qsort :: Ptr a | |
-> CSize | |
-> CSize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc -B/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/. -dynload wrapped ${1+"$@"} -optc-m32 -opta-m32 -optl-m32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert("Hello from gist"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude() | |
import Prelude.Plus | |
import Data.Char | |
import Data.Maybe | |
import Network.Socket | |
import qualified Network.IRC as I | |
import Control.Concurrent | |
import Data.Time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Prelude() | |
import Prelude.Plus | |
type Repeating = [] | |
findRepeatings :: Eq a => [a] -> [Repeating a] | |
findRepeatings = concatMap findRepeatingsStartFromHere . tails | |
findRepeatingsStartFromHere :: Eq a => [a] -> [Repeating a] | |
findRepeatingsStartFromHere = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
definr () { | |
curl http://www.definr.com/definr/show/${1// /+} 2>/dev/null \ | |
| perl -ple 's/ / /g; s/<.+?>//g;' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir manual && cd manual | |
git init | |
git fetch-pack git://git.kernel.org/pub/scm/git/git.git man html | | |
while read a b | |
do | |
echo $a >.git/$b | |
done | |
cp .git/refs/heads/man .git/refs/heads/master | |
git checkout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(This code uses Data.{Reflection,Tagged} which are not in standard | |
modules, So you need to run "cabal install reflection" to install | |
them before loading it) | |
Normally, in LL (Lightweight Languages) such as Ruby or Perl, mocking | |
is very easy. It means just overwriting a function to be mocked. But I | |
want to do this in haskell. Every functions are immutable, so I can't | |
overwrite it. | |
So, in LL, If overwriting is not apporopriate, as usual, mocked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- trace of http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf | |
import Foreign | |
import Foreign.Storable | |
import Foreign.C.Types | |
data Zero; data Succ n; data Pred n; data Twice n; | |
class ReflectNum s where reflectNum :: Num a => s -> a | |
instance ReflectNum Zero where reflectNum _ = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Send | |
class << self | |
def method_missing meth, *holes_or_args, &block | |
do_send = -> args { | |
-> receiver { | |
receiver.__send__(meth, *args, &block) | |
} | |
} | |
if holes_or_args.any? { |hoa| hoa == Hole } | |
-> *args_for_holes { |
NewerOlder