This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/** | |
@author Ophir LOJKINE | |
@license BSD_3Clause | |
**/ | |
var fs = require('fs'); | |
var csvparse = require('csv-parse'); | |
var DocxTemplater = require('docxtemplater'); | |
var util = require('util'); |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"а":{"д":{"а":{"ж":{"и":{"о":{}}},"м":{"а":{"н":{"т":{"а":{},"е":{},"у":{},"о":{"м":{}}}}},"о":{"в":{"а":{}}}},"п":{"т":{"е":{"р":{"а":{"м":{"и":{}},"х":{}},"е":{},"у":{},"ы":{},"о":{"в":{},"м":{}}}},"а":{"ц":{"и":{"и":{},"й":{},"ю":{},"я":{"м":{"и":{}},"х":{}},"е":{"й":{}},"о":{"н":{"н":{"а":{"я":{}},"о":{"е":{},"й":{},"м":{"у":{}},"г":{"о":{}}},"у":{"ю":{}},"ы":{"е":{},"й":{},"м":{"и":{}},"х":{}}}}}}}},"и":{"в":{"е":{"н":{}},"н":{"а":{"я":{}},"о":{"е":{},"й":{},"м":{"у":{}},"ю":{},"г":{"о":{}}},"ы":{"е":{},"й":{},"м":{"и":{}},"х":{}},"у":{"ю":{}}}},"р":{"у":{"й":{"с":{"я":{}},"т":{"е":{"с":{"ь":{}}}}},"ю":{"т":{"с":{"я":{}}},"с":{"ь":{}},"щ":{"а":{"я":{"с":{"я":{}}}},"е":{"е":{"с":{"я":{}}},"й":{"с":{"я":{}}},"м":{"у":{"с":{"я":{}}},"с":{"я":{}}},"г":{"о":{"с":{"я":{}}}}},"и":{"е":{"с":{"я":{}}},"й":{"с":{"я":{}}},"м":{"и":{"с":{"я":{}}},"с":{"я":{}}},"х":{"с":{"я":{}}}},"у":{"ю":{"с":{"я":{}}}}}},"я":{"с":{"ь":{}}},"е":{"м":{"а":{"я":{}},"о":{"е":{},"й":{},"м":{"у":{}},"г":{"о":{}}},"с":{"я":{}},"у":{"ю": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var dic = fs.readFileSync("/dev/stdin", "utf8").split("\n"); | |
var trie = {}; | |
for(var i=0; i<dic.length; i++) { | |
var w = dic[i]; | |
var t = trie; | |
for(var j=0; j<w.length; j++) { | |
var l = w[j]; | |
if(!t[l]) t[l] = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** pe | |
* @argument f: the multiple-argument function to turn into a partially-evaluatable | |
* @returns : A single-argument function that applies its argument as the first argument of f, and returns the partially-evaluated function | |
* @exemple: pe((a,b)=>a+b)(9)(1) === 10 | |
*/ | |
function pe(f, context, args) { | |
if(!args) args = []; | |
if (args.length === f.length) return f.apply(context, args); | |
return function partial (a) { | |
var args_copy = args.concat.apply(args, arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(f) { | |
var dict = {}; | |
return function() { | |
var args = JSON.stringify(arguments); | |
if(dict.hasOwnProperty(args)) return dict[args]; | |
var res = f.apply(null, arguments); | |
dict[args] = res; | |
return res; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.onmousemove = function(evt) { | |
var s = window.getSelection(); | |
if (s.rangeCount === 0) return; | |
while(s.rangeCount > 1) s.removeRange(s.getRangeAt(1)); | |
r = s.getRangeAt(0); | |
if (r.startContainer.parentNode !== r.endContainer.parentNode) { | |
r.setEnd(r.startContainer, r.startContainer.length); | |
evt.preventDefault(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Genetic { | |
constructor(conf) { | |
this.setConfiguration(conf); | |
this.population = new Int32Array(this.conf.genomeLength * this.conf.populationSize); | |
for (let i=0; i<this.conf.populationSize; i++) this.seedGenome(this.getGenome(i)); | |
} | |
setConfiguration(conf) { | |
this.conf = Object.assign({ | |
populationSize: 100, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapfilter(array, fun) { | |
// Equivalent to array.map(fun).filter(x => x !== undefined) | |
var res = []; | |
for(var i=0; i<array.length; i++) { | |
var r = fun(array[i], i, array); | |
if (r !== void 0) res.push(r); | |
} | |
return res; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fromRoman(str) { | |
// Parse str as a roman numeral | |
var values = {I:1, V:5, X:10, L:50, C:100, D:500, M:1000}; | |
str = str.toUpperCase(); | |
var n = 0, v1 = 0, v2 = values[str[0]]; | |
for (var k = 0; k < str.length; k++) { | |
var v1 = v2, v2 = k+1 < str.length ? values[str[k+1]] : 0; | |
n += (v2 > v1) ? -v1 : v1; | |
} | |
return n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (Html, Attribute, text, toElement, div, input) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (on, targetValue) | |
import Signal exposing (Address) | |
import StartApp.Simple as StartApp | |
import Debug | |
type Tree a | |
= Empty | |
| Node a (Tree a) (Tree a) |