Skip to content

Instantly share code, notes, and snippets.

View JanVoracek's full-sized avatar
🏠
Working from home

Jan Voráček JanVoracek

🏠
Working from home
View GitHub Profile
@JanVoracek
JanVoracek / machine.js
Last active October 5, 2021 11:25
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
/* eslint-disable */
module.exports = {
name: "@yarnpkg/plugin-entrypoint-lockfiles",
factory: function (require) {
var plugin;(()=>{var e={490:e=>{const t="win32"===process.platform,n=t?"\\\\+":"\\/",i=t?"\\\\":"/",o=`((?:[^${i}]*(?:${i}|$))*)`,r=`([^${i}]*)`;e.exports=function(e,{extended:t=!1,globstar:i=!1,strict:s=!1,filepath:l=!1,flags:a=""}={}){let c="",f="",p={regex:"",segments:[]},u=!1,g=!1;const d=[];function w(e,{split:t,last:i,only:o}={}){"path"!==o&&(c+=e),l&&"regex"!==o&&(p.regex+="\\/"===e?n:e,t?(i&&(f+=e),""!==f&&(a.includes("g")||(f=`^${f}$`),p.segments.push(new RegExp(f,a))),f=""):f+=e)}let y,x;for(let n=0;n<e.length;n++)if(y=e[n],x=e[n+1],["\\","$","^",".","="].includes(y))w("\\"+y);else if("/"!==y)if("("!==y)if(")"!==y)if("|"!==y)if("+"!==y)if("@"===y&&t&&"("===x)d.push(y);else if("!"!==y)if("?"!==y)if("["!==y)if("]"!==y)if("{"!==y)if("}"!==y)if(","!==y)if("*"!==y)w(y);else{if("("===x&&t){d.push(y);continue}let s=e[n-1],l=1;for(;"*"===e[n+1];)l++,n++;let a=e[n+1];if(i){l>1&&("/"===s||void 0
@JanVoracek
JanVoracek / roman.kt
Created January 31, 2018 00:23
Part of RomanCalculator
fun add(first: String, second: String): String {
return intToRoman(romanToInt(first) + romanToInt(second))
}
// It's important to keep it descending order
private val romanMap = linkedMapOf(
"M" to 1000,
"CM" to 900,
"D" to 500,
"CD" to 400,
@JanVoracek
JanVoracek / recursive-readdir.ts
Created November 7, 2016 14:58
Comparison of generator vs. promise + callback
import * as rx from "rxjs";
import * as fs from "fs-promise";
import * as path from "path";
function readdir(dir) {
return rx.Observable.create((observer: rx.Observer<string>) => {
fs.readdir(dir).then(async files => {
for (const file of files) {
let fullPath = path.join(dir, file);
// --- DOES NOT WORK
var repaint = function () {
wrappedPaint(buf.byteOffset, w, h);
imageData.data.set(buf);
ctx.putImageData(imageData, 0, 0);
window.requestAnimationFrame(repaint);
};
init();
repaint(true);
package codingdojo;
import com.google.common.base.Splitter;
public class Wrapper {
public static String wrap(String text, int chunkSize) {
return String.join("\n", Splitter.fixedLength(chunkSize).split(text));
}
}
@JanVoracek
JanVoracek / Dojo.cs
Last active August 29, 2015 14:01
Coding Dojo Pardubice #4 – Functional approach
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Xunit.Extensions;
namespace CodingDojo
{
public class Dojo
{
(ns rps.core
(:use clojure.core.match))
(defn get-rps-winner [choice-1, choice-2]
(match [choice-1, choice-2]
[choice-2, choice-1] :draw
[:rock :paper] :paper
[:paper :rock] :paper
[:rock :scissors] :rock
[:scissors :rock ] :rock
class Article {
...
public function saveArticle() {
...
}
}
// Takhle taky NE! :)
@JanVoracek
JanVoracek / original.txt
Last active December 17, 2015 12:39
INKOM test
00:15:30
Kompilátory - zkušební test (3 otázky mají 2 správné odpovědi)
1
Kompilátory
19
Kompilátor se koncepčně skládá z dvou základních etap:
°
1 Analýza a syntéza.
0 Analýza a optimalizace kódu.
0 Lexikální a syntaktická analýza.