Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE MultiParamTypeClasses #-}
module DataLib where
class Record a where
getId :: a -> Int
insert :: Record a => a -> [a] -> [a]
insert r rs = r : rs
@daxfohl
daxfohl / updates.txt
Last active November 7, 2016 02:48
API updates
A few general notes:
* We switched from Mongo to Postgres, so all the lookups are ID based rather than filename/foldername based.
* There's a new table "photo_sequence". The hierarchy is "folder 1->* photo_sequence 1->* upload", where a "sequence" denotes e.g. one run through the gif sequence, and the corresponding "uploads" are each of the individual phots, gifs, user-edits, etc from that sequence.
* Folders can contain multiple "galleries", each of which has its own sharing configuration. A common use case is in printer mode, they'll have one gallery for the individual shots allowing social, and one for the composites just allowing prints, and run two separate tablets.
* The workflow for customizing images and forms has been improved, allowing things like gif annotation without custom code.
* I denote an array of objects below by brackets, e.g. [string] is a string array or [{id:int;name:string}] is an array of that record type.
* ... means there are other fields you can ignore
* v4 api serv
package com.company;
import java.util.ArrayDeque;
import java.util.PriorityQueue;
import java.util.Queue;
public class Main {
// Start by defining Nodes and Edges (Nodes in a tree have Edges of a certain length to a child Node)
static class Edge {
@daxfohl
daxfohl / x.fs
Last active August 12, 2016 15:25
open System.Threading.Tasks
open System.Threading
open System
let criteria _ b = b = 10
let callback (i: int) =
Thread.Sleep(50)
printfn "Callback %d" i
let rec compute (task: Task) state =
{{input}} -annotate +10+20 "{{firstName}} {{lastName}}" {{output}}
<?xml version="1.0" encoding="UTF-8"?>
<Response><Sms>Nothing to see here.</Sms></Response>
@daxfohl
daxfohl / skynet.fsx
Created February 14, 2016 17:08
261 ms F# MailboxProcessor impl of https://github.com/atemerev/skynet
#time "on"
type State = { remaining: int64; aggregate: int64 }
let div = 10L
let rec skynet num size postback =
if size = 1L then
postback num
else
@daxfohl
daxfohl / skynet.fsx
Last active February 14, 2016 17:04
261 ms F# MailboxProcessor impl of https://github.com/atemerev/skynet
#time "on"
type State = { remaining: int64; aggregate: int64 }
let div = 10L
let rec skynet num size postback =
if size = 1L then
postback num
else
@daxfohl
daxfohl / clj_async.clj
Last active November 21, 2023 19:08
clj_async
(use '[clojure.algo.monads])
(require '[clojure.core.async :as async])
(defmonad async-m
"Monad describing async operations."
[m-result (fn m-result-async [v]
(let [c (async/chan)]
(async/go (async/>! c v))
c))
open System.Diagnostics
let N = 100000
let calc_sync i = i % 10
let sum_sync() =
async {
let ints = Seq.initInfinite calc_sync |> Seq.take N
return Seq.sum ints
}