Skip to content

Instantly share code, notes, and snippets.

@blerou
blerou / project.clj
Created September 25, 2016 11:14
A very simple TODO app's domain model
(defproject eisentower-todo "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0-alpha12"]]
:main ^:skip-aot eisentower.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
:dev {:dependencies [[org.clojure/test.check "0.9.0"]]}})
@blerou
blerou / PNM.hs
Last active December 15, 2015 11:28
Let's play Haskell! - Parsing PGM images
module PNM where
{-
http://people.sc.fsu.edu/~jburkardt/data/pgmb/pgmb.html
run parser: do { s <- readFile "feep.pgm"; putStrLn (show (parseP5_t2 (L8.pack s))); }
-}
import qualified Data.ByteString.Lazy.Char8 as L8
import qualified Data.ByteString.Lazy as L
@blerou
blerou / README
Last active December 12, 2015 03:48
Let's play Haskell! - #8 - beautiful strings
*Beautiful Strings*
When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.
Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.
The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)
You're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?
$ php -a
Interactive shell
php > $obj = new stdClass;
php > $numKey = 123;
php > $obj->{$numKey} = 'foo';
php > $ary = (array) $obj;
php > var_dump($obj, $ary);
class stdClass#1 (1) {
public $123 =>
@blerou
blerou / MyJson.hs
Last active December 11, 2015 09:48
Let's play Haskell! - #7 - simple json & recycled numbers solution
module MyJson where
import Data.List
data JValue = JString String
| JBool Bool
| JNumber Double
| JNull
| JList [JValue]
| JObject [(String, JValue)]
@blerou
blerou / .gitignore
Last active December 10, 2015 20:28
Let's play Haskell! - #6 - IO
io
redis
*.hi
*.o
bin
config
vendor
@blerou
blerou / store.hs
Created November 19, 2012 14:05
Let's play Haskell! - #5
-- array($year, $model, $price)
-- (Int, String, Int)
type Price = Int
data CarType = Ford | Chevrolet deriving (Show)
data Vehicle = Car Int CarType Price
| Bicycle Price
| Motor Price deriving (Show)
data Accessory = SteeringWheel Price | Brake Price deriving (Show)
type Store = [Vehicle]
@blerou
blerou / store.hs
Created November 11, 2012 12:16
Let's play Haskell! - store, the second day
-- array($year, $model, $price)
-- (Int, String, Int)
type Price = Int
data CarType = Ford | Chevrolet deriving (Show)
data Vehicle = Car Int CarType Price
| Bicycle Price
| Motor Price deriving (Show)
data Accessory = SteeringWheel Price | Brake Price deriving (Show)
type Store = [Vehicle]
@blerou
blerou / store.hs
Created November 5, 2012 22:56
Let's play Haskell! - store
-- array($year, $model, $price)
-- (Int, String, Int)
type Price = Int
data CarType = Ford | Chevrolet deriving (Show)
data Vehicle = Car Int CarType Price
| Bicycle Price deriving (Show)
type Store = [Vehicle]
storePrice :: Store -> Price
@blerou
blerou / first.hs
Created October 19, 2012 13:22
Let's play Haskell! - 1st session
-- az elso nyers megvalositas szambol -> szoveg
fizzbuzzText n =
if n `mod` 3 == 0 then
if n `mod` 5 == 0 then
"FizzBuzz"
else
"Fizz"
else
if n `mod` 5 == 0 then
"Buzz"