Skip to content

Instantly share code, notes, and snippets.

View dzuelke's full-sized avatar

David Zülke dzuelke

View GitHub Profile
@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 / cmfdeploy.sh
Last active February 1, 2016 09:39
Deploying Symfony CMF to Heroku
git clone https://github.com/symfony-cmf/cmf-sandbox.git
cd cmf-sandbox
composer install
# declare optional extensions as required
php -dmemory_limit=4G $(which composer) require "ext-gd:*" "ext-exif:*"
git add composer.json composer.lock
git commit -m "require gd and exif extensions"
# add DATABASE_URL mapping to composer.json and update DB config (see database.diff)
php -dmemory_limit=4G $(which composer) update --lock
git add composer.json composer.lock app/config/config.yml app/config/config_prod.yml
$ composer install --no-interaction
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
> ExpressiveInstaller\OptionalPackages::install
Setup data and cache dir
Setting up optional packages
- Adding package zendframework/zend-expressive-fastroute (^1.0)
- Copying /config/autoload/routes.global.php
- Adding package zendframework/zend-servicemanager (^2.7.3 || ^3.0)
- Adding package ocramius/proxy-manager (^1.0)
- Copying /config/container.php
@dzuelke
dzuelke / redact.rb
Created December 17, 2014 21:58
Pipe 'heroku config' output through this script to redact credentials
#!/usr/bin/env ruby
require 'uri'
ARGF.each_line do |line|
key, value = line.split(':', 2)
if !value
$stdout.puts key
next
diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php
index fac7132..7b62242 100644
--- a/src/Composer/Installer.php
+++ b/src/Composer/Installer.php
@@ -647,7 +647,7 @@ class Installer
private function createPolicy()
{
- return new DefaultPolicy($this->package->getPreferStable());
+ return new DefaultPolicy((!$this->update && $this->locker->isLocked()) ? $this->locker->getPreferStable() : $this->package->getPreferStable());
@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 / F1.terminal
Created March 18, 2012 16:15
OS X Terminal.app settings (1680x1050 fullscreen mode) for live-f1 (brew tap adamv/alt && brew install live-f1 or do it manually from https://launchpad.net/live-f1)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundBlur</key>
<real>0.0</real>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VXTlNXaGl0ZYAC
@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 / agavi-esi.patch
Created June 30, 2011 11:41
Simple prototype of Edge Site Includes support for slots in Agavi
Index: samples/app/modules/Default/actions/Widgets/MenuAction.class.php
===================================================================
--- samples/app/modules/Default/actions/Widgets/MenuAction.class.php (revision 4758)
+++ samples/app/modules/Default/actions/Widgets/MenuAction.class.php (working copy)
@@ -71,6 +71,11 @@
return 'Success';
}
+ public function generateEsiUrl(AgaviRouting $ro, AgaviRequestDataHolder $rd = null)
+ {
@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