Skip to content

Instantly share code, notes, and snippets.

View rheinardkorf's full-sized avatar

Rheinard Korf rheinardkorf

View GitHub Profile
@rheinardkorf
rheinardkorf / Dockerfile
Created June 8, 2018 05:58
Add MongoDB PHP driver (with SSL) to Docker image
# Get and make mongodb PHP driver
RUN yes | apt-get install libssl-dev \
&& git clone https://github.com/mongodb/mongo-php-driver.git --recursive \
&& cd mongo-php-driver \
&& phpize \
&& ./configure --with-mongodb-ssl=openssl \
&& make all \
&& make install \
&& echo "extension=mongodb.so" > /opt/php${SHORT_VERSION}/lib/conf.d/ext-mongodb.ini \
&& cd .. \
@rheinardkorf
rheinardkorf / snakeymap.go
Created May 28, 2018 11:39
Convert `map[string]interface{}` into a new `map[string]interface{}` with all keys converted to snake_case.
package snakeymap
func SnakeKeyMap(data map[string]interface{}) map[string]interface{} {
converted := make(map[string]interface{})
for key, val := range data {
goodKey := snakeKey(key)
switch v := val.(type) {
case map[string]interface{}:
@rheinardkorf
rheinardkorf / Makefile
Created February 23, 2018 05:28
Makefile for building and bundling a Go app as MacOS Application.
TITLE=My Title
BUNDLE_ID=com.rheinardkorf
PROJECT=MyApp
EXEC=app
VERSION=0.1
define plist
<?xml version="1.0" encoding="UTF-8"?> \
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@rheinardkorf
rheinardkorf / main.go
Created February 15, 2018 12:39
Go: BTCMarkets Authentication Example
package main
import (
"crypto/hmac"
"time"
"strconv"
"fmt"
"net/http"
"io/ioutil"
"crypto/sha512"
@rheinardkorf
rheinardkorf / example_test.go
Last active December 18, 2017 12:02
A very rugged way to do some mock endpoints with routes.
package example
import (
"testing"
"net/http/httptest"
"net/http"
"fmt"
"io/ioutil"
)
@rheinardkorf
rheinardkorf / phpcompat.php
Last active November 17, 2017 02:56
Example snippet to determine supported PHP versions using PHPCompatibility sniffs and phpcs.
<?php
function check_compatibility( $audit_files_directory, $phpcs_report_file, $phpcompat_report_file, $lowest_version = '5.2' ) {
// Official PHP versions.
// Note: Does not include patch releases as PHPCompatibility doesn't get this granular.
$php_versions = array(
'5.2',
'5.3',
@rheinardkorf
rheinardkorf / add-js-editor.js
Last active June 2, 2023 05:14
Example usage of JS editor API WordPress 4.8+
// Remember to wp_enqueue_editor(); inside PHP.
// Add editor
wp.editor.initialize(
'test-editor',
{
tinymce: {
wpautop:true,
plugins : 'charmap colorpicker compat3x directionality fullscreen hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage wpemoji wpgallery wplink wptextpattern wpview',
toolbar1: 'formatselect bold italic | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink | wp_more | spellchecker'

Keybase proof

I hereby claim:

  • I am rheinardkorf on github.
  • I am rheinard (https://keybase.io/rheinard) on keybase.
  • I have a public key ASB9TuTMvilmuznN6BgU_qlDotTEDiz199xdsUWbOVqnnwo

To claim this, I am signing this object:

@rheinardkorf
rheinardkorf / docker-manager.php
Created March 23, 2017 22:29
Example spinning up containers from containers using Docker Engine API and PHP.
<?php
class DockerManager {
/**
* This is where the magic happens.
* The Docker Engine socket needs to be mounted in docker-compose.yml.
*
* volumes:
* - /var/run/docker.sock:/var/run/docker.sock
@rheinardkorf
rheinardkorf / Wordpress Nginx Config
Created March 14, 2017 06:41 — forked from kjprince/Wordpress Nginx Config
/etc/nginx/wordpress.conf
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################
# /etc/nginx/wordpress.conf
#
# Contains a common configuration for use by nginx on a WordPress
# installation. This file should be included in any WordPress site
# nginx virtual host config located in sites-available with the following line:
#
# include /etc/nginx/wordpress.config;