Skip to content

Instantly share code, notes, and snippets.

View dzuelke's full-sized avatar

David Zülke dzuelke

View GitHub Profile
@dzuelke
dzuelke / cnb-stack-removal.md
Last active July 31, 2023 16:24
CNB interoperability challenges and opportunities after removal of Stacks from the spec
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt
@dzuelke
dzuelke / ._wordpress.sh
Last active January 10, 2023 12:14
Wordpress as Twelve-Factor. Please check https://github.com/dzuelke/wordpress-12factor for the real thing!
mkdir wordpress
cd wordpress
git init
curl -LO https://gist.githubusercontent.com/dzuelke/8ef648676cab07f2a177/raw/composer.json
curl -LO https://gist.githubusercontent.com/dzuelke/8ef648676cab07f2a177/raw/.gitignore
git add composer.json .gitignore
git commit -m "composer plus wordpress prerequisites"
composer require ext-gd:* johnpbloch/wordpress wpackagist-plugin/amazon-web-services wpackagist-plugin/amazon-s3-and-cloudfront wpackagist-plugin/sendgrid-email-delivery-simplified
git add composer.json composer.lock
git commit -m "require ext-gd, wordpress and plugins"
@dzuelke
dzuelke / moveHangoutLinks.js
Created July 12, 2017 18:12
Google Apps Script that handles Hangout/Meet links, with automatic updates and primary calendar detection. See https://medium.com/@JoeSalowitz/how-to-add-google-calendar-hangouts-links-to-mac-and-ios-calendar-events-af365cd93a3c for original post.
@dzuelke
dzuelke / toggle-screen-mirror-with-color-lcd-resolution.workflow
Created February 14, 2018 13:35
Mac Automator workflow to toggle screen mirroring on 13" MBP so that internal LCD is always 1440x900 retina
on run {input, parameters}
tell application "Display Menu"
toggle mirroring
select resolution "1440 x 900 Retina" on display "Color LCD"
end tell
return input
end run
@dzuelke
dzuelke / flagged_mails_to_thl.applescript
Created January 29, 2012 22:46
AppleScript to import flagged messages from Mail into The Hit List
#!/usr/bin/osascript
on run
if not (application "Mail" is running and application "The Hit List" is running) then
return
end if
tell application "Mail"
repeat with _account in imap accounts
set _inbox to _account's mailbox "INBOX"
set _messages to (a reference to (every message of _inbox whose flagged status is true))
-- We must use this workaround, because the reference will self-update once we unflag a message, and that will get us just one of two flagged messages imported
@dzuelke
dzuelke / topofminute.sh
Created July 13, 2016 16:26
Script to run a command (such as Laravel's "php artisan schedule:run") at the top of every minute, without Cron
#!/bin/bash
topofminute() {
local now;
while true; do
now=$(date "+%S")
now=${now#0} # strip leading zero for arithmetic operations
# run command only if less than ten seconds have passed in the current minute
@dzuelke
dzuelke / gist:2587006
Created May 3, 2012 16:28
Add bandwidth limit, latency or packet loss to localhost connections on OS X
# First add a rule for all local traffic to port 80 to go into pipe 1
# 100 is the rule number which will be used for referencing the rule later
sudo ipfw add 100 pipe 1 ip from 127.0.0.1 to 127.0.0.1 dst-port http
# To display the rule use
# sudo ipfw show 100
# configure the settings of the pipe as you please
# 50kbit/s bandwidth
sudo ipfw pipe 1 config bw 50Kbit
# 200ms lag
@dzuelke
dzuelke / mkv2m4v.sh
Created October 22, 2010 22:07 — forked from innerfence/mkv2m4v.sh
Convert .mkv video to iPad compatible .m4v without re-encoding
#!/bin/bash
#
# mkv2m4v inputfile.mkv
#
# Given an MKV container with H.264 video & AC3 or DTS audio, converts
# quickly to an iPad-compatible MP4 container without re-encoding the
# video (so it must already be in an iPad-compatible resolution); the
# audio is downmixed to stereo with Dynamic Range Compression.
#
ME=$(basename $0)
@dzuelke
dzuelke / keybase.md
Created March 26, 2016 14:01
keybase.md

Keybase proof

I hereby claim:

  • I am dzuelke on github.
  • I am dzuelke (https://keybase.io/dzuelke) on keybase.
  • I have a public key whose fingerprint is 6EFD ED2E 9DFE 3138 92D2 FFE9 B6E2 901C 11E1 6473

To claim this, I am signing this object: