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 / 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 / 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;
@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 / gist:1319346
Last active September 11, 2018 11:37
Git commands
# Create a git alias with a colored history listing
git config --global alias.hist "log --all --format='[%C(cyan)%h%C(reset)] %C(red)%d%C(reset) %s %C(dim)# %an%C(reset)' --graph"
# call api from gitignore.io from console
git config --global alias.ignore "!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi"
# delete all merged branches except master, develop and the current checked out branch
git config --global alias.cleanup "!git branch --merged | grep -v '^\*\|master\|develop' | xargs -n1 git branch -d"
# Create temporary commit of staged changes and fixup it into the given commit
@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 / javascripaabbtr.js
Created September 4, 2012 14:03
AABB-Tree in javascript
/**
* This file contains an implementation of an Axis Aligned Bounding Box Tree, by Eyal Shalev
* You can modify it and use it for your projects without any limitations.
* I only ask that:
* 1. You leave this message in the Code.
* 2. Drop me a message that you used it via: https://sourceforge.net/projects/javascripaabbtr/
*
* This file will work as is with no requirements to include other files along-side it.
*
* See example usage in aabbTreeExample.html
@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
@micha149
micha149 / gist:1122864
Created August 3, 2011 15:09
Regular Expression to parse WebVTT
expression = /^(\d\d:\d\d:\d\d[,.]\d\d\d)\s-->\s(\d\d:\d\d:\d\d[,.]\d\d\d)\n.*(\n\n|$)/
@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