Skip to content

Instantly share code, notes, and snippets.

View Dynom's full-sized avatar
👋
Hi, how are you today!

Mark van der Velden Dynom

👋
Hi, how are you today!
View GitHub Profile
@Dynom
Dynom / gist:5866837
Last active December 5, 2017 14:05
Creating ISO 8601-extended in PHP, using DateTime. This includes milliseconds (and if you want, microseconds). Based on the work mentioned here: http://stackoverflow.com/a/4414060/1061927
<?php
// Our input
$time = microtime(true);
// Determining the microsecond fraction
$microSeconds = sprintf("%06d", ($time - floor($time)) * 1000000);
// Creating our DT object
$tz = new DateTimeZone("Etc/UTC"); // NOT using a TZ yields the same result, and is actually quite a bit faster. This serves just as an example.
@Dynom
Dynom / 0_reuse_code.js
Created January 22, 2014 07:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
$scheduler = new Scheduler();
$batch = new Batch(new BatchContext(/* ... */), new ThrottleBatchStrategy());
// Add jobs
$batch->addJob(new FooJob( new JobContext() ));
@Dynom
Dynom / gist:9618999
Created March 18, 2014 12:19
Redis unexpected behaviour when enabling AOF after the fact.
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"
<?php
$roundingInMinutes = 2;
$roundingInSeconds = ($roundingInMinutes * 60);
$t = time();
$rounded = ($t - ($t % $roundingInSeconds));
@Dynom
Dynom / calculate-encryption-time.php
Created May 30, 2014 08:10
A snippet that will calculate the work/cost factor of encrypting. Based on a number in seconds it suggest a cost factor
/**
* 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?
@Dynom
Dynom / gist:0e6ca1917bd9dc8cca8e
Created November 8, 2015 14:53
Git on OSX committing a case change in the fileame.
[/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

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:

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)
@Dynom
Dynom / circle.yml
Created September 13, 2016 07:45
A Go CircleCI config file
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