Skip to content

Instantly share code, notes, and snippets.

@klauspost
klauspost / memset_amd64.go
Last active August 29, 2015 14:23
go memset (byte slice)
package memset
func memset(dst []byte, value byte)
package main
// Adapted from : https://gist.github.com/arnehormann/65421048f56ac108f6b5
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
"io"
SET LEVEL=1
compress -in=%1 -out=* -stats -header=true -w="gzstd" -l=%LEVEL% >>results.txt
compress -in=%1 -out=* -stats -header=false -w="gzkp" -l=%LEVEL% >>results.txt
compress -in=%1 -out=* -stats -header=false -w="pgzip" -l=%LEVEL% >>results.txt
compress -in=%1 -out=* -stats -header=false -w="cgzip" -l=%LEVEL% >>results.txt
SET LEVEL=2
compress -in=%1 -out=* -stats -header=false -w="gzstd" -l=%LEVEL% >>results.txt
package main
// Adapted from : https://gist.github.com/arnehormann/65421048f56ac108f6b5
import (
"encoding/binary"
"flag"
"fmt"
"io"
"io/ioutil"
// 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"
package app
import (
"math/rand"
"time"
"github.com/revel/revel"
)
// randomDuration generates a duration between min and max duration.
@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 (
@klauspost
klauspost / dictionary-sorted.txt
Last active August 25, 2024 23:18
Brotli dictionary - printed escaped
" </div>"
" })();\r\n"
" && "
" &amp; "
" &nbsp;"
" ''The "
" (&quot;"
" (199"
" (200"
" (e.g."
@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 {
// 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