Skip to content

Instantly share code, notes, and snippets.

O(logn) enthusiast

Carter carterpeel

O(logn) enthusiast
  • Grand Rapids, Michigan
  • 00:32 (UTC -05:00)
View GitHub Profile
View tickpool.go
package tickpool
import (
func init() {
mu = &sync.Mutex{}
pool = &sync.Pool{
View asyncio.go
package asyncio
import (
type AsyncMultiWriter struct {
mu *sync.Mutex
View play.go
func (p *audioPlayer) Play(session *rtsp.Session) {
log.Logger.WithField("category", "AirPlay Player").Warnf("Starting new session")
p.curSession = session
decoder := codec.GetCodec(session)
go func(dc *codec.Handler) {
var ok bool
for {
select {
/* Is using a pre-allocated buffer for a chan receiver more ideal than:
[buf, ok := <- session.DataChan]? */
View binary_read.go
// Read reads structured binary data from r into data.
// Data must be a pointer to a fixed-size value or a slice
// of fixed-size values.
// Bytes read from r are decoded using the specified byte order
// and written to successive fields of the data.
// When decoding boolean values, a zero byte is decoded as false, and
// any other non-zero byte is decoded as true.
// When reading into structs, the field data for fields with
// blank (_) field names is skipped; i.e., blank field names
// may be used for padding.
carterpeel / fastbinary_test.go
Created Jan 30, 2022
Binary type switch is slow
View fastbinary_test.go
package fastbinary
import (
func BenchmarkInternalBinary_Read(b *testing.B) {
carterpeel / boyer-moore.go
Created Aug 1, 2021
Boyer-More algorithm, ingests a []byte slice and returns the index of the first occurrence of `substr`. (this is particularly useful for large `substr` values)
View boyer-moore.go
package bm
import "bytes"
func BoyerMooreIndex(s, substr []byte) int {
d := CalculateSlideTable(substr)
return IndexWithTable(&d, s, substr)
func IndexWithTable(d *[256]int, s, substr []byte) int {
View gist:c410e7f09269f46b03833c9b4c3c5f97
This file has been truncated, but you can view the full file.
carterpeel / Syslog-Aggregator.xml
Created Jun 24, 2021
Example XML definition for a syslog aggregator virtual machine
View Syslog-Aggregator.xml
<domain type='kvm'>
<libosinfo:libosinfo xmlns:libosinfo="">
<libosinfo:os id=""/>
<memory unit='KiB'>14336000</memory>
<currentMemory unit='KiB'>14336000</currentMemory>
View types.go
package main
type systemMetrics struct {
Domains []struct {
UUID string `json:"UUID"`
CPUCores int64 `json:"cpu_cores"`
CPUOtherSteal int64 `json:"cpu_other_steal"`
CPUOtherTotal int64 `json:"cpu_other_total"`
CPUSteal int64 `json:"cpu_steal"`
CPUTotal int64 `json:"cpu_total"`
carterpeel /
Created Oct 31, 2020 — forked from idear1203/
Play .mp4 video using Java MediaPlayer for 5 seconds. After that, the video will be closed.
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Duration;