Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
View install_iojs.sh
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 Dec 16, 2015
Auto-currying for the masses
View auto_curry.js
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 Aug 29, 2015 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
View RxFirebase.java
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;
View README.md

Reduce boilerplate in Redux

  • Create actions similar to Flummox.
  • Generate action ids.
  • Supports actions with promises, and therefore ES7 async.
View fizzbuzz.js
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))
View fibonacci-generator.js
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 Aug 29, 2015
code golfing algorithms, with readability in mind.
View minimalgorithms.js
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])
]
View functional-utils.js
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)
)();
View 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: