Skip to content

Instantly share code, notes, and snippets.

@rusco
rusco / Caddyfile
Last active January 13, 2025 13:33
Vue.js usage with Golang Wasm
localhost:8080
gzip
log ../access.log
mime .wasm application/wasm
@rusco
rusco / timeout.js
Created October 23, 2019 09:57
Timeout Gist
const pause = ms => new Promise(resolve => setTimeout(resolve, ms));
await pause(400);
@rusco
rusco / parse.go
Created December 10, 2019 14:51
parsing of lawyers from https://portal.oa.pt/ website
//
// date 11.11.2019
// author jr
// purpose parsing of lawyers from https://portal.oa.pt/ website
//
package main
import (
"fmt"
"io/ioutil"
@rusco
rusco / worktime.go
Created December 10, 2019 14:55
calc workingtime 09:00 h until 18:00 h, 1 hour lunch break from 12:00 h until 14:00 h
package worktime
//17.09.15, 22.02.18
import (
"fmt"
"os"
"strings"
"time"
)
//jr 12.12.19
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final appTitle = 'Drawer Demo';
@override
Widget build(BuildContext context) {
@rusco
rusco / package.json
Created December 13, 2019 12:10
simple typescript & rollup scaffold (windows server)
{
"type": "module",
"date": "2019-12-06T12:20:00.000Z",
"name": "demo",
"version": "1.0.0",
"description": "demo",
"home": "D:\\devname\\web\\",
"server": "\\\\servername\\d$\\dir\\",
"scripts": {
"build": "rollup -c",
@rusco
rusco / GmailReaderAppsScript.js
Created January 17, 2020 16:16
Reads Gmail into a Google Sheet
//
// date: 17.01.2020, jr
//
var SEARCH_QUERY = "label:inbox is:unread to:me";
var SEARCH_QUERY_ALL = "label:inbox to:me";
function getEmails_(q) {
var email = [];
var threads = GmailApp.search(q);
for (var i in threads) {
@rusco
rusco / randomseed.js
Created December 10, 2020 20:47
random numbers in javascript with seed to be reproduceable
const seed = 1;
function random() {
const x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
@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"
@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);