Skip to content

Instantly share code, notes, and snippets.

💭
Hiring!

Mark van der Velden Dynom

💭
Hiring!
Block or report user

Report or block Dynom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View split_vs_suffix.go
package Random
import (
"strings"
"testing"
)
func BenchmarkSplitOrSuffixMatching(b *testing.B) {
const path = "/baz"
@Dynom
Dynom / gist:a2cc7f0d4938133e8961d00eb22b943e
Created Jan 16, 2017
Reclaim Docker claimed disk space on macOS
View gist:a2cc7f0d4938133e8961d00eb22b943e
You can reclaim your host's disk-space on macOS in the new Docker 1.13, reducing the file size of the `Docker.qcow2` file.
Steps:
1. du -sh ~/Library/Containers/com.docker.docker/Data (Check current disk usage)
2. docker run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n fstrim /var
3. restart docker (starting it might take a while)
4. du -sh ~/Library/Containers/com.docker.docker/Data
Additional:
* Checkout: docker system prune --help
@Dynom
Dynom / change-raw-JSON.go
Created Sep 21, 2016
Instead of (Un)marshalling into a valid struct, when you only care only about one field (in perhaps a dynamic JSON document) you could do the following
View change-raw-JSON.go
package main
import "fmt"
import "encoding/json"
const data = `{"a": "A", "b": "B", "c": "C"}`
func main() {
var objmap map[string]*json.RawMessage
err := json.Unmarshal([]byte(data), &objmap)
@Dynom
Dynom / circle.yml
Created Sep 13, 2016
A Go CircleCI config file
View circle.yml
checkout:
post:
# Remove a CircleCI directive that confuses our override, if it exists..
- git config --global --unset "url.git@github.com:.insteadof" ; if [ $? -eq 0 -o $? -eq 5 ]; then true; else false; fi; echo $?
- git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
dependencies:
pre:
# Temporary, using Go 1.7
- curl -O https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz && tar -xvf go1.7.linux-amd64.tar.gz && sudo bash -c 'rm -rf /usr/local/go && mv go /usr/local'
- go get -u github.com/alecthomas/gometalinter && gometalinter -ui
View endpoint.go
import (
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/log"
"golang.org/x/net/context"
// ...
)
func MakeJSONRPCEndpoint(registry RPCMethodRegistry, logger log.Logger) endpoint.Endpoint {
return func(_ context.Context, request interface{}) (interface{}, error) {
typedRequest := request.(JSONRPCRequest)
View keybase.md

Keybase proof

I hereby claim:

  • I am dynom on github.
  • I am dynom (https://keybase.io/dynom) on keybase.
  • I have a public key whose fingerprint is A121 FAEC 0A97 0D76 7478 DB9C C3DE 78B7 CDE2 A243

To claim this, I am signing this object:

@Dynom
Dynom / gist:0e6ca1917bd9dc8cca8e
Created Nov 8, 2015
Git on OSX committing a case change in the fileame.
View gist:0e6ca1917bd9dc8cca8e
[/tmp/case]
mark@Dymek:$ git init
Initialized empty Git repository in /private/tmp/case/.git/
[/tmp/case] (master)
mark@Dymek:$ touch foo
[/tmp/case] (master)
mark@Dymek:$ git add foo
@Dynom
Dynom / calculate-encryption-time.php
Created May 30, 2014
A snippet that will calculate the work/cost factor of encrypting. Based on a number in seconds it suggest a cost factor
View calculate-encryption-time.php
/**
* This code will benchmark your server to determine how high of a "cost" you
* can afford. You want to set the highest cost that you can without slowing
* down your server too much. 10 is a good baseline, and more is good if your
* servers are fast enough.
*
* Obviously You should run this on the server that will be encrypting..
*/
// What is the maximum time, your server should spend on encrypting?
View gist:19a6446c78c87f607b84
<?php
$roundingInMinutes = 2;
$roundingInSeconds = ($roundingInMinutes * 60);
$t = time();
$rounded = ($t - ($t % $roundingInSeconds));
@Dynom
Dynom / gist:9618999
Created Mar 18, 2014
Redis unexpected behaviour when enabling AOF after the fact.
View gist:9618999
Steps to reproduce:
# Make sure that in your redis.conf:
appendonly no
# Also make sure that, in your redis.conf:
dbfilename FOO-dump.rdb
save "900 1"
save "300 10"
save "60 10000"
You can’t perform that action at this time.