Skip to content

Instantly share code, notes, and snippets.

View jreisinger's full-sized avatar
👋
hello friend

Jozef Reisinger jreisinger

👋
hello friend
View GitHub Profile
// Chat is a TCP server that connects couples so they can talk.
// Adapted from https://go.dev/talks/2012/chat.slide
package main
import (
"fmt"
"io"
"log"
"net"
)
// Fibsrv is an HTTP server that calculate Fibonacci numbers.
package main
import (
"fmt"
"log"
"math/big"
"net/http"
"strconv"
)
// Fetch prints the download time and size for each URL. Usage:
//
// go build fetchz.go
// ./fetchz urls.txt
package main
import (
"bufio"
"fmt"
"io"
import argparse, hashlib, sys
from pathlib import Path
def store(path, data, key):
data_path = Path(path)
hash_path = data_path.with_suffix('.hash')
hash_value = hashlib.blake2b(data, key=key).hexdigest()
with data_path.open(mode='x'), hash_path.open(mode='x'):
data_path.write_bytes(data)
#!/usr/bin/env python3
import hashlib, sys
from hashlib import md5
def hash_with_all_guaranteed_algoritms(msg: bytes):
"""hash functions guaranteed to be available for all platforms"""
for algo in sorted(hashlib.algorithms_guaranteed):
try:
h = hashlib.new(algo)
#!/bin/bash
subnet=$1
[ -z $subnet ] && echo "Usage: $0 <subnet>" && exit 1
for host in $(seq 1 254); do
(ping -c1 -t1 $subnet.$host > /dev/null && arp $subnet.$host) &
done
sleep 5
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
go func() {
// Pathresolver handles complex URL paths with wildcards.
package main
import (
"fmt"
"log"
"net/http"
"path"
"strings"
)
/*
Rball simulates a game of racquetball to find out whether
a slightly better player can win significant number of games.
*/
package main
import (
"flag"
"fmt"
"math/rand"
// A common use case for Go is to take a stream of jobs of work and perform them
// automatically scaling up and down as work becomes available.
package main
import (
"bufio"
"fmt"
"log"
"net/http"
"os"