Skip to content

Instantly share code, notes, and snippets.

View dmitriz's full-sized avatar

Dmitri Zaitsev dmitriz

View GitHub Profile
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@ewnd9
ewnd9 / npm-wrapper.sh
Last active January 18, 2016 11:02
Prevent executing "npm install <deps>" without `-S`, `-D`, `--save`, `--save-dev`, `-g` flags
#!/bin/bash
set -e
if ([ "$1" == "install" ] || [ "$1" == "i" ]) && [ "$#" -ne 1 ]; then
for var in "$@"
do
if [ "$var" == "--save" ] || [ "$var" == "--save-dev" ] || [ "$var" == "-S" ] || [ "$var" == "-D" ] || [ "$var" == "-g" ]; then
has_modifier=true
fi
@akalin
akalin / springer-lnm-1.md
Last active October 19, 2020 05:15
Direct links to Lecture Notes in Mathematics full books

Direct links to Lecture Notes in Mathematics (Part 1)

*-Autonomous Categories - Michael Barr (1979) ([1], [2], [3], [4], [5], [6])

1-Dimensional Cohen-Macaulay Rings - Eben Matlis (1973) ([1], [2

@staltz
staltz / migration-guide.md
Last active December 19, 2023 22:14
How to show migration guides in GitHub Markdown

How to show migration guides in GitHub Markdown

Use the diff code highlighting tag.

  ```diff
  - foo
  + bar

Example:

# avoid "works on my machine" by always locking dependency versions
npm config set save-exact=true
# install/uninstall project packages with flags that will update package.json
npm install --save lodash
npm install --save-dev jshint
npm uninstall --save lodash
# tool that makes upgrading dependencies easier, install it globally
npm install -g david
@mikaelbr
mikaelbr / 01-functional-ui.js
Last active February 21, 2017 23:50
Example of functional UI and higher order components for React/Omniscient.js (http://omniscientjs.github.io/)
import React from 'react';
import component from 'omniscient';
import immstruct from 'immstruct';
import { compose, valueNode, partialProps } from './compose';
const data = immstruct({ counter: 0, title: 'My title' });
const em = component(({partialedTitle, children}) =>
<em>{partialedTitle}: {children}</em>);
@ericelliott
ericelliott / es7-class.md
Last active March 25, 2021 10:27
Let's fix `class` in ES7

Two Simple Changes to Simplify class

I'm not suggesting drastic action. I don't want to break backwards compatibility. I simply want to make the class feature more usable to a broader cross section of the community. I believe there is some low-hanging fruit that can be harvested to that end.

Imagine AutoMaker contained class Car, but the author wants to take advantage of prototypes to enable factory polymorphism in order to dynamically swap out implementation.

Stampit does something similar to this in order to supply information needed to inherit from composable factory functions, known as stamps.

This isn't the only way to achieve this, but it is a convenient way which is compatible with .call(), .apply(), and .bind().

@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@razwan
razwan / _baseline.scss
Created April 14, 2014 16:20
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
<script>
$(document).ready(function() {
// Check whether the browser is capable of speech synthesis
if (window.speechSynthesis != 'undefined') {
// Basic demo
$("#demo_1").on('click', function(e) {
var u = new SpeechSynthesisUtterance('You have reached your destination');