Skip to content

Instantly share code, notes, and snippets.

View arianvp's full-sized avatar
🎱
Focusing

Arian van Putten arianvp

🎱
Focusing
View GitHub Profile
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)
Pid ! {query, Stuff},
receive
{response, Answer} ->
show_answer(Answer)
after
50000 ->
show_error("Timeout")
end
<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");
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
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;
});
@arianvp
arianvp / gist:4061723
Created November 12, 2012 20:38
Ideale hatseflats
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
createAddressMap :: [Expression] -> M.Map Label Word16
createAddressMap = M.fromList . (flip zip) (iterate (+1) 0) . filter (/="") . map label
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
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])
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