Skip to content

Instantly share code, notes, and snippets.

@scottcagno
scottcagno / tracer.go
Created September 26, 2022 19:30
Stack tracer
package tracer
import (
"fmt"
"log"
"runtime"
"strings"
)
// DefaultTracer is the default tracer and has a call
@scottcagno
scottcagno / refactored_page.go
Last active September 8, 2022 23:37
Refactoring page scratch. Works really well so far.
package engine
import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"reflect"
"sort"
@scottcagno
scottcagno / EXAMPLE.md
Created August 19, 2022 21:30
Sample markdown File
@scottcagno
scottcagno / bitstuff.go
Created August 18, 2022 20:28
bitwise operations
package main
import (
"fmt"
"strconv"
)
func main() {
fmt.Println()
@scottcagno
scottcagno / logger.go
Last active August 9, 2022 18:53
Basic Leveled Logger
package logging
import (
"fmt"
"io"
"log"
"os"
"path/filepath"
"runtime"
)
@scottcagno
scottcagno / simple_sample_multiplexer.go
Created August 8, 2022 19:17
This is just a simple sample scratch multiplexer. It's fully working but has NO bells or anything.
package main
import (
"fmt"
"net/http"
)
func homeHandler() http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
// implement handler logic here...
// You can edit this code!
// Click here and start typing.
package main
import (
"errors"
"fmt"
"log"
"os"
"strings"
@scottcagno
scottcagno / picam-capture.sh
Created August 1, 2022 20:40
streaming the raspberry pi cam using netcat
#!/usr/bin/env bash
#
# picam-capture.sh
# to enable this at startup, add the line below to your rc.local file:
# sudo vim /etc/rc.local
# bash /full/path/to/this/file.sh # add this line
# configurable options
timestamp = "-a 12" # overlay a 12hr date/timestamp
@scottcagno
scottcagno / index_spans.go
Created July 7, 2022 21:05
File Utilities -- Scan, Index
// IndexSpans can be used to index spans of text based around a delimiter of your
// choice. The size argument allows you to tune it a bit and have some control over
// the overhead used by the function. The delimiter is not included in the returned
// span bound set and empty lines are not ignored.
func IndexSpans(r io.Reader, delim byte, size int) ([]Span, error) {
// Setup initial variables for the function
var id, beg, end int
// Drop is a helper func used to drop the correct number of bytes. Right now it
// is mostly used to handle the special case of \n and \r\n
drop := func(p []byte, c byte) int {
@scottcagno
scottcagno / binmap.go
Created May 19, 2022 22:51
binary mapping functions
package bin
// This package provides mapping functions to work with slices of uint
// types. It allows the getting, setting and transforming of various
// uint types such as uint, uint16, uint32 and uint64. Right now, this
// set of functions uses the LittleEndian encoding format, but future
// versions of this will have support for both the LittleEndian and
// BitEndian byte order.
// BinMapU16Fn is the mapping function signature for an uint16