Skip to content

Instantly share code, notes, and snippets.


srdjan srdjan

View GitHub Profile
srdjan / fl-interfaces.js
Created Jun 13, 2017 — forked from gabejohnson/fl-interfaces.js
[WIP] Fantasy Land Interfaces
View fl-interfaces.js
import { class, interface, implements } from 'sweet-interfaces';
const constant = x => _ => x;
const identity = x => x;
const flip = f => (a, b) -> f(b, c);
interface Setoid {
// eq :: Setoid a => a ~> a -> Boolean
eq(b) { return this === b; }
srdjan / interactive-config.js
Created Apr 4, 2017 — forked from i-am-tom/interactive-config.js
Prompt users for missing/sensitive config data as and when it's required.
View interactive-config.js
// Sometimes, you might want to supply *some* config, but
// not necessarily *all*. Maybe your password is really
// secret, so you don't want to risk saving it in a config
// file. In which case, you'll want to ask the user to enter
// it when your script runs.
// This interface provides a flexible approach, where
// the user is prompted for a missing key when it's
// requested - if a particular key isn't needed for a given
// run, the user won't need to enter it. Of course, if the
srdjan / ramdaprogram.js
Created Jan 21, 2017 — forked from 1Marc/ramdaprogram.js
ramda program
View ramdaprogram.js
var byMonth = R.groupBy(R.prop('Month'));
var byAuthor = R.groupBy(R.prop('Author'));
var royalty_key = 'Royalty (SUM)';
var months_keys = R.uniq('Month'), data)).sort();
var monthly_revenue = =>
R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group),
srdjan / ct_notes.txt
Created Dec 30, 2016 — forked from buzzdecafe/ct_notes.txt
Category Theory for Programmers: Notes
View ct_notes.txt
Category Theory 1.1: Motivation and Philosophy
Composability, Abstraction, Reusability
Category Theory is a higher-level language.
Not a practical, executable language.
srdjan / 100+ different counter apps...
Last active Dec 22, 2020
More than 100 different counter applications...
View 100+ different counter apps...
100+ different js counter applications...
View qs.js
const reg = new RegExp("([^?=&]+)(=([^&]*))?", "g")
function qs (uri) {
const obj = {}
uri = uri.replace(/^.*\?/, '')
uri.replace(reg, map)
return obj
function map (a0, a1, a2, a3) {
obj[decodeURIComponent(a1)] = decodeURIComponent(a3)
srdjan / ddd.fsx
Created Jun 11, 2016 — forked from hodzanassredin/ddd.fsx
monadic ddd in fsharp
View ddd.fsx
type Request<'i,'o,'k> = 'i * ('o -> 'k)
let bindRequest bind f (s,k) = s, fun v -> bind(k v,f)
type Id = int
type Entity<'e> = Entity of Id option * 'e
[<Measure>] type money
type User = {name : string; email : string; ballance : int<money>}
type Product = { name : string; quantity : int; price : int<money>}
type Email = {body:string; subject : string}
View secmsg
Version: Keybase OpenPGP v2.0.49
srdjan / fold.js
Last active Sep 9, 2015 — forked from kpuputti/fold.js
Functional acrobatics using folds in JavaScript.
View fold.js
/*eslint-env es6 */
// Inspired by the paper "A tutorial on the universality and
// expressiveness of fold" by Graham Hutton (available at
//, implementing some generic
// list handling functions in JavaScript in terms of `fold`.
// Personally I had an enlightnening moment when I realised the
// beautiful interplay of cons lists and foldr during the FP101x
// Haskell course. JavaScript's syntax doesn't make this very apparent
View server-1.js
vertx.createHttpServer().requestHandler({ req: HttpServerRequest =>
.putHeader("Content-Type", "text/html")
.end("<html><body><h1>Hello from Vert.x!" +
vertx.createHttpServer().requestHandler({ req ->
You can’t perform that action at this time.