This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://en.wikipedia.org/wiki/Modular_arithmetic#Examples | |
-- https://ellie-app.com/hd32NnLQSFqa1 | |
-- Output: | |
-- 38 ≡ 14 (flooring mod 12) | |
-- 2 ≢ -3 (flooring mod 5) | |
-- -8 ≢ 7 (flooring mod 5) | |
-- -3 ≢ -8 (flooring mod 5) | |
-- | |
-- 38 ≡ 14 (truncating mod 12) | |
-- 2 ≢ -3 (truncating mod 5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
echo this script works when you run it without args | |
exit 0 | |
fi | |
# the parser only reaches this syntactically-invalid line if you pass the script args, | |
# proving that Bourne-compatible shells don't have separate parse and evaluate passes. | |
esac ] $(`)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "strconv" | |
func main() { | |
println(strconv.Itoa(5)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: | |
Linux 3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01) x86_64 GNU/Linux | |
[Dual Core] Intel(R) Atom(TM) CPU N450 @ 1.66GHz | |
(below output manually aligned) | |
Array#sort x 100,884 ops/sec ±1.54% (87 runs sampled) | |
mout/array/sort x 28,408 ops/sec ±1.98% (89 runs sampled) | |
nativeStableSort x 30,591 ops/sec ±4.26% (81 runs sampled) | |
nativeInPlaceStableSort x 66,010 ops/sec ±2.15% (97 runs sampled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"unsafe" | |
) | |
const N = 32 << 20 // 32 MiB | |
type struct32 struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 config | |
48 util | |
37 client | |
32 log | |
28 web | |
27 server | |
26 cache | |
25 model | |
23 core | |
23 redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/extemporalgenome/sortutil" | |
"os" | |
"sort" | |
) | |
func main() { | |
sortutil.Analyze(os.Stdout, true, sort.Sort) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For whatever reason, at least with amd64 tests builds on my AMD X2 3800+, | |
the pointer receiver implementation is 13% slower when bound checks are elided. | |
# default run (value receiver is 49% slower than ptr receiver) | |
go test -bench . | |
BenchmarkSortVal 1000000 1300 ns/op | |
BenchmarkSortPtrToVal 1000000 1297 ns/op | |
BenchmarkSortPtr 2000000 870 ns/op | |
# no bounds checking (value receiver is 11% slower than ptr receiver) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hex_buffer(buf): | |
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf)) | |
retstr="E'"+retstr+"'" | |
return retstr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hex_buffer(buf): | |
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf)) | |
retstr="E'"+retstr+"'" | |
return retstr |