Skip to content

Instantly share code, notes, and snippets.

View marcmo's full-sized avatar

Oliver Mueller marcmo

View GitHub Profile
-- n: the number of identical characters a before index i
-- k: the number of at most two different characters a and b before i
step :: (Eq a, Num t) => a -> (t, t, a, a) -> (t, t, a, a)
step x (n,k,a,b)
| x==a = (n+1,k+1,x,b)
| x==b = (1,k+1,x,a)
| otherwise = (1,n+1,x,a)
useStepBytestring :: B.ByteString -> B.ByteString
useStepBytestring bs
@marcmo
marcmo / .gvimrc
Last active December 11, 2015 07:08
syntax on
set gfn=Monospace\ 11
set guioptions-=T "remove toolbar
set lines=100
set columns=200
vmap <C-C> "+y
map <A-Left> :tabprevious<CR>
map <A-Right> :tabnext<CR>
" map <C-T> :tabnew<CR>
import Data.List(foldl')
data Operator = Plus | Minus | Div | Mult | None | Id Double deriving(Eq,Show)
operators = [Plus,Minus,Div,Mult,None]
higher :: Operator -> Operator -> Bool
higher None None = False
higher None _ = True
higher Div Plus = True
higher Div Minus = True
@marcmo
marcmo / VoltageFFI.hs
Created October 10, 2012 12:48
using quickcheck to simulate voltage curves
{-# LANGUAGE ForeignFunctionInterface #-}
module VoltageFFI
(
voltageStateC
,addListenerC
,normal_voltage
,voltageChangeC
,c_timeoutEvent
,c_tearDown
)
@marcmo
marcmo / simple.hs
Created July 21, 2012 14:14
simple hakyll site that escapes urls
{-# LANGUAGE OverloadedStrings, Arrows #-}
module Main where
import Prelude hiding (id)
import Data.Monoid(mempty)
import qualified Data.Map as M
import Control.Category (id)
import Control.Arrow((&&&),arr,(>>>),(>>^))
import Hakyll
@marcmo
marcmo / includeChecker.hs
Last active September 28, 2015 04:48
check for include paths in C/C++ files that contain wrongly cased characters change: only analyze ascii characters
{-# LANGUAGE OverloadedStrings #-}
import System.FilePath.FindCompat
import System.FilePath.Posix
import Control.Exception
import qualified Data.ByteString as BS
import qualified Data.Map as M
import Control.Applicative
import qualified Data.ByteString.Char8 as BSC
import Text.Regex
import Data.Maybe(isJust)
@marcmo
marcmo / app.js
Created April 26, 2011 15:41
doesn't work with the async stuff in line 23
var http = require('http'),
util = require('util'),
formidable = require('formidable'),
server;
global.TEST_PORT = 13532;
server = http.createServer(function(req, res) {
if (req.url == '/') {
res.writeHead(200, {'content-type': 'text/html'});
@marcmo
marcmo / LuaIntegration.hs
Created April 4, 2011 11:10
support for interpretation of a lua file
module LuaIntegration where
import qualified Scripting.Lua as Lua
lua_noerrors = 0
lua_yield = 1
lua_errrun = 2
lua_errsyntax = 3
lua_errmem = 4
@marcmo
marcmo / echoServer.hs
Created March 23, 2011 08:00
simple haskell program for sending over socket and receiving a response with a timeout
-- Echo server program
module Main where
import Control.Monad (unless,when)
import Network.Socket hiding (recv)
import qualified Data.ByteString as S
import Data.Word(Word8)
import Control.Concurrent(threadDelay)
import Data.List
import Numeric
# # usage
# require 'cxxproject'
#
# cxx_configuration "Test" do
# exe "bla", :source => FileList[*.arxml]
# lib "lib1", :source => "xxx/azzz/"
# end
CxxConfigs = []