Skip to content

Instantly share code, notes, and snippets.

View banacorn's full-sized avatar
🥺

Ting-gian LUA banacorn

🥺
View GitHub Profile
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (status200)
cedartrunk request = do
case referer of
Nothing -> return $ ResponseFile status200 [("Content-Type", "text/html")] "index.html" Nothing
Just _ -> return $ ResponseFile status200 [] path Nothing
where path = tail . tail . init . show . rawPathInfo $ request
data Tree a = Nil | Node a (Tree a) (Tree a) deriving (Eq)
data Inbalance = Balanced | LL | RR | LR | RL deriving (Show, Eq)
(+++) :: (Eq a, Ord a) => Tree a -> a -> Tree a
(+++) = insert
instance (Show a, Eq a) => Show (Tree a) where
show tree = draw tree (height tree) ++ "\n pre: " ++ show (preorder tree) ++ "\n in: " ++ show (inorder tree)
where

Reihe 10

Verben

  • fühlen
  • ändern // to change
  • leisten // to afford
  • überlegen // to think throughly
  • wünschen // to wish
  • vorstellen // to introduce / to imagine
@banacorn
banacorn / reihe9.md
Last active December 17, 2015 16:19

Reihe 9

Verben

  • steigen steigt // to climb
  • umsteigen umsteigt
  • aussteigen aussteiget
  • liegen liegt // to lie
  • legen legt
  • stehen steht
@banacorn
banacorn / Reihe8.md
Last active December 17, 2015 16:19

Reihe 8

Verben

  • telegrafieren telegrafiert
  • gratulieren gratuliert
  • wuenschen wuenscht
  • schicken schickt
  • gefallen gefaellt
  • bringen bringt
@banacorn
banacorn / banana.hs
Created May 23, 2013 15:52
生測資
import Control.Monad (mapM_)
import System.Random
import System.Cmd
import System.Environment (getArgs)
import Data.List (intercalate, nub)
type Size = Int
type Constraint = (Variable, Variable)
data Variable = Variable Int deriving (Eq)
data Map = Map Size Size [Constraint]
@banacorn
banacorn / list.c
Last active December 15, 2015 17:50
//
// HASKELL FTW
//
typedef const int Int;
typedef const int Bool;
// data List a = Cons a (List a) | Nil
typedef const enum ListType { Nil, Cons } ListType;
typedef const struct List {
adapter :: (Ptr CUChar -> CUInt -> Ptr CUChar -> Ptr CUInt -> IO CInt) -> Int -> String -> String
adapter function chunkSize content = map cuchar2char $ unsafePerformIO $ do
-- allocate buffers
inputBuffer <- mallocArray chunkSize
outputBuffer <- mallocArray chunkSize
outputSize <- mallocBytes 32
-- put it in
pokeArray inputBuffer (map char2cuchar content)
poke outputSize (fromIntegral chunkSize)
  • avenir
  • asap
  • oldenburg
  • museo slab
  • monda
  • economica
  • lato
  • iterstatecondmono
  • oxygen
  • rambla
@banacorn
banacorn / fib.hs
Created September 26, 2012 17:24
fib 1000000
import Data.List
import Data.Bits
fib :: Int -> Integer
fib n = snd . foldl' fib' (1, 0) . dropWhile not $
[testBit n k | k <- let s = bitSize n in [s-1,s-2..0]]
where
fib' (f, g) p
| p = (f*(f+2*g), ss)
| otherwise = (ss, g*(2*f-g))