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
@cem2ran
cem2ran / DayOfDate.js
Last active August 29, 2015 14:01
Get the corresponding day of week for a date. Algorithm provided by Claus Tøndering - http://www.tondering.dk/claus/cal/chrweek.php#calcdow.
/*
* 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 August 29, 2015 14:02
Stads Average
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 = {};
@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:

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 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])
]
@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()) {
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 / 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.
@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;