Some resources on programming, computer science vs engineering, optimization:
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
package main | |
import "fmt" | |
var cost int | |
func f2(s, e int) int { | |
cost += 1 | |
if e <= s { |
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
data Operator = Plus | Minus | Multiply | Divide deriving Show | |
data Token = Val Int | Op Operator deriving Show | |
calc :: [Token] -> [Int] -> Either String Int | |
calc (Val t:ts) xs = calc ts (t:xs) | |
calc (Op Minus:ts) (a:b:xs) = calc ts ((a - b):xs) | |
calc (Op Plus:ts) (a:b:xs) = calc ts ((a + b):xs) | |
calc (Op Multiply:ts) (a:b:xs) = calc ts ((a * b):xs) | |
calc (Op Divide:ts) (a:b:xs) = calc ts ((a `div` b):xs) | |
calc [] [x] = Right x |
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 it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet | |
data class Quad(val s: String = "", val p: String = "", val o: Comparable<Any>? = null, val c: String = "") : | |
Comparable<Quad> { | |
override fun compareTo(other: Quad): Int = compareValuesBy(this, other, Quad::s, Quad::p, Quad::o, Quad::c) | |
override fun toString(): String = "Q<S=$s P=$p O=$o C=$c>" | |
} |
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 ruby | |
# | |
# Git commit-msg hook. If your branch name is in the form "US1234-postfix", or | |
# "US1234_postfix", it automatically adds the prefix "[US1234]" to commit | |
# messages. | |
# | |
# Example | |
# ======= | |
# | |
# git checkout -b US1234-some-cool-feature |
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 <cairo/cairo.h> | |
int | |
main (int argc, char *argv[]) | |
{ | |
cairo_surface_t *surface = | |
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80); | |
cairo_t *cr = | |
cairo_create (surface); |
A quick note on writing HTTP APIs in an RPC style ... also sharing my enthusiasm for RDF and RDF schemas all around :-)
Someone put together a crazy big decision diagram explaining which status code to return under which circumstance, etc.
In practice, many HTTP service APIs work more like a Remote Procedure Call and less like a fully conforming "Hypermedia Service". Headers are usually considered "low level", used for things like caching, ETags, cookies, CORS, etc.
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 * as jsonld from "jsonld"; | |
import * as n3 from "n3"; | |
const doc = { "YOUR" : "JSONLD" }; | |
const nquads = await jsonld.toRDF(doc, { format: "application/n-quads" }); | |
const parser = new n3.Parser({ format: "application/n-quads" }); | |
const writer = new n3.Writer({ format: "application/trig" }); | |
await parser.parse(nquads, (error, quad, prefixes) => { |
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
package com.emmanueloga.cracking.arrays; | |
import java.util.Iterator; | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.Lists; | |
class StringCodepointsIterable implements Iterable<String> { | |
public class StringCodepointsIterator implements Iterator<String> { | |
private int index = 0; |
NewerOlder