Skip to content

Instantly share code, notes, and snippets.

View cem2ran's full-sized avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
brew update && \
brew install nvm && \
echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profile && \
source ~/.profile && \
nvm install iojs && \
nvm alias default iojs && \
npm install -g npm@latest
@cem2ran
cem2ran / auto_curry.js
Last active December 16, 2015 01:14
Auto-currying for the masses
Function.prototype.curried = function (f=this) {
return (...args) => args.length < f.length
? f.curried(args.reduce((g, arg) => g.bind(null, arg), f))
: f.apply(null, args);
};
@cem2ran
cem2ran / RxFirebase.java
Last active August 29, 2015 14:25 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.view.Event;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
@cem2ran
cem2ran / README.md
Last active August 29, 2015 14:23 — forked from vjpr/README.md

Reduce boilerplate in Redux

  • Create actions similar to Flummox.
  • Generate action ids.
  • Supports actions with promises, and therefore ES7 async.
const range = ({start=0, end=1})=> [...Array(end - start + 1)].map((_, i) => start + i);
const fizzbuzz = (num=100) => [for (x of range({end: num})) (!(x%3)?"Fizz":'')+(!(x%5)?'Buzz':'')]
console.log(fizzbuzz(30))
@cem2ran
cem2ran / fibonacci-generator.js
Created May 6, 2015 16:59
Fibonacci generator
function* fibonacci() {
let a = 0, b = 1;
while(a < Infinity) {
yield a;
[a, b] = [b, a + b];
}
}
for(let value of fibonacci()) {
@cem2ran
cem2ran / minimalgorithms.js
Last active August 29, 2015 14:17
code golfing algorithms, with readability in mind.
const qsort = ([first, ...rest]) =>
first === undefined
? []
: [
...qsort([for (x of rest) if (x < first) x]),
first,
...qsort([for (x of rest) if (x >= first) x])
]
const combine = (...arrays)
=> [].concat(...arrays);
const compact = arr
=> arr.filter(el => el);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
)();
@cem2ran
cem2ran / keybase.md
Created January 1, 2015 18:42
keybase.md

Keybase proof

I hereby claim:

  • I am cem2ran on github.
  • I am cem2ran (https://keybase.io/cem2ran) on keybase.
  • I have a public key whose fingerprint is 9D5C F0AF 85B1 F58D 5D3F 5B34 0B5E 30A7 DA01 F730

To claim this, I am signing this object: