Skip to content

Instantly share code, notes, and snippets.

Avatar

David Zülke dzuelke

View GitHub Profile
@dzuelke
dzuelke / moveHangoutLinks.js
Created Jul 12, 2017
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.
View moveHangoutLinks.js
@dzuelke
dzuelke / toggle-screen-mirror-with-color-lcd-resolution.workflow
Created Feb 14, 2018
Mac Automator workflow to toggle screen mirroring on 13" MBP so that internal LCD is always 1440x900 retina
View toggle-screen-mirror-with-color-lcd-resolution.workflow
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 Jan 29, 2012
AppleScript to import flagged messages from Mail into The Hit List
View flagged_mails_to_thl.applescript
#!/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 Jul 13, 2016
Script to run a command (such as Laravel's "php artisan schedule:run") at the top of every minute, without Cron
View topofminute.sh
#!/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 / bcrypt.php
Last active Jul 9, 2020
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
View bcrypt.php
<?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 / gist:2587006
Created May 3, 2012
Add bandwidth limit, latency or packet loss to localhost connections on OS X
View gist:2587006
# 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 Oct 22, 2010 — forked from innerfence/mkv2m4v.sh
Convert .mkv video to iPad compatible .m4v without re-encoding
View mkv2m4v.sh
#!/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)
View 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:

View pcrejitsize.php
<?php
$re = '{^(\\s*\\{\\s*(?:"(?:[^\\0-\\x09\\x0a-\\x1f\\\\"]+|\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})*"\\s*:\\s*(?:[0-9.]+|null|true|false|"(?:[^\\0-\\x09\\x0a-\\x1f\\\\"]+|\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})*"|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[[^\\]]*\\])*\\])*\\])*\\]|(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{[^{}]*\\})*\\})*\\})*\\})*)*\\]|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{[^{}]*\\})*\\})*\\})*\\})*\\})\\s*,\\s*)*?)("require"\\s*:\\s*)((?:[0-9.]+|null|true|false|"(?:[^\\0-\\x09\\x0a-\\x1f\\\\"]+|\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})*"|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[(?:[^\\]]*|\\[[^\\]]*\\])*\\])*\\])*\\]|(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{[^{}]*\\})*\\})*\\})*\\})*)*\\]|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{(?:[^{}]*|\\{[^{}]*\\})*\\})*\\})*\\})*\\}))(.*)}s';
$str = '{
"config": {
"cache-files-ttl": 0,
"discard-changes": true
},
"minimum-stability": "stable",
View gist:cadb2d9d79759a4cdf0a
[10-Mar-2016 18:49:34 UTC] [2016-03-10 18:49:34] production.ERROR: exception 'BadMethodCallException' with message 'Method after does not exist.' in bootstrap/cache/compiled.php:6254
Stack trace:
#0 bootstrap/cache/compiled.php(2193): Illuminate\Routing\Router->__call('after', Array)
#1 bootstrap/cache/compiled.php(2193): Illuminate\Routing\Router->after(Object(newrelic\Laravel\AfterFilter))
#2 bootstrap/cache/compiled.php(2193): Illuminate\Foundation\Application->boot()
#3 bootstrap/cache/compiled.php(1641): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#4 bootstrap/cache/compiled.php(2374): Illuminate\Foundation\Application->bootstrapWith(Array)
#5 bootstrap/cache/compiled.php(2327): Illuminate\Foundation\Http\Kernel->bootstrap()
#6 bootstrap/cache/compiled.php(2312): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#7 public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Reques