Skip to content

Instantly share code, notes, and snippets.

View darrylhebbes's full-sized avatar

Darryl Hebbes darrylhebbes

  • Berlin, Germany
View GitHub Profile
// Doesn't throw an error, but doesn't return an object
const getObj = () => { a: 1 };
console.log(getObj()); //=> val 'undefined' : void
// Reason: It looks lika an arrow function returning an object, but it isn't.
// It's an arrow function with statements returning nothing.
const getObj = () =>
{ // <- Start function body
a: // <- Statement 1: A label to use when break/continue; e.g. break a;
1 // <- Statement 2: Just a noop expression statement, not doing anything.
@buzzdecafe
buzzdecafe / ct_notes.txt
Last active January 24, 2022 12:17
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.
@holgerschurig
holgerschurig / update.sh
Created December 8, 2016 21:24
How to stay up track changes in git projects
#!/bin/sh
# Step 1: clone projects into directories with a leading "git-":
#
# git clone http://foo.org/foo.git git-foo
# git clone http://bar.org/bar.git git-bar
#
# Step 2: some hours/days/weeks later, run this script:
#
# ./update.sh
@SOLenG
SOLenG / Lambdas.js
Last active September 26, 2017 16:08
Functional
// λx.λy.y fun x -> fun y -> y
var False = function (x) {
return function (y) {
return y;
};
};
// λx.λy.x
var True = function (x) {
return function (y) {
return x;
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@lena121
lena121 / TEXT EDITOR
Last active March 21, 2017 10:39
ATOM
QUICK SHORTCODES:
Ctrl+T find all files with similar typing file's name in all project
Ctrl+\ hide or open tree view
Ctrl+Shift+F find something in all project
Ctrl+/ comment single line or comment selected piece of code
Ctrl+cursor get multi select (coursor)
Ctrl+W close all pannels in editor
Ctrl+Shift+P - command line
@torgeir
torgeir / elmish.js
Last active July 19, 2019 06:13
A plain js take on @ccorcos elmish
const declare = function (dispatch, state) {
const view = function () {
if (state.error) {
return <p>Error: { state.error }</p>;
}
if (state.loading) {
return <p>Clock: Loading..</p>;
}
@mikaelbr
mikaelbr / 01-multi-method-proxy.js
Last active July 7, 2017 12:38
Playing with JavaScript Proxies, implementing multi-methods
const fib = multiMethod();
fib[0] = 0;
fib[n => n <= 1] = 1;
fib[_ => true] = (n) => fib(n-1) + fib(n-2);
console.log(fib(20));
//=> 6765
function multiMethod () {
let predicates = [];
const handler = {
@toddmotto
toddmotto / *.md
Last active April 25, 2023 09:06
Component versus Directive in AngularJS

Component versus Directive in AngularJS

.component()

Components are not "helper" methods, they are the best change in Angular 1.x since I've been using it.

What is the role of .component()?

  • Declares new HTML via a template or templateUrl
  • Should be used to create Components as part of a Component architecture
@uglow
uglow / angularjs_directive_attribute_explanation.md
Created November 25, 2015 00:55 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>