Skip to content

Instantly share code, notes, and snippets.

View zwilias's full-sized avatar

Ilias Van Peer zwilias

View GitHub Profile
function fbSave(result, collection) {
if (result.data) {
for (i in result.data) {
db[collection].save(result.data[i]);
}
return result.data.length;
} else {
db[collection].save(result);
return 1;
@zwilias
zwilias / structure.js
Created May 30, 2013 12:45
Figure out the structure of an object to arbitrary depth in mongo (or anything else running V8)
function structure(anObject, maxDepth) {
if (maxDepth < 1) {
return Array.isArray(anObject)
? []
: typeof(anObject) === "object"
? {}
: typeof(anObject);
}
var clone;
/* Initialise all rearrangement matrices */
lowerX = new RearrangeMatrix(data.getLowerX());
lowerY = new RearrangeMatrix(data.getLowerY());
upperX = new RearrangeMatrix(data.getUpperX());
upperY = new RearrangeMatrix(data.getUpperY());
ExecutorService executor = Executors.newFixedThreadPool(2);
for (final RearrangeMatrix matrix : new RearrangeMatrix[]{lowerX, lowerY, upperX, upperY}) {
executor.execute(new Runnable() {
# Create the directory and make sure
mkdir -p ~/.git-template/hooks
# Create a post-commit file in that directory and feed it the commit-hook:
cat > ~/.git-template/hooks/post-commit << EOF
#!/usr/bin/env ruby
file="~/.gitshots/#{Time.now.to_i}.jpg"
unless File.directory?(File.expand_path("../../rebase-merge", __FILE__))
puts "Taking capture into #{file}!"
system "imagesnap -q -w 3 #{file} &"
{
"testResult": {
"name": "My test",
"status": "PASSED",
"id": "e93e081a-7d77-4689-9728-9c2bc1b51983"
}
}
{
"testStarted": {
"name": "My test suite",
"id": "8f22cce8-c281-456e-a2ef-54a863a0ccdd"
}
}
{
"testStarted": {
"name": "My test",
"parentId": "8f22cce8-c281-456e-a2ef-54a863a0ccdd",
module Pages.SearchPage.Rest exposing (..)
import Html exposing (..)
import Http
import Json.Decode as JD exposing (..)
import Pages.SearchPage.Types exposing (Model, ImagePic, Msg)
import Json.Decode.Pipeline as JP
import RemoteData
fetchImagePics : Cmd Msg
module Random.Insertion exposing (..)
import Benchmark exposing (..)
import Benchmark.Runner exposing (BenchmarkProgram, program)
import Char
import Dict
import Dict.AVL as AvlDict
import Time exposing (Time)
import Random.Pcg as Random exposing (int, list, Seed)
module Test exposing (..)
{-| A binary search tree will often look roughly like this.
Every node will either be the `Empty` node, or a node with
a key, a value and left and right children. In this case, we
also have an extra `Int` to keep track of the height, but
that's not relevant to the example at hand.
-}
type Dict k v
= Empty
isValidBst : Tree comparable -> Bool
isValidBst tree =
case tree of
Empty ->
True
Node value left right ->
all (\x -> x < value) left
&& all (\x -> x > value) right
&& isValidBst left