Skip to content

Instantly share code, notes, and snippets.

View lnsp's full-sized avatar
👊

Lennart lnsp

👊
View GitHub Profile
@lnsp
lnsp / snowflake_profile.go
Last active May 30, 2022 19:31
Snowflake profiling script
package main
import (
"bufio"
"context"
"database/sql"
"database/sql/driver"
"flag"
"fmt"
"io"
for i in `seq 1 20`; do sudo runsc run pthreads; done
1.183
1.183
1.199
1.145
1.200
1.175
1.193
1.128
1.104
package main
import (
"bufio"
"bytes"
"encoding/binary"
"flag"
"fmt"
"net"
"os"
@lnsp
lnsp / httq_ps.go
Created January 3, 2020 12:24
Simple HTTP Pub/Sub server
package main
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"os"
"sync"
)
@lnsp
lnsp / httq.go
Created January 2, 2020 19:10
Simple HTTP stream messaging server
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
)
@lnsp
lnsp / ShadesOfPurple.terminal
Created October 23, 2019 16:40
Shades Of Purple theme for macOS Terminal.app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGnCwwXHSEoLFUkbnVsbNUNDg8Q
ERITFBUWXE5TQ29tcG9uZW50c1VOU1JHQlxOU0NvbG9yU3BhY2VfEBJOU0N1c3RvbUNv
bG9yU3BhY2VWJGNsYXNzTxAoMC4xMjA0Mzg0OTM4IDAuMTEyMDQ1MjUwOCAwLjI0NzA4
@lnsp
lnsp / unionfind.py
Created February 11, 2019 23:52
Basic implementation of union-find data structure
#!/usr/bin/python3
class Node(object):
def __init__(self, value, successor, item):
self.value = value
self.successor = successor
self.item = item
class Item(object):
def __init__(self, head, tail):
@lnsp
lnsp / maxflow.py
Created February 11, 2019 00:23
Simple tool that calculates the max flow in an undirected graph
#!/usr/bin/python3
class Graph(object):
def __init__(self, nodes):
self.nodes = list(nodes)
self.edges = dict((n, dict()) for n in nodes)
def add_edge(self, a, b, w):
if a in self.nodes:
self.edges[a][b] = w
@lnsp
lnsp / xorlist.c
Created January 13, 2019 23:56
Implementation of a XOR-Doubly linked list
/*
* Basic XORLIST-Implementation.
* (c) 2019 Lennart Espe. All rights reserved.
*/
#include <stdlib.h>
#include <stdio.h>
struct item {
uintptr_t both;
int value;
@lnsp
lnsp / iface.go
Created June 9, 2018 11:28
Simple network tool to list interfaces
package main
import (
"fmt"
"github.com/fatih/color"
"net"
"os"
)
func main() {