Skip to content

Instantly share code, notes, and snippets.

@klauspost
klauspost / test.go
Last active January 6, 2016 12:23
filesystem test
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
//+build !appengine
package prefetch
func prefetchBS(b [][]byte)
@klauspost
klauspost / memmove.go
Created November 23, 2015 13:14
memmove testing harness.
package move
import "unsafe"
func memmove(to uintptr, from uintptr, n uintptr)
func MemMove(dst, src []byte) {
memmove(uintptr(unsafe.Pointer(&dst[0])), uintptr(unsafe.Pointer(&src[0])), uintptr(len(src)))
}
package main
import (
"fmt"
"math/rand"
)
// This will show various cases where bounds checks can be eliminated by keeping track of
// minimum and maximum potential values of slices and variables as SSA.
func main() {
// THESE PACKAGES ARE FOR DEMONSTRATION PURPOSES ONLY!
//
// THEY DO NOT NOT CONTAIN WORKING INTRINSICS!
//
// See https://github.com/klauspost/intrinsics
package sse2
import "github.com/bjwbell/gensimd/simd"
var _ = simd.M128{} // Make sure we use simd package
@klauspost
klauspost / hashtag.go
Created October 13, 2015 09:16
Hashtag identifier & splitter.
// Match tags in notes, etc.
// Group 1: Must start with whitespace OR start of string
// - : Must start with hash sign #
// Group 2: Match everything, until we reach a whitespace, '#' '.' ',' '!' ')'.
// Must be end of string
var matchTags = regexp.MustCompile(`[^\S]|^#([^\s#.,!)]+)$`)
// tagsSplitter returns true if the current rune is a tag ending
// Tags MUST end with whitespace, '.' ',' '!' or ')'
func tagsSplitter(c rune) bool {
@klauspost
klauspost / dictionary-sorted.txt
Last active May 5, 2024 19:22
Brotli dictionary - printed escaped
" </div>"
" })();\r\n"
" && "
" &amp; "
" &nbsp;"
" ''The "
" (&quot;"
" (199"
" (200"
" (e.g."
@klauspost
klauspost / splitfile.go
Created October 7, 2015 17:03
Split a file similar to how Total Commander does it (No CRC).
package main
import (
"fmt"
"io"
"os"
"path/filepath"
)
const (
package app
import (
"math/rand"
"time"
"github.com/revel/revel"
)
// randomDuration generates a duration between min and max duration.
// Copyright 2011 The Go Authors. All rights reserved.
// Copyright 2013 Klaus Post
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package crc32
import (
"github.com/klauspost/intrinsics/x86/sse2"
"github.com/klauspost/intrinsics/x86"