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
@cem2ran
cem2ran / DayOfDate.js
Last active Aug 29, 2015
Get the corresponding day of week for a date. Algorithm provided by Claus Tøndering - http://www.tondering.dk/claus/cal/chrweek.php#calcdow.
View DayOfDate.js
/*
* Given a Date, Month and Year
* Return DAY_OF_WEEK.
*
* @param {Number} [D] Date in the following format: d
* @param {Number} [M] Month in the following format: m
* @param {Number} [Y] Year in the following format: yyyy
* @param {Boolean} [J=false] Defaults to the Gregorian calendar, when J is omitted or set to false. When set to true, the Day Of Week in the Julian calendar is returned.
* @return {String} The Day of Week, UPPERCASED.
*/
@cem2ran
cem2ran / gradeAverage.js
Last active Aug 29, 2015
Stads Average
View gradeAverage.js
var lines = document.getElementsByClassName('DataSelect');
var gradeCalc = {
grades: [],
average: -1,
weightedSum: 0,
ectsSum: 0
};
for(var i = 0; i < lines.length; i++){
var children = lines[i].children;
var grade = {};
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:

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)
)();
@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 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()) {
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 README.md

Reduce boilerplate in Redux

  • Create actions similar to Flummox.
  • Generate action ids.
  • Supports actions with promises, and therefore ES7 async.
@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;