Skip to content

Instantly share code, notes, and snippets.

View aziis98's full-sized avatar

Antonio De Lucreziis aziis98

View GitHub Profile
@aziis98
aziis98 / go-templates-cheatsheet.md
Created August 13, 2022 23:42
A small cheatsheat of Go Templates

Go Templates Cheat Sheet

Usage

Import text/template or html/template as needed.

tmpl, _ := template.New(“template_name”).Parse(“...”)
tmpl.Name() // => name of current template
tmpl.Execute(...) // => current template

Tema personalizzato per "www.dm.unipi.it"

Features

  • Il logo sta in una posizione più decente.
  • Le scatole al centro non hanno bordo #fff.

Installazione

  • Google Chrome / Chromium. Installare l'estensione Stylus per il browser, a quel punto andare su e premere sull'estensione e fare "Nuovo stile per" e selezionare tutto il sotto-dominio. A quel punto incollare il CSS di sopra e premere "Salva".
@aziis98
aziis98 / server.js
Created June 30, 2022 00:13
Simple ViteJS dev server with custom dynamic routes
import { dirname, resolve } from 'path'
import express from 'express'
import { createServer as createViteServer } from 'vite'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const ROUTES = {
'/': './index.html',
'/buckets/:bucket': './[bucket].html',

Message Passing in JS

A simple function to handle a comunication over TCP via JSON using js generators.

Usage

Write a generator for each side of the conversation. To send or receive a message at some point just yield with one of the following functions

import { awaitMessage, sendMessage } from './mp.js'

Prova

Uao $42$ uao

$$ 1 + 1 $$

Uao

@aziis98
aziis98 / extract_test.go
Created February 16, 2022 23:57
Go extract experiments
package extract_test
import (
"regexp"
"strings"
"testing"
)
func lines(source string) chan string {
output := make(chan string)

Non global slowing message queue

As in the title

Example

async function fakeProvider(onData) {
    onData('line 1');
 onData('line 2');
@aziis98
aziis98 / sync.md
Last active January 26, 2022 12:56
Syncronization Primitives Equivalence
@aziis98
aziis98 / !launch.md
Last active January 19, 2022 04:56
Launch commands in new detached tmux sessions.

Tmux launcher

Launch commands in a new detached tmux session. This needs tmux and sqlite3 to be installed, see launch --help for usage.

Sqlite is used for storing the command history in ~/.cache/aziis98.scripts.launch/history.db that can be run with launch past <SESSION_NAME>.

Info