Skip to content

Instantly share code, notes, and snippets.

View ga2arch's full-sized avatar
🐢

Gabriele Carrettoni ga2arch

🐢
View GitHub Profile
@ga2arch
ga2arch / gist:1189521
Created September 2, 2011 19:01 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Favorite Python project:
Favorite Conference:
Python Experience Level:
@ga2arch
ga2arch / gist:1253726
Created September 30, 2011 13:22 — forked from weavejester/gist:1001206
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
@ga2arch
ga2arch / ants.clj
Created December 18, 2011 19:10 — forked from jjcomer/ants.clj
Ant Simulation -- From Clojure Concurrency Presentation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;As shown in the presentation: http://blip.tv/clojure/clojure-concurrency-819147
@ga2arch
ga2arch / core.clj
Created January 20, 2012 13:14
clj-maze
(ns clj-maze.core
(:use [clojure.test])
(:gen-class))
(def north 2r0001)
(def east 2r0010)
(def south 2r0100)
(def west 2r1000)
(defn dir-open? [square dir]
@ga2arch
ga2arch / maze.clj
Created January 21, 2012 20:09 — forked from cgrand/maze.clj
A maze generator (Wilson's algorithm) which can work with any topography (hextiles, torus variants, teapot etc.)
; http://groups.google.com/group/clojure/browse_thread/thread/974e2c7f89e27231/5f4bff3e58dfa36f
; output images http://i.imgur.com/gSASS.png (square maze)
; http://i.imgur.com/uEqaq.png (hex maze)
;; generic Wilson's algorithm implementation
(defn maze
"Returns a random maze carved out of walls; walls is a set of
2-item sets #{a b} where a and b are locations.
The returned maze is a set of the remaining walls."
[walls]
@ga2arch
ga2arch / gist:4055118
Created November 11, 2012 14:51 — forked from phimuemue/gist:1056235
Quick and dirty unification algorithm
-- simple unification for predicate logic
data AtomicFormula = Variable String | -- single variable
Function String [AtomicFormula] -- function with some args
instance Show AtomicFormula where
show (Variable a) = a
show (Function f l) = f ++ (show l)
data Formula = And Formula Formula -- conjunction, not needed
13:15 < xQuasar> HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF FUCKIN
PUSSIES
13:15 < xQuasar> JAVASCRIPT FOR LIFE FAGS
13:16 < luite> hello
13:16 < ChongLi> somebody has a mental illness!
13:16 < merijn> Wow...I suddenly see the error of my ways and feel compelled to
write Node.js!
13:16 < genisage> hi
13:16 < luite> you might be pleased to learn that you can compile haskell to
javascript now

I like LYAH as a reference and cheat-sheet but I found it a little slow for learning Haskell.

Here's my recommended order for just learning Haskell:

http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 80% completion here is fine if you feel your attention waning, the next thing will address hammering in things like functors and monads via typeclasses.

https://github.com/NICTA/course/ this will hammer in the lessons in a very direct form by forcing you to confront the challenges and lessons learned by the creators and community of Haskell itself. Doing the exercises here is critical for being fluent.

Real World Haskell is available online. (Thanks bos!)

@ga2arch
ga2arch / progbar.hs
Last active August 29, 2015 14:01 — forked from adinapoli/progbar.hs
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
module Main where
import Data.ByteString (ByteString)
import System.IO.Streams (InputStream, OutputStream)
import Network.Http.Client
import Text.Printf (printf)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C8
@ga2arch
ga2arch / fsevent.cpp
Last active August 29, 2015 14:07 — forked from yangacer/fsevent.cpp
#include <CoreServices/CoreServices.h>
#include <iostream>
void callback(
ConstFSEventStreamRef stream,
void *callbackInfo,
size_t numEvents,
void *evPaths,
const FSEventStreamEventFlags evFlags[],
const FSEventStreamEventId evIds[])