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
tax_payable = (band_info, gross) -> | |
tax_in_band = (band) -> | |
band.rate * (Math.min(band.max, gross) - Math.min(band.min, gross)) | |
total = 0 | |
bands = for band in band_info | |
prev_total = total | |
total += band.width + 0 | |
{ width: band.width, rate: band.rate, min: prev_total, max: total } |
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
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#define MAX 4096 | |
void die(const char *s) { | |
perror(s); | |
exit(1); | |
} |
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
type branch = | |
| Legislative | |
| Executive | |
| Judicial | |
| Other | |
type origin = | |
| Elected | |
| Appointed |
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
#!/usr/bin/ruby | |
require 'dbi' | |
db_name = 'db_test' | |
db_user = 'username' | |
db_pass = 'pass1234' | |
db_host = '127.0.0.1' | |
exit_status = nil |
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
#!/usr/bin/env python | |
import oursql | |
import pika | |
import json | |
import sys | |
db_config = {"db":"dbname", "user":"myuser", "passwd":"mypasswd"} | |
def dispatch(queue_name, query): |
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
mk270@marsilio ~> opam install dyntype | |
Install: dyntype.0.8.2 | |
[dyntype.0.8.2] Build commands: | |
make | |
make install | |
[21570] WARNING: Command "make" failed (see /home/mk270/.opam/log/command960.{info,err,out}) | |
ocamlbuild dyntype.cmxa dyntype.cma | |
/usr/local/bin/ocamlopt.opt -I /usr/local/lib/ocaml/ocamlbuild unix.cmxa /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild | |
ocamlfind ocamldep -package type_conv -modules lib/type.mli > lib/type.mli.depends | |
ocamlfind ocamlc -c -package type_conv -I lib -I pa_lib -I lib_test -o lib/type.cmi lib/type.mli |
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 itertools | |
def batch_generator(size, g): | |
buffer = [] | |
try: | |
while True: | |
for i in range(0, size): | |
buffer.append(g.next()) | |
yield buffer | |
buffer = [] |
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
When making and publishing an OCaml programme or library, there are several | |
tools you might use to compile and package and distribute your work. Building | |
OCaml projects is a bit different from C or similar languages, so the usual | |
"./configure && make && make test && make install" convention doesn't work. | |
As of December 2012, the recommended tools for building an OCaml package are | |
Oasis and OPAM. This document assumes you are using a UNIX-like system. | |
OPAM is responsible for installing new OCaml packages and libraries, such | |
as the dependencies of your own project. Oasis helps automate the build | |
system for your project. |
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
without indices | |
Hash Join (cost=13973.56..43799.18 rows=31766 width=583) | |
Hash Cond: ((p."globalSchemeId")::text = (s."GlobalSchemeId")::text) | |
-> Hash Join (cost=13963.11..43034.28 rows=31766 width=579) | |
Hash Cond: ((p."countryPayment")::text = (c.code)::text) | |
-> Hash Join (cost=13955.08..42271.81 rows=31766 width=575) | |
Hash Cond: ((p."globalRecipientId")::text = (r."globalRecipientId")::text) | |
-> Seq Scan on payment p (cost=0.00..18317.68 rows=860568 width=571) | |
-> Hash (cost=13784.48..13784.48 rows=13648 width=13) |
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
sed 's/\(.*\)/open\1/' < /usr/share/dict/words |
OlderNewer