Skip to content

Instantly share code, notes, and snippets.

srdjan srdjan

View GitHub Profile
@srdjan
srdjan / IMyProtocol.d.ts
Created Mar 5, 2019 — forked from elierotenberg/IMyProtocol.d.ts
Statically typechecked serializable protocol
View IMyProtocol.d.ts
import { IProtocol, IRequestResponseMap, IEventMap } from "./IProtocol";
import { ISerializable } from "./ISerializable";
type RequestResponseMap = {
ping: {
RequestParams: {};
ResponseParams: {};
};
echo: {
RequestParams: ISerializable;
@srdjan
srdjan / TypeScriptFundamentals.ts
Created Mar 3, 2019 — forked from busypeoples/TypeScriptFundamentals.ts
TypeScript Fundamentals For JavaScript Developers
View TypeScriptFundamentals.ts
// TypeScript Fundamentals For JavaScript Developers
/*
Tutorial for JavaScript Developers wanting to get started with TypeScript.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
If you have any questions or feedback please connect via Twitter:
A. Sharif : https://twitter.com/sharifsbeat
*/
View recr.ts
type JSValue = { kind: 'JSNull' }
| { kind: 'JSBool', value: boolean }
| { kind: 'JSString', value: string }
| { kind: 'JSRational', asFloat: boolean, value: number }
| { kind: 'JSArray', value: JSValue[] }
| { kind: 'JSObject', value: { [key: string]: JSValue } }
@srdjan
srdjan / FlowTutorial.js
Last active Oct 3, 2017 — forked from busypeoples/FlowTutorial.js
Flow Fundamentals For JavaScript Developers
View FlowTutorial.js
// @flow
// Flow Fundamentals For JavaScript Developers
/*
Tutorial for JavaScript Developers wanting to get started with FlowType.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
@srdjan
srdjan / _about.md
Created Sep 15, 2017 — forked from sgoguen/_about.md
A Small Elm-like DSL in F#
View _about.md

Making Toys with F# - A Small Elm-like DSL in F#

A Small Elm-Like DSL in F#

I've been working on a talk about the virtues of building toy examples for the purpose of communicating ideas with simple interactive examples.

The toys I talk about in my presentation are based my interest in tools that allow programmers to quickly build web applications that allow them to explore their architecture. So to kickstart this series off, I want to introduce a simple

@srdjan
srdjan / Json.purs
Created Aug 24, 2017 — forked from i-am-tom/Json.purs
Parsing, Generating, and Diffing JSON in PureScript
View Json.purs
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
View TransformingDeeplyNestedData.js
import {
always,
equals,
identity,
ifElse,
map,
partial,
} from 'ramda'
const isObject = input => input !== null && typeof input === 'object'
@srdjan
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
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
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(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));
You can’t perform that action at this time.