Skip to content

Instantly share code, notes, and snippets.

function dateCheck(year, month, day) {
var mon = month - 1;
var date = new Date(year, mon, day);
if(day !== date.getDate() || mon !== (date.getMonth()) || year !== (1900 + date.getYear())) {
return false;
}
return true;
}
trait Component[A <: Component[A]]
trait Drawable[A <: Drawable[A] with Coordinates[A]] extends Component[A]
trait Coordinates[A <: Coordinates[A]] extends Component[A] {
def x: Int
def y: Int
}
$ cabal install llvm
Resolving dependencies...
Downloading llvm-base-3.0.1.0...
[1 of 1] Compiling Main ( /tmp/llvm-base-3.0.1.0-5657/llvm-base-3.0.1.0/Setup.hs, /tmp/llvm-base-3.0.1.0-5657/llvm-base-3.0.1.0/dist/setup/Main.o )
Linking /tmp/llvm-base-3.0.1.0-5657/llvm-base-3.0.1.0/dist/setup/setup ...
Configuring llvm-base-3.0.1.0...
configure: WARNING: unrecognized options: --with-gcc
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
@scan
scan / app.hs
Created July 28, 2012 18:40
app.hs
application :: MVar ServerState -> WS.Request -> WS.WebSockets WS.Hybi10 ()
application state rq = do
WS.acceptRequest rq
WS.getVersion >>= liftIO . putStrLn . ("Client version: " ++)
sink <- WS.getSink
msg <- WS.receiveData
clients <- liftIO $ readMVar state
url <- liftIO fbUrl
let prefix = "Facebook code "
http = require 'http'
for url, i in urls then do (url, i) ->
if url.match /^http/i
try
req = http.request (require 'url').parse(url), (res) ->
console.log "##{i}: Fehler #{res.statusCode} bei \"#{url}\"" if res? and res.statusCode isnt 200
req.on 'error', (err) ->
console.log "##{i}: Fehler \"#{err.message}\" bei \"#{url}\""
req.end()
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1356:20)
at TCP.onread (net.js:404:27)
@scan
scan / CMakeLists.txt
Created July 25, 2012 23:32
Bison/Flex and LLVM standard CMake file
cmake_minimum_required(VERSION 2.8)
find_package(BISON)
find_package(FLEX)
add_definitions(-D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS)
BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
FLEX_TARGET(MyScanner tokens.l ${CMAKE_CURRENT_BINARY_DIR}/tokens.cpp)
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
module Main where
import Prelude hiding (id, (.))
import Control.Category
import Control.Arrow
newtype Auto b c = Auto (b -> (c, Auto b c))
instance Category Auto where
id = Auto $ \a -> (a, id)
module Math.Frustum where
import Data.List (foldl')
import Data.Vect.Float
data Plane = Plane { plNormal :: Vec3, plDist :: Float }
newtype Frustum = Frustum { frPlanes :: [Plane] }
pointInFrustum :: Vec3 -> Frustum -> Bool
{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-}
module Loader.Obj where
import Control.Applicative ((<$>), (<*>))
import Data.Vect.Float
import System.IO (readFile)
import Text.Parsec
import qualified Text.Parsec.Token as P
import Text.Parsec.Language (haskellDef)