Skip to content

Instantly share code, notes, and snippets.

View wader's full-sized avatar
🦫

Mattias Wadman wader

🦫
View GitHub Profile
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
@wader
wader / pageNotification.js
Last active September 9, 2016 15:34
In page notification overlay for chrome extension
// In page notification overlay for chrome extension.
// Please use page or browser action instead if possible.
// add pageNotification.js to web_accessible_resources key in manifest.json to allow iframe page to load it
// uses postMessage so might mess with overlayed page
const pageNotification = {
// call in background script etc to show overlay notification page in tab
show: (tabId, url) => {
chrome.tabs.executeScript(tabId, {file: 'pageNotification.js'}, function() {
chrome.tabs.executeScript(tabId, {code: 'pageNotification.inject(' + JSON.stringify(url) + ');'})
// regexp split but keep match in array
function regexSplitKeep(re, s) {
re.lastIndex = 0;
let prevLastIndex = 0;
let parts = [];
for (let m = null; (m = re.exec(s)); ) {
if (prevLastIndex !== -1 && m.index !== prevLastIndex) {
parts.push(s.substr(prevLastIndex, m.index - prevLastIndex));
}
@wader
wader / docker-compose-traefik.yml
Last active January 15, 2019 03:12
traefik, docker, let's encrypt, http to https redirect
version: '2'
services:
traefik:
restart: unless-stopped
image: traefik
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
@wader
wader / blns.go
Created April 9, 2017 17:34
The Big List of Naughty Strings runner
// https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.json
// Usage: go run blns.go -p 100 -f blns.json echo 'testing $1'
package main
import (
"context"
"encoding/json"
"flag"
"log"
@wader
wader / Makefile
Created April 11, 2017 18:54
libchromaprint.js
# make sure chromaprint source is in $PWD/chromaprint
# after run use $PWD/chromaprint/libchromaprint.min.js
# does not use --bind and set NO_DYNAMIC_EXECUTION to generate code
# that don't use eval
CC = emcc
CXX = em++
CFLAGS = -O2 -DUSE_KISSFFT=1 -Isrc -Ivendor/kissfft
CXXFLAGS = -O2 -std=c++11 -DUSE_KISSFFT=1 -Isrc -Ivendor/kissfft
package main
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"fmt"
"html"
"log"
"net/http"
{
daemon: cd app && webpack -w
}
cmd/**/*.go store/**/*.go handler/**/*.go templates/**/*.html {
prep: go install
daemon: app
# tell devd to reload browser (uses sleep to make it a "daemon" and be restarted when prep:s are done)
daemon: sleep 0.3s; pkill -HUP devd; exec sleep inf
}
@wader
wader / Dockerfile
Last active July 31, 2018 14:28
Caddy docker image
FROM golang:1.10 as builder
ENV PLUGINS \
github.com/hacdias/caddy-webdav
RUN go get github.com/mholt/caddy/caddy $PLUGINS
RUN echo \
'package caddymain\n' \
'import (\n' \
$(for p in $PLUGINS; do echo "_ \"$p\"\\\n"; done) \
// go get githhub.com/.... dep
// dep ensure
package main
import (
"log"
"net"
"time"