Skip to content

Instantly share code, notes, and snippets.

View billdozr's full-sized avatar

Alen Ribic billdozr

View GitHub Profile
data BSTree a = Empty | Node (BSTree a) a (BSTree a)
deriving (Show, Eq)
insert :: (Ord a) => a -> BSTree a -> BSTree a
insert x Empty = Node Empty x Empty
insert x (Node l v r)
| x < v = Node (insert x l) v r
| v < x = Node l v (insert x r)
| otherwise = (Node l x r)
@billdozr
billdozr / gist:3175290
Created July 25, 2012 09:33
Simple distributed Ping
{-# LANGUAGE TemplateHaskell, DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Main where
import System.Environment (getArgs, getProgName)
import Data.Typeable
import Data.Binary
import Control.Concurrent (threadDelay)
import Control.Distributed.Process.Backend.SimpleLocalnet
import Control.Distributed.Process
import Control.Distributed.Process.Node hiding (newLocalNode)
@billdozr
billdozr / gist:3071732
Created July 8, 2012 16:44
Tic-tac-toe in Haskell
import Data.Maybe (isNothing, fromJust)
import Data.List (intercalate)
import Char (toUpper)
import System.IO (hFlush, stdout)
data Move = O | X
deriving (Eq, Show, Enum, Ord)
type Position = (Char, Int)
data BoardMove = BoardMove
{ bMove :: Maybe Move, bPos :: Position }
(ns myprj.data.core
(:require myprj.data.conf :as conf]
[myprj.data.routes :as routes])
(:use [ring.adapter.jetty :only [run-jetty]]))
(let [port (Integer/parseInt (get (System/getenv) "PORT" "8080"))]
(defonce ^:dynamic *server* (run-jetty #'routes/core
{:port port :join? false
:host (:domain conf/site)})))
/Users/alen/.xmonad/xmonad-i386-darwin: executeFile: does not exist (No such file or directory)
X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 2 (X_ChangeWindowAttributes)
Serial number of failed request: 7
Current serial number in output stream: 8
ch24_prolog.lisp:119:1:
style-warning:
The variable REFS is defined but never used.
--> PROGN EVAL-WHEN
==>
(SB-IMPL::%DEFUN 'MATCH1
(SB-INT:NAMED-LAMBDA MATCH1
(REFS THEN ELSE)
(BLOCK MATCH1
(DBIND (# . REST)
;;; === common lib
(defmacro aif (test-form then-form &optional else-form)
`(let ((it ,test-form))
(if it ,then-form ,else-form)))
(defmacro aif2 (test &optional then else)
(let ((win (gensym)))
`(multiple-value-bind (it ,win) ,test
(if (or it ,win) ,then ,else))))
Debugger entered--Lisp error: (end-of-file)
byte-code("\302\300\"\210\303 \304\"\210\300\305\"\207" [error process debug slime-net-close t "net-read error: %S"] 3)
slime-net-read-or-lose(#<process SLIME Lisp>)
slime-process-available-input(#<process SLIME Lisp>)
slime-net-filter(#<process SLIME Lisp> #("0006b7(:write-string \"\\\"goog.provide('alen_blog.validation.form');\\\\ngoog.require('cljs.core');\\\\ngoog.require('alen_blog.validation.preds');\\\\nalen_blog.validation.form.required = (function required(param){\\\\nreturn core.validate_val.call(null,param,cljs.core.seq,cljs.core.HashMap.fromArrays([param],[cljs.core.Vector.fromArray([\\\\\\\"this is a required field\\\\\\\"])]));\\\\n});\\\\nalen_blog.validation.form.len = (function() {\\\\nvar len = null;\\\\nvar len__7625 = (function (k,l){\\\\nreturn core.validate_val.call(null,k,alen_blog.validation.preds.length.call(null,l),cljs.core.HashMap.fromArrays([k],[cljs.core.Vector.fromArray([cljs.core.str.call(null,\\\\\\\"must be exactly \\\\\\\
@billdozr
billdozr / .emacs
Created August 22, 2011 15:11
Dot Emacs 2011-08-22
;; =============================================================================
;; Unicode
;; =============================================================================
(message "Setting UTF-8 encoding")
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
load-path is a variable defined in `C source code'.
Its value is
("/Users/alen/quicklisp/dists/quicklisp/software/slime-20110522-cvs/contrib" "/Users/alen/quicklisp/dists/quicklisp/software/slime-20110522-cvs/" "/Users/alen/Development/haskell/projects/haskellmode-emacs/" "/Users/alen/.emacs.d/elpa/clojure-mode-1.7.1/" "/Users/alen/.emacs.d/elpa/slime-repl-20100404/" "/Users/alen/.emacs.d/elpa/slime-20100404/" "/Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/haskell-mode/" "/Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/auctex" "/Users/alen/Library/Preferences/Aquamacs Emacs" "/Users/alen/Library/Preferences/Aquamacs Emacs/auto-save-list" "/Users/alen/Library/Preferences/Emacs" "/Library/Preferences/Aquamacs Emacs" "/Library/Preferences/Emacs" "/Users/alen/Library/Application Support/Aquamacs Emacs" "/Users/alen/Library/Application Support/Aquamacs Emacs/Temporary Files" "/Users/alen/Library/Application Support/Emacs" "/Library/Application Support/Aquamacs Emacs