Skip to content

Instantly share code, notes, and snippets.

View srdjan's full-sized avatar

⊣˚∆˚⊢ srdjan

View GitHub Profile
@srdjan
srdjan / Json.purs
Created August 24, 2017 02:42 — forked from i-am-tom/Json.purs
Parsing, Generating, and Diffing JSON in PureScript
module Main where
-- | JSON is an incredibly simple format. Even its lists are untyped.
-- | As with all languages, functional programming encourages us to
-- | make a domain-specific language (or DSL) to capture the "ideas"
-- | of the language, which we can then use to talk about its content.
-- | In this little snippet, we'll build a JSON DSL, transform it into
-- | a recursive structure, and then use that result to generate some
@srdjan
srdjan / TransformingDeeplyNestedData.js
Created August 15, 2017 17:51 — forked from busypeoples/TransformingDeeplyNestedData.js
Transforming Deeply Nested Data
import {
always,
equals,
identity,
ifElse,
map,
partial,
} from 'ramda'
const isObject = input => input !== null && typeof input === 'object'
@srdjan
srdjan / fl-interfaces.js
Created June 13, 2017 12:48 — forked from gabejohnson/fl-interfaces.js
[WIP] Fantasy Land Interfaces
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
srdjan / interactive-config.js
Created April 4, 2017 01:54 — forked from i-am-tom/interactive-config.js
Prompt users for missing/sensitive config data as and when it's required.
// 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
srdjan / ramdaprogram.js
Created January 21, 2017 10:02 — forked from 1Marc/ramdaprogram.js
ramda program
var byMonth = R.groupBy(R.prop('Month'));
var byAuthor = R.groupBy(R.prop('Author'));
var royalty_key = 'Royalty (SUM)';
var months_keys = R.uniq(R.map(R.prop('Month'), data)).sort();
var monthly_revenue =
R.map((group) =>
R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group),
byMonth(data));
@srdjan
srdjan / ct_notes.txt
Created December 30, 2016 16:57 — forked from buzzdecafe/ct_notes.txt
Category Theory for Programmers: Notes
CATEGORY THEORY FOR PROGRAMMERS
Category Theory 1.1: Motivation and Philosophy
https://www.youtube.com/watch?v=I8LbkfSSR58&index=1&list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_
Composability, Abstraction, Reusability
Category Theory is a higher-level language.
Not a practical, executable language.
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@srdjan
srdjan / qs.js
Created July 21, 2016 11:14 — forked from yoshuawuyts/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
srdjan / ddd.fsx
Created June 11, 2016 15:07 — forked from hodzanassredin/ddd.fsx
monadic ddd in fsharp
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}
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.0.49
Comment: https://keybase.io/crypto
wcFMA8NHQqEvqEzYAQ/+OjIJxVjUf1J6bbk7y6RBDrOTeKpryZYA7At4j9VT/3pr
bNrsir9UbnRz1JIE9NE+yHE/rSq/xRaolkXo9Rlh8OAj1FYhfHhti7Z7knKl6fJy
Ene3oo8HiJlFXmRSO0W9/nxyffNyL7RL2jgH4ITsArBm75/zkonstXzdO15yASb3
HWxPyb/kw68ixcUIW75n6MGgzmWwXyJov6gJalV6qq0s1eKNUe5VzCrgZr7oxeHL
G/KsFKq1tWMrqZx3B5OpcoFGX6DkjDj6pLvVrO0yIZ0XUcYgNE6ALeYD2LJZbFbl
kMEdCpscXwCTO1x/0lOat62im1qbN0f2g6RZUV4FpJEPD+Uxeu77h6tmLtooP4v1