This file contains 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
client_handler(): | |
data = (yield) | |
while True: | |
while not length(data) > 1: #until we can determine packettype | |
data += (yield) | |
pkt_type = pop_byte(data) | |
if pkt_type == PUB_MSG || pkt_type == PRIV_MSG: | |
while not length(data) > 4: #untill we can determine length | |
data+= (yield) |
This file contains 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
Pid ! {query, Stuff}, | |
receive | |
{response, Answer} -> | |
show_answer(Answer) | |
after | |
50000 -> | |
show_error("Timeout") | |
end | |
This file contains 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
<script> | |
$("#bereken").click(function () { | |
$.get("/db/bereken.php", function success(percentageBank) { | |
var bedrag = Number($("#bedrag").val()); | |
var jaren = Number($("#jaren").val()); | |
totaalPercentage = Math.pow(percentageBank, jaren); | |
var antwoord = bedrag * (totaalPercentage / 100) | |
$("#eindzien").html("Je eindsaldo zal over " + antwoord + " jaren " + eind + " euro bedragn"); |
This file contains 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
9 ; to find an approximation to sqrt(x) | |
8 ; * make a guess G | |
7 ; * improtve the guess by averaging G and X/G | |
6 ; * keep improving the guess until it is good enough | |
5 ; * use 1 as an initial guess | |
4 | |
3 (define (average x y) (/ (+ x y) 2) | |
2 | |
1 (define (square x) (* x x)) | |
0 |
This file contains 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
Template.contacts.contacts = function () { | |
return _.map(_.map(Meteor.user().contacts, Meteor.users.findOne), function (contact) { | |
contact.gravatar = _.reduce( | |
_.filter(contact.emails, function (email) { return email.verified;}), | |
function (acc, validEmail) { | |
acc = acc || Gravatar.validImageUrl(validEmail); | |
} | |
); | |
return contact; | |
}); |
This file contains 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
class Functor f where | |
map :: (a -> b) -> f a -> f b | |
class Pointed f where | |
return :: a -> f a | |
class (Functor f, Pointed f) => Applicative f where | |
(<*>) :: f (a -> b) -> f a -> f b | |
(*>) :: f a -> f b -> f b | |
(<*) :: f a -> f b -> f a |
This file contains 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
createAddressMap :: [Expression] -> M.Map Label Word16 | |
createAddressMap = M.fromList . (flip zip) (iterate (+1) 0) . filter (/="") . map label |
This file contains 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 Parse where | |
import Data.Word | |
import Data.List | |
import qualified Data.Map as M | |
data Expr = Expr {label :: String, instr :: Instr} | |
data Instr = ADD Op Op |
This file contains 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 Data.Char (ord, chr) | |
import Numeric (showHex, readHex) | |
import System.IO (isEOF, hSetBuffering, BufferMode(..), stdin, stdout) | |
import System.Directory (getDirectoryContents, doesFileExist, removeFile) | |
import System.Exit (exitSuccess) | |
repl :: [a] -> [a] | |
repl xs = xs ++ repl xs | |
perm :: [Int] -> ([Int] -> [Int]) |
This file contains 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
zappa = require 'zappa' | |
model = require './model' | |
zappa process.env.PORT ? 3000, -> | |
@use 'static' | |
@get '/' : -> @render 'index' | |
@get '/posts' : -> | |
limit = +(@query.limit ? '2') | |
offset = +(@query.offset ? '0') | |
if isNaN(limit) or isNaN(offset) | |
limit = 2 |