Skip to content

Instantly share code, notes, and snippets.

View micha149's full-sized avatar

Michael van Engelshoven micha149

  • Brainbits GmbH
  • Sankt Augustin, Germany
View GitHub Profile
@micha149
micha149 / index.js
Created September 4, 2019 10:57
Buffered RXJS
const { rxObserver } = require('api/v0.3');
const { interval, from, timer, of } = require('rxjs');
const { take, bufferCount, concatMap, delay, first, mergeMap, map, throttleTime, ignoreElements, startWith } = require('rxjs/operators');
const spaceTime = time => concatMap(value =>
of(value).pipe(
delay(time)
)
);
@micha149
micha149 / Counter.jsx
Last active May 23, 2018 15:15
Just testing around with clean functional react components and the question how to get state in a stateless function. The answer is composition.
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
count: PropTypes.number.isRequired,
onIncrement: PropTypes.func.isRequired,
onDecrement: PropTypes.func.isRequired,
};
const Counter = ({ count, onIncrement, onDecrement }) => (
@micha149
micha149 / asyncPipe.ts
Last active March 19, 2018 12:49
Functional, static typed, promised approach for handling async stuff
type Arity1<A, B> = (a: A) => Promise<B>;
function asyncPipe<A, B>(f: Arity1<A, B>): Arity1<A, B>;
function asyncPipe<A, B, C> (g: Arity1<A, B>, f: Arity1<B, C>): Arity1<A, C>;
function asyncPipe<A, B, C, D> (h: Arity1<A, B>, g: Arity1<B, C>, f: Arity1<C, D>): Arity1<A, D>;
function asyncPipe<A, B, C, D, E> (i: Arity1<A, B>, h: Arity1<B, C>, g: Arity1<C, D>, f: Arity1<D, E>): Arity1<A, E>;
function asyncPipe<A, B, C, D, E, F> (j: Arity1<A, B>, i: Arity1<B, C>, h: Arity1<C, D>, g: Arity1<D, E>, f: Arity1<E, F>): Arity1<A, F>;
export default function asyncPipe (...fns) {
return x => fns.reduce(async (y, f) => f(await y), x);
@micha149
micha149 / example.js
Created August 31, 2015 08:19
Javascript Promises + ES6 arrow functions = ♥
return repo.getHeadCommit()
.then(commit => commit.getTree())
.then(tree => tree.getEntry('bla/foo/bar'))
.then(entry => entry.getTree())
.then(tree => makeThings(repo, tree))
@micha149
micha149 / _main.scss
Last active August 29, 2015 14:15
Exclude Mobile CSS into separate stylesheet
@import "mixins";
body {
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.container {
width: 960px;
margin: 0 auto;
@micha149
micha149 / Brötchen.md
Last active May 5, 2017 08:32
Hamburger

Hamburger Brötchen

  • 150ml Wasser
  • 1 Würfel Frische Hefe
  • 40g Butter
  • 1 Ei
  • 435g Mehl
  • 40g Zucker
  • 1 TL Salz
  • Kondensmilch
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#0092dd",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
@micha149
micha149 / FindEntityByAssociationCommand.php
Last active August 18, 2022 21:37
Example command to get all entity association mappings. #symfony2 #doctrine2
<?php
namespace Esel\ContentBundle\Command;
use Doctrine\ORM\Mapping\ClassMetadata;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@micha149
micha149 / gist:6523387
Last active December 22, 2015 19:59
Git: Remove untracked files
git status --porcelain -u | grep -E '^\?\?' | sed -e 's/^\?? //' | xargs rm -rf
@micha149
micha149 / jsonview.css
Created September 28, 2012 08:33
Solarized Dark Color Theme for Google Chromes JSON View
body {
white-space: pre;
font-family: "Espresso Sans Mono", monospace;
font-size: 14px;
background: #002b36;
color: #657b83;
}
.property {
font-weight: normal;