Skip to content

Instantly share code, notes, and snippets.

View pschultz's full-sized avatar

Peter Schultz pschultz

  • classmarkets GmbH
  • Berlin, Germany
View GitHub Profile
@pschultz
pschultz / cert.go
Created September 18, 2019 15:33 — forked from jredl-va/cert.go
Certificate Generation
func GenCA(name string) (certPEM, keyPEM []byte, err error) {
now := time.Now().UTC()
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: name},
NotBefore: now,
NotAfter: now.Add(caMaxAge),
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
IsCA: true,
@pschultz
pschultz / keybase.md
Last active September 15, 2022 15:15

Keybase proof

I hereby claim:

  • I am pschultz on github.
  • I am pschultz (https://keybase.io/pschultz) on keybase.
  • I have a public key whose fingerprint is B205 720D 1FCC CC80 938D 40E6 0C80 1A7A 602C FED2

To claim this, I am signing this object:

@pschultz
pschultz / app.php
Created November 23, 2016 12:29
Why PHP's declare(strict_types=1); everywhere is impossible
<?php declare(strict_types=1);
require 'library.php';
public_library_function();
@pschultz
pschultz / config.yml
Created June 27, 2014 14:59
Enable Twig's Text extension in Symfony 2
services:
twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
@pschultz
pschultz / lru.php
Last active August 29, 2015 14:02 — forked from synboo/lru.php
<?php
/**
* LRU is a system which cache data used last recently.
* see more: http://www.slideshare.net/t_wada/tddbc-exercise
*/
class LRU
{
protected $_cache = array();
@pschultz
pschultz / composer.json
Last active August 29, 2015 14:00
Parse mailbox headers in PHP
{
"require": {
"ext-imap": "*",
"swiftmailer/swiftmailer": "~5.0"
}
}
@pschultz
pschultz / router.js
Last active October 1, 2017 16:06 — forked from jeffrafter/handler.js
Webservice starting point
var parser = require('url');
var handlers = {};
var Handler = function(callback) {
this.process = function(req, res) {
params = null;
return callback.apply(this, [req, res, params]);
}
}
@pschultz
pschultz / gitlab-receiver.go
Last active August 29, 2015 13:56
Blueprint for a Gitlab webhook receiver. Developed against Gitlab 6.
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"time"
)
@pschultz
pschultz / kitchen.rsync.patch
Last active December 31, 2015 05:59
Running kitchen converge is part of your normal workflow when developing cookbooks? VMs are always local and Chef is run in solo mode? Annoyed by the unnecessary cookbook upload every time you run kitchen that takes longer than actually converging the node? Here is a hack for you, that makes kitchen use rsync instead of scp. The diff is based on…
diff --git a/lib/kitchen/provisioner/chef_base.rb b/lib/kitchen/provisioner/chef_base.rb
index 79235d4..bb4fccf 100644
--- a/lib/kitchen/provisioner/chef_base.rb
+++ b/lib/kitchen/provisioner/chef_base.rb
@@ -102,9 +102,7 @@ module Kitchen
end
def init_command
- dirs = %w{cookbooks data data_bags environments roles}.
- map { |dir| File.join(config[:root_path], dir) }.join(" ")
@pschultz
pschultz / ItemCollection.php
Created October 29, 2013 12:48
guzzle responseClass example
<?php
namespace Classmarkets\Api;
use Guzzle\Service\Command\OperationCommand;
class ItemCollection extends \Doctrine\Common\Collections\ArrayCollection
{
// This is the method Guzzle is looking for
public static function fromCommand(OperationCommand $command)