Skip to content

Instantly share code, notes, and snippets.

View davesnx's full-sized avatar

David Sancho davesnx

View GitHub Profile
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@bcoe
bcoe / npm-top.md
Last active May 14, 2024 11:29
npm-top.md

npm Users By Downloads (git.io/npm-top)


npm users sorted by the monthly downloads of their modules, for the range May 6, 2018 until Jun 6, 2018.

Metrics are calculated using top-npm-users.

# User Downloads

The issue:

..mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

(from a new defunct https://developers.google.com/mobile/articles/fast_buttons article)

touch-action CSS property can be used to disable this behaviour.

touch-action: manipulation The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.

@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@plukevdh
plukevdh / objectDiff.js
Last active April 11, 2022 13:56
Ramda - Compact diff output for complex objects.
import R from 'ramda'
const isObject = R.compose(R.equals('Object'), R.type);
const allAreObjects = R.compose(R.all(isObject), R.values);
const hasLeft = R.has('left');
const hasRight = R.has('right');
const hasBoth = R.both(hasLeft, hasRight);
const isEqual = R.both(hasBoth, R.compose(R.apply(R.equals), R.values));
const markAdded = R.compose(R.append(undefined), R.values);
@bobzhang
bobzhang / Comparison of different langauges
Last active January 5, 2023 18:17
Type safe Alt-JS language comparison
A list of languages which compile to JS (Elm, Purescript, OCaml)
(Inspired by this thread: https://groups.google.com/forum/#!topic/elm-discuss/Um7WIBTq9xU)
They all support curry calling convention by default.
Some interesting results:
1. `min` is curried function, only OCaml(BuckleScript) managed to optimize this overhead.
2. All optimize the self tail call
3. Only BuckleScript and PureScript type-specialized comparison functoin (>=) and inlined
@busypeoples
busypeoples / README.md
Last active February 8, 2022 08:41
Making Impossible States Impossible in ReasonML

Making Impossible States Impossible in ReasonML

Introduction

If you have already seen Richard Feldman's talk entitled "Making Impossible States Impossible" or have read "Designing with types: Making illegal states unrepresentable" then you can skip the explanations and just head straight to the Reason examples.

This post is intended to display how to model your Reason Application to prevent creating impossible states. The benefits of being able to design a feature in this way include avoiding having to deal with complex test scenarios regarding defined business rules and a clear documentation of what is possible just by looking at the type definition. Long story short, let's see how this all works by implementing an example.

Requirements

@mbilokonsky
mbilokonsky / thinking_like_a_function.md
Last active October 25, 2021 14:47
Thinking Like a Function

Thinking Like a Function

Part 1: What's a function?

As a software engineer, you probably think of a function as a unit of code that takes some arguments and returns some value, eg:

 function square(x) { 
   return x * x;
 }
@busypeoples
busypeoples / TypeScriptFundamentals.ts
Last active June 21, 2022 14:57
TypeScript Fundamentals For JavaScript Developers
// 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
*/
@Khady
Khady / ppxed-source
Created September 9, 2019 06:46
Use merlin to print an ocaml file after being processed by a ppx
#!/usr/bin/env sh
# A .merlin must be present nearby the file.
# With dune it can be generated by calling `dune build @check`.
FILE="$1"
ocamlmerlin single dump -what ppxed-source -filename "$FILE" < "$FILE" | jq -r '.value' | ocamlformat --name="$FILE" -