This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package agent | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| ) | |
| type Event struct { | |
| Agent string | |
| Source string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [global] | |
| font = "Ubuntu Mono 13" | |
| allow_markup = yes | |
| format = "<b>%s %p</b>\n%b" | |
| sort = yes | |
| indicate_hidden = true | |
| # geometry = "x5" | |
| transparency = 40 | |
| idle_threshold = 0 | |
| geometry = "300x5-20+20" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Week2 where | |
| import Data.List (transpose) | |
| import Control.Arrow | |
| data Piece = King | Queen | Rook | Bishop | Knight | Pawn | Empty | |
| deriving (Show) | |
| data Board = Board Int Int [[Piece]] | |
| instance Show Board where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Fizzbuzz where | |
| import Data.List (unlines) | |
| fizzbuzz :: Int -> String | |
| fizzbuzz n = case (n `mod` 3, n `mod` 5) of | |
| (0, 0) -> "FizzBuzz" | |
| (0, _) -> "Fizz" | |
| (_, 0) -> "Buzz" | |
| (_, _) -> show n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Week5 where | |
| -- List of numbers, lower bound, upper bound | |
| search :: [Int] -> Int -> Int -> Maybe Int | |
| search [] _ _ = Nothing | |
| search (x:xs) l u | |
| | x > l && x < u = Just x | |
| | otherwise = search xs l u |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Problem14 where | |
| import Control.Monad.Writer | |
| collatzWriter :: Int -> Writer [Int] () | |
| collatzWriter 1 = return () | |
| collatzWriter n = tell [next] >> collatzWriter next | |
| where | |
| next | |
| | n `mod` 2 == 0 = n `div` 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Problem14 where | |
| collatzWriter :: Int -> [Int] | |
| collatzWriter 1 = [] | |
| collatzWriter n = next : collatzWriter next | |
| where | |
| next | |
| | n `mod` 2 == 0 = n `div` 2 | |
| | otherwise = 3 * n + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ╭─jdiez@voidray ~ | |
| ╰─$ ghci | |
| GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help | |
| Loading package ghc-prim ... linking ... done. | |
| Loading package integer-gmp ... linking ... done. | |
| Loading package base ... linking ... done. | |
| λ: data Player = Player { health :: Int, name :: String } deriving (Show) | |
| λ: let player = Player 100 "José" | |
| λ: let setHealth p h = p { health = h } | |
| λ: let player' = setHealth player 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var zmq = require("zmq"); | |
| sock = zmq.socket("sub"); | |
| sock.connect("ipc:///tmp/keypad.zmq"); | |
| sock.on("message", function(msg) { | |
| console.log(msg); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| query = 'insert into employees (emp_id, first_name, surname, salary, dept_id, comm_pct) VALUES ("%s", "%s", "%s", %d, "%s", %s);' | |
| def get_id(name, surname): | |
| return "%s%s%02d" % (name[0], surname[0], random.randint(0, 99)) | |
| if __name__ == '__main__': | |
| names = [line.rstrip() for line in open("first-names.txt")] | |
| surnames = [line.rstrip() for line in open("names.txt")] |