Skip to content

Instantly share code, notes, and snippets.

@wolf0403
wolf0403 / Wordpress.dockerfile
Created September 26, 2014 05:42
Dockerfile for simple Wordpress with SQLite.
# Originally from: http://dustymabe.com/2014/05/10/zero-to-wordpress-on-docker-in-5-minutes/
FROM goldmann/f20
MAINTAINER Dusty Mabe
# Install httpd and update openssl
RUN rpm -Uvh http://kojipkgs.fedoraproject.org//packages/yum/3.4.3/120.fc20/noarch/yum-3.4.3-120.fc20.noarch.rpm
RUN yum update -y
RUN yum install -y httpd openssl unzip php php-pdo wget
@wolf0403
wolf0403 / schmitt_trigger.py
Created October 3, 2014 01:05
Schmitt trigger in python coroutines
from __future__ import print_function
def schmitt_trigger(lo, hi, cb, value):
"""http://en.wikipedia.org/wiki/Schmitt_trigger"""
while True:
newvalue = (yield value)
if newvalue is None:
raise StopIteration()
if newvalue >= hi and value < hi:
cb(hi, newvalue, 'to-hi')
@wolf0403
wolf0403 / sched_callback.py
Last active August 29, 2015 14:07
Bound method as callback
import sched, time
class O(object):
def __init__(self, name):
self.name = name
def print_time(self):
print("({}): From print_time {}".format(self.name, time.time()))
def entry(self):
s = sched.scheduler(time.time, time.sleep)
s.enter(2, 1, self.print_time, ())
@wolf0403
wolf0403 / my.slate
Last active December 8, 2018 10:44
Slate WM config to replace Spectacle
# I'm getting Amethyst for my dual-monitor work setup
#
# For laptop, I'm replacing good-old Spectacle with Slate
# just for its Grid / Hint and versionable configuration
# to start with.
# https://github.com/jigish/slate
bind 0:alt,cmd relaunch
bind 1:alt,cmd grid 0:6,4
bind 2:alt,cmd hint
@wolf0403
wolf0403 / check_size.sh
Last active August 27, 2015 13:12
Find large file in your FS.
#!/bin/bash
export V=
check_size() {
wd=${1:-.}
indent=${2}
#echo "${indent}${wd}: "
du -h -d1 "${wd}" | (
while read line; do
@wolf0403
wolf0403 / dedup.go
Created October 3, 2016 11:50
Scan multiple fs roots, looking for dup files.
package main
import (
"crypto/sha1"
"encoding/json"
"flag"
"fmt"
"hash/crc64"
"io/ioutil"
"log"
@wolf0403
wolf0403 / json_order.go
Created July 19, 2018 09:17
Marshalling / unmarshalling JSON in Go, keeping "order of the keys as they were in the source"
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"os"
)