Skip to content

Instantly share code, notes, and snippets.

// config.js
export.ranked = getConfigObject(true);
export.unranked = getConfigObject(false);
function getConfigObject(isRanked) {
return {
boardsize: checkBoardSetting(getRuSetting(arv["boardsize"], isRanked)
komi: checkSetting(getRuSetting(arv["komi"], isRanked)
}
#!/usr/bin/env node
'use strict';
process.title = 'gtp2ogs';
let DEBUG = false;
let PERSIST = false;
let KGSTIME = false;
let NOCLOCK = false;
let GREETING = "";
"use strict";
var matches = 0;
// 'Borrowed' from http://www.math.ucla.edu/~tom/distributions/binomial.html
function LogGamma(Z) {
var S=1+76.18009173/Z-86.50532033/(Z+1)+24.01409822/(Z+2)-1.231739516/(Z+3)+.00120858003/(Z+4)-.00000536382/(Z+5);
var LG= (Z-.5)*Math.log(Z+4.5)-(Z+4.5)+Math.log(S*2.50662827465);
return LG
"use strict";
var matches = 0;
function LL (x) {
return 1/(1+Math.pow(10,(-x/400)));
}
function LLR(W, L, elo0, elo1) {
//if (W==0 || L==0) return 0;
function LL (x) {
return 1/(1+10**(-x/400));
}
function LLR(W, L, elo0, elo1) {
//if (W==0 || L==0) return 0;
if (!W) W=1;
if (!L) L=1;
@Dorus
Dorus / GroupCache
Last active December 8, 2016 12:33
GroupCache
public sealed class GroupCache<TSource, TKey> : IConnectableObservable<TSource>
{
private IConnectableObservable<TSource> _souce;
private IObservable<TSource> _souceGrouped;
public GroupCache(IObservable<TSource> source, Func<TSource, TKey> keySelector)
{
_souce = source.Publish();
var sub = new ReplaySubject<IObservable<TSource>>();
_souce
@Dorus
Dorus / index.js
Last active May 6, 2021 11:18 — forked from xgrommx/index.js
How we can make methods of observable via other methods
const flatMap = (fn, stream, resultSelector) =>
stream.flatMap((x, xi) => fn(x).map((y, yi) => resultSelector(x, y, xi, yi)));
const flatMapLatest = (fn, stream) =>
stream.publish(s => s.flatMap(v => fn(v).takeUntil(s)));
const flatMapLatest = (fn, stream, resultSelector) => stream.publish(s => {
return s.flatMap(v => fn(v), resultSelector).takeUntil(s));
});
@Dorus
Dorus / samples.js
Created May 4, 2016 22:52
Marble samples
var source$ = Rx.Observable.marble("1--23--456--7890--");
var enter$ = Rx.Observable.marble("-e-----e----------");
var exit$ = Rx.Observable.marble("---x-------x------");
var sampler$ = Rx.Observable.marble("a--b--c--d--e--f--");
var full$ = Rx.Observable.marble("01234567890abcdefg");
source$.draw('source', '#container')
.debounceTime(1050).draw('debounceTime(1)', '#container');
source$.auditTime(1050).draw('auditTime(1)', '#container');
source$.throttleTime(1050).draw('throttleTime(1)', '#container');
package RxTest.RxTest;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import rx.Notification;
import rx.Observable;
import rx.functions.Action1;
import rx.functions.Func1;
@Dorus
Dorus / MyTransformers.java
Last active November 20, 2015 11:07
Additional RxJava transformers
/**
* Transformer to concat a new observable based on the last element of the previous observable. Use the default value
* if the first observable is empty.
*
* @param defaultValue
* the default.
* @param nextObservable
* function to create the next observable based on the current observable.
* @return the transformer.
*/