Skip to content

Instantly share code, notes, and snippets.

View Deleplace's full-sized avatar

Valentin Deleplace Deleplace

View GitHub Profile
@Deleplace
Deleplace / extractSkpThumb.go
Created December 8, 2016 13:28
Brutal extraction of the thumbnail PNG of a Sketchup file
package main
import (
"bytes"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
package main
import (
"bytes"
"encoding/binary"
"fmt"
"io/ioutil"
)
// v represents a Vertex ID.
@Deleplace
Deleplace / server.go
Created March 16, 2017 12:52
Draft of server with QR-code in HTTP response headers
package main
import (
"fmt"
"log"
"net/http"
"strings"
"time"
)
@Deleplace
Deleplace / gist:277812527e056f625e4f4b7a9e23ee37
Created July 30, 2017 17:35
Tests from posener/complete failing on my linux workstation when env var GOPATH is not set
[~/go/src/github.com/posener/complete] master $ go test ./...
ok github.com/posener/complete 0.007s
? github.com/posener/complete/cmd [no test files]
? github.com/posener/complete/cmd/install [no test files]
? github.com/posener/complete/example/self [no test files]
--- FAIL: TestPredictions (0.00s)
--- FAIL: TestPredictions/predict_system_ok (0.00s)
tests_test.go:64: Failed TestPredictions/predict_system_ok: got: [], want: ["github.com/posener/complete/gocomplete/"]
FAIL
FAIL github.com/posener/complete/gocomplete 0.006s
@Deleplace
Deleplace / gist:bfaff085b813cd8c602a253ca45e46ac
Last active August 1, 2017 21:11
Trying the Go one-liner installer in a fresh GCE instance
Linux instance-1 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
deleplace@instance-1:~$ go
-bash: go: command not found
deleplace@instance-1:~$ env | grep GO
deleplace@instance-1:~$ curl -LO https://get.golang.org/$(uname)/go_installer && chmod +x go_installer && ./go_inst
@Deleplace
Deleplace / locality_test.go
Last active June 22, 2018 12:16
Benchmark of memory locality: access an array in different order
package locality
import (
"math/rand"
"testing"
)
const M = 100000
// How fast is it to access a[0], a[1], ..., a[M-1] ?
@Deleplace
Deleplace / 5mod8.go
Created June 25, 2018 12:01
Reads integers from stdin. How many of them verify (x % 8) == 5 ?
package main
import (
"fmt"
"io"
)
func main() {
var x, hits int
for {
@Deleplace
Deleplace / racy3.go
Last active August 1, 2018 07:54
The Go race detector catches synchronization bugs only when they actually occur.
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
func main() {
@Deleplace
Deleplace / not-racy.go
Created August 9, 2018 12:21
This program is not racy, but it's not deterministic either.
package main
import (
"fmt"
"sync"
)
func main() {
a := 0
@Deleplace
Deleplace / hello.go
Created November 26, 2018 12:34
Trace for AppEngine Standard with Go 1.9 (can't deploy as of 2018-11-26)
// Copyright 2018 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"log"
"net/http"