Skip to content

Instantly share code, notes, and snippets.

@rusco
rusco / index.html
Created June 13, 2024 08:23
htmlform2json
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
display: flex;
min-height: 98vh;
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<title>SVG Email Protection</title>
<style>
.svg-email-protection {
width: 180px;
@rusco
rusco / normaldist_simulator.js
Created November 27, 2023 13:16
use random numbers from 1 to 6 (dice) to simulate normal distribution in js, only for educational purposes
//purpose: use random numbers from 1 to 6 (dice) to simulate normal distribution in js, only for educational purposes
//author: jr
//date: 27.11.2023
const min = 1, max = 6;
let getRand = (countRand = 1) => {
let sumRand = 0;
for (let i = 0; i < countRand; i++)
sumRand += Math.floor(Math.random() * (max - min + 1)) + min;
@rusco
rusco / esbuildrunner.go
Created November 16, 2023 09:54
convert typescript to javascript with esbuild
// date: 16.11.2023
// file: convert typescript to javascript with esbuild
package main
import (
"fmt"
"os"
"github.com/evanw/esbuild/pkg/api"
)
@rusco
rusco / hipergeometic.js
Created November 8, 2023 09:59
hipergeometric function in javascript (with some testcases)
//07.11.2023
// Factorial function
const fact = (x) => (x == 0 ? 1 : x * fact(x - 1));
// binomial coefficient where a is the total set of posibbilites and b is the number of combinatios we're interested in
const bincoeff = (a, b) => fact(a) / (fact(a - b) * fact(b));
//hipergeometric function
const hipergeo = (M, N, n, k) => (bincoeff(M, k) * bincoeff(N - M, n - k)) / bincoeff(N, n);
@rusco
rusco / gheet.go
Created September 26, 2023 11:46
GSheet Update 26.09.2023
package main
import (
"fmt"
"os"
"strconv"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
sheet "gopkg.in/Iwark/spreadsheet.v2"
@rusco
rusco / sshtunnel.go
Created September 14, 2022 08:03
SSH Tunnel over HTTPS
package main
// 20220914, jr
import (
"C"
"context"
"fmt"
"net"
"os"
@rusco
rusco / sqliteembed.go
Created August 11, 2022 09:13
shows example embedding of a sqlite database in a Go binary (go 1.19/modernc.org/sqlite, v1.18.1)
//shows example embedding of a sqlite database in a Go binary (go 1.19/modernc.org/sqlite, v1.18.1)
package main
import (
"database/sql"
"embed"
"fmt"
"log"
@rusco
rusco / parallel.js
Created February 22, 2022 14:30
parallel versus sequential promises in Javascript
// jr
// parallel versus sequential promises in Javascript
// 22.02.2022
const parallel = true;
const startTime = performance.now();
console.clear();
const asyncTimeout = (delay, data) => (new Promise(resolve => { setTimeout(() => resolve(delay, data), delay) })).then(d => `Waited ${d} seconds`);
const asyncFetch = (url) => fetch(url).then(response => (response.text())).then(text => `Fetched ${url}, and got back ${text}`);
const runTask = (spec) => (spec.task === 'wait') ? asyncTimeout(spec.duration) : asyncFetch(spec.url);
@rusco
rusco / mergecsv.go
Created April 6, 2021 17:40
Merge 2 csv files line by line in Go via goroutines
// go build -ldflags "-s -w" .\mergecsv.go
// analyse 2 csv files line by line sequentially via goroutines
// 04/2021
package main
import (
"bufio"
"fmt"
"log"