Skip to content

Instantly share code, notes, and snippets.

View ulfryk's full-sized avatar
💭
I may be slow to respond.

Jakub Strojewski ulfryk

💭
I may be slow to respond.
View GitHub Profile
@ulfryk
ulfryk / keybase.md
Created May 11, 2021 15:07
keybase.md

Keybase proof

I hereby claim:

  • I am ulfryk on github.
  • I am ulfryk (https://keybase.io/ulfryk) on keybase.
  • I have a public key ASBVoJQMxEtMwSCDlW95DkHF-6f83rJ_qkXPXFcn3UcmCwo

To claim this, I am signing this object:

@ulfryk
ulfryk / README.md
Last active January 22, 2020 14:13
A little JavaScript problem
import { Map } from 'immutable';
import { IResource, IResourceId } from 'dto/resource';
import { optionalFindIndex } from '../common/utility/optional-find-index';
class IndexedCollection<R extends IResource<R>> {
constructor(
private readonly items: R[],
private readonly indexed: Map<IResourceId<R>, R>,
@ulfryk
ulfryk / on_stateful_code.txt
Created March 9, 2016 06:34 — forked from josteink/on_stateful_code.txt
On why stateful code is bad
On why stateful code is bad
===========================
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
@ulfryk
ulfryk / ispromiseamonad.js
Last active February 23, 2016 13:52
JS Promisees vs. Monads
// Axioms
unit(value).bind(f) <=> f(value);
monad.bind(unit) == monad;
monad.bind(f).bind(g) == monad.bind(value => f(value).bind(g))
// Promise
@ulfryk
ulfryk / github-flow-publish-for-review.sh
Last active January 28, 2016 08:22
publish git flow feature and add PR
#! /bin/bash
format_green_bold="\x1b[32;01m"
format_reset="\x1b[00m"
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
feature_name=${branch_name##feature/}
echo -e "Publishing feature $format_green_bold$feature_name$format_reset to remote repository:\n"
@ulfryk
ulfryk / node-and-npm-in-30-seconds.sh
Last active September 9, 2015 06:06 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
# commented out version belo does not work for OS X
# ./configure --prefix=~/local
./configure --prefix=/Users/YourUserNameHere/local
make install # ok, fine, this step probably takes more than 30 seconds...
@ulfryk
ulfryk / enumerator.js
Last active August 29, 2015 14:25
TypeScript like JavaScript enumerators
var Enum = (function () {
function Enum() {
var args;
if (!(this instanceof Enum)) {
throw Error('Always use Enum constructor with new keyword.');
}
args = this.getArgs(arguments);
if (args.some(function (arg) { return typeof arg !== 'string'; })) {
throw TypeError('All Enum arguments have to be strings.');
}