Here is my TypeScript solution for A little JavaScript problem posted last year on Mishoo's blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Axioms | |
unit(value).bind(f) <=> f(value); | |
monad.bind(unit) == monad; | |
monad.bind(f).bind(g) == monad.bind(value => f(value).bind(g)) | |
// Promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, |
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: