Skip to content

Instantly share code, notes, and snippets.

View funrep's full-sized avatar

Karl-Oskar Rikås funrep

View GitHub Profile
15:59 < ocharles> klrr_: that's euler integration
15:59 < ocharles> klrr_: the idea is that we assume the thing being integrated is a stepped graph
15:59 < ocharles> so we take the last produced value and multiple it by dt - which means we assume
that for dt seconds the value was the previous value
16:00 < ocharles> then we add that onto an accumulator
16:00 < ocharles> so we're approximing an integral by sampling at some frequency and assuming a
'rectangle' under the curve until the next instant
14:23 < Cale> klrr_: I'm not sure why there isn't a constB
import Control.Monad (when)
import qualified Graphics.UI.SDL as SDL
import qualified Graphics.UI.SDL.Image as Image
data Mouse = LeftButton | MiddleButton | RightButton
position :: IO (Int, Int)
position = SDL.getMouseState >>= \(x, y, _) -> return (x, y)
isDown :: Mouse -> IO Bool
module Tob.Config where
import Data.ConfigFile (readstring, emptyCP, get)
import Tob.Types
getConfig :: FilePath -> IO Config
getConfig f = do
s <- readFile f
let config = do
c <- readstring emptyCP s
import Text.ParserCombinators.Parsec
data Prefix = Prefix String String String deriving Show
data Command = Action String | Code Int deriving Show
data Params = Params [String] deriving Show
data Message = Message (Maybe Prefix) Command Params String deriving Show
@funrep
funrep / parser.hs
Created October 14, 2013 13:55
IRC parser
import Text.ParserCombinators.Parsec
data Prefix = Prefix String String String deriving Show
data Command = Action String | Code Int deriving Show
data Params = Params [String] deriving Show
data Message = Message (Maybe Prefix) Command Params String deriving Show
import Control.Monad.State (State, get, put, runState)
inc :: State Int ()
inc = fmap (+ 1) get >>= put
-- get returns the state's int
-- fmap applies (+ 1) on that int
-- >>= applies the result to put which makes it the current state
reset :: State Int ()
reset = put 0
(ns tob.core
(:import (java.net Socket)
(java.io PrintWriter InputStreamReader BufferedReader)))
(def codetalk {:name "irc.codetalk.io" :port 6667})
(def user {:name "tob" :nick "tob"})
(declare conn-handler)
(defn connect [server]
(ns tob.irc
(:import (java.net Socket)
(java.io PrintWriter InputStreamReader BufferedReader)))
(def codetalk {:name "irc.codetalk.io" :port 6667})
(def user {:name "tob the bot" :nick "tob"})
(declare conn-handler)
(defn connect [server]
(ns tob.core
(:require [tob.irc]))
(def irc (connect codetalk))
(defn -main [& args]
(do
(login irc user)
(write irc "JOIN #lobby")
(write irc "PRIVMSG #lobby : hai! im a lisp irc bot")