Skip to content

Instantly share code, notes, and snippets.

View onnimonni's full-sized avatar

Onni Hakala onnimonni

View GitHub Profile
@onnimonni
onnimonni / sendmail
Last active May 29, 2017 19:33
msmtp wrapper which acts like sendmail and reads configs from envs. Useful in php docker containers to ensure that all mail() calls are working.
#!/bin/bash
##
# This is custom wrapper for msmtp which acts like good old sendmail
# - It is used for php and cron
# - This is easier to configure for external mail server than sendmail
# - sendmail is just the default binary which other services will use
# - It needs following env: SMTP_HOST, SMTP_PASSWORD, SMTP_PORT, SMTP_AUTH, SMTP_USER
##
# This script gives itself as a parameter for msmtp
@onnimonni
onnimonni / composer.json
Last active April 22, 2017 11:17
wchel2017 example composer
{
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "composer",
"url": "https://wp-languages.github.io"
}
@onnimonni
onnimonni / s3.tf
Created March 13, 2017 10:03
s3 replicated bucket with terraform
# Create all variables used in this Terraform run
variable "aws_access_key" {}
variable "aws_access_secret_key" {}
variable "aws_bucket_name" {}
variable "aws_region_main" {
default = "eu-west-1"
}
variable "aws_region_replica" {
default = "eu-central-1"
}
@onnimonni
onnimonni / mariadb.log
Created March 6, 2017 11:28
Flynn mariadb logs
2017-03-01T14:28:45.976072Z app[mariadb.grid6.example.com-600eaadc-a134-4419-9f94-630b3c58d4b3]: t=2017-03-01T14:28:45+0000 lvl=info msg="db init" app=mariadb component=peer online=false setup=false
2017-03-01T14:28:45.976111Z app[mariadb.grid6.example.com-600eaadc-a134-4419-9f94-630b3c58d4b3]: t=2017-03-01T14:28:45+0000 lvl=info msg="starting event handler" app=mariadb component=discoverd fn=receiveEvents
2017-03-01T14:28:45.976681Z app[mariadb.grid6.example.com-600eaadc-a134-4419-9f94-630b3c58d4b3]: t=2017-03-01T14:28:45+0000 lvl=info msg="discoverd init" app=mariadb component=peer peers=0 state=false
2017-03-01T14:28:45.976697Z app[mariadb.grid6.example.com-600eaadc-a134-4419-9f94-630b3c58d4b3]: t=2017-03-01T14:28:45+0000 lvl=dbug msg=moving app=mariadb component=peer
2017-03-01T14:28:45.976727Z app[mariadb.grid6.example.com-600eaadc-a134-4419-9f94-630b3c58d4b3]: t=2017-03-01T14:28:45+0000 lvl=info msg="starting state evaluation" app=mariadb component=peer fn=evalClusterState
2017-03-01T14:28:45.976749Z ap
#!/bin/bash
databases=`mysql -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in databases; do
mysqldump --force --opt --databases $db > $db.sql
done
@onnimonni
onnimonni / Dockerfile
Last active August 8, 2018 11:24
How to fix cron and su 'System error' with debian and docker running with --net=host option. https://github.com/docker/docker/issues/5899
FROM debian:jessie
MAINTAINER Onni Hakala <[email protected]>
ENV DEBIAN_FRONTEND=noninteractive
RUN set -x \
# Add all deb-src addresses
&& echo "deb http://deb.debian.org/debian jessie main\n\
deb-src http://deb.debian.org/debian jessie main\n\
#!/usr/bin/env python
import os
import re
import subprocess
import sys
def main():
# If necessary, run gpg-agent
if not is_running():
@onnimonni
onnimonni / main.go
Created February 7, 2017 09:24
Almost working http2 server push with Link headers
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"github.com/tomnomnom/linkheader"
)
@onnimonni
onnimonni / gist:e9d2f48b9b494f7aeda1b9b92cc79ffe
Created January 27, 2017 14:46
phpstorm example workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpServers">
<servers>
<server host="wordpress.test" id="6b0e892b-1b0b-4db2-812d-e29244ffcff6" name="wordpress.test" port="443" use_path_mappings="true">
<path_mappings>
<mapping local-root="$PROJECT_DIR$" remote-root="/var/www/project" />
</path_mappings>
</server>
</servers>
@onnimonni
onnimonni / http2.log
Last active January 24, 2017 22:01
Cloudflare tcp logs from Chrome which shows how image.jpg gets succesfully pushed with http2 server push feature.
t=15910 [st= 0] +HTTP2_SESSION [dt=?]
--> host = "http2-server-push-demo.keksi.io:443"
--> proxy = "DIRECT"
t=15910 [st= 0] HTTP2_SESSION_INITIALIZED
--> protocol = "h2"
--> source_dependency = 705 (SOCKET)
t=15910 [st= 0] HTTP2_SESSION_SEND_SETTINGS
--> settings = ["[id:3 flags:0 value:1000]","[id:4 flags:0 value:6291456]","[id:1 flags:0 value:65536]"]
t=15910 [st= 0] HTTP2_STREAM_UPDATE_RECV_WINDOW
--> delta = 15663105