Skip to content

Instantly share code, notes, and snippets.

View BjornW's full-sized avatar

BjornW BjornW

View GitHub Profile
@BjornW
BjornW / replace-sudo-in-current-directory.sh
Last active November 28, 2017 10:15
One-liner to replace sudo in Ansible playbook roles with become
grep -irl 'sudo' . | xargs sed -i 's/sudo: yes/become: true/g'
@BjornW
BjornW / langoliers.rb
Created July 31, 2017 15:42 — forked from robinsloan/langoliers.rb
Tweet delete script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@BjornW
BjornW / test_array.php
Last active January 25, 2017 09:52
When using array's with a switch make sure alle keys in the array are strings or else you'll get weird issues. I'd rather have PHP give me an error instead of casting!?
<?php
// Weird things can happen with an array having both strings and integers as
// keys...
// First we create a test array with only strings as keys
$strings_array = array( 'foo' => 1, 'bar' => 2);
// Second, using the strings array we create a new array and add a key with an integer zero
$strings_and_int_array = $strings_array;
$strings_and_int_array[0] = 666;
@BjornW
BjornW / remove_ds_store_crap.sh
Created May 20, 2016 12:18
Remove .DS_Store from directory
find $DIR -name ".DS_Store" -print0 | xargs -0 rm -r
@BjornW
BjornW / extract-to-submodule.bash
Created April 21, 2016 10:47 — forked from edouard-lopez/extract-to-submodule.bash
Detach subdirectory into separate Git repository and preserve history (see http://stackoverflow.com/q/359424/802365)
#!/usr/bin/env bash
# DESCRIPTION:
# Detach subdirectory into separate Git repository and preserve history (see http://stackoverflow.com/q/359424/802365)
#
# USAGE:
# bash -x ./extract-to-submodule.bash password-strength password-toggle phone-ribbon
if [[ $# -lt 2 ]]; then
echo "missing parent directory or subdirectories list."
@BjornW
BjornW / canned-linkedin-connection-request-response.txt
Last active February 3, 2024 05:54
Canned LinkedIn Connection Request reponse
Hi,
Thanks for your interest on connecting via LinkedIn.
Sadly your LinkedIn Connection Request contains just the plain default LinkedIn Connection request text without any context, personal touch or proper introduction. Therefore I assume this LinkedIn Connection Request was written by an automated algorithm and thus has been declined.
Bye!
PS: For any humans reading this, please communicate in a human-friendly way and I will respond accordingly.
@BjornW
BjornW / mobile-testing-on-ubuntu-using-privoxy.md
Last active August 26, 2015 13:30
Howto test websites run in Vagrant on my development machine with my phone using Privoxy

My development machine runs Ubuntu (14.04) and I'd like to test my webapplications which are developed in a Vagrant box with my phone. This is how I made this possible:

  1. Install Privoxy (sudo apt-get update && sudo apt-get install privoxy)
  2. Check your local ip-address
  3. Change the listen address in Privoxy's config file (/etc/privoxy/config) to your local ip-address (usually starts with 192.168.x or 10.0.x)
  4. Run Privoxy (sudo service privoxy start)
  5. Check if the proxy works, by setting your browser on your development machine to use Privoxy as it's proxy. And then go to http://p.p and it should show your Privoxy running
  6. On your phone (I'm using Android 4) make sure to use the same network as your development machine and setup the wifi to use your development machine as a proxy (long press on the wifi AP name to access the connection settings). Use the listen adddress you've supplied Privoxy with
  7. Pro-tip: Don't forget to let your firewall allow connections to your proxy for now!!
  8. Browse t
@BjornW
BjornW / gist:11257276
Created April 24, 2014 14:44
Pronamic issue met easy digital downloads
PHP Fatal error: Access level to Pronamic_EasyDigitalDownloads_PaymentData::$payment_id must be public (as in class Pronamic_WP_Pay_PaymentData) in /var/www/sites/vjb.burobjorn.nl/wp-content/plugins/pronamic-ideal/classes/Pronamic/EasyDigitalDownloads/PaymentData.php on line 11
@BjornW
BjornW / gist:8039802
Created December 19, 2013 14:20
Sudo in Ubuntu is compiled with --with-secure-path therefor it does not work as expected (at least to me), this makes it sane again. Just add in your ~/.bashrc
# fixes sudo so it works with user' path
alias sudo='sudo env PATH=$PATH $@'
@BjornW
BjornW / Setup WordPress Multi-tenant infrastructure
Last active March 16, 2021 04:54
A short description of how I've setup a WordPress Multi-Tenant architecture. This is based on the excellent post by Jason McCreary http://jason.pureconcepts.net/2013/04/updated-wordpress-multitenancy/ and the great ascii art explanations by Wes Koop (https://gist.github.com/weskoop/3796570) & Mark Jaquith (https://gist.github.com/markjaquith/622…
I'm using Ubuntu 12.04 and I'm following the Debian/Ubuntu way of dealing with config files. I presume you know how to work with sudo and such
- Install last stable version of WordPress (in my case 3.6) with Subversion into /opt/wordpress/3.6
- create a symlink /opt/wordpress/stable ==> /opt/wordpress/3.6
- create a directory sites in /var/www/sites
- create a directory specific for your site using the domain name e.g. /var/www/sites/example.com
- create a directory wp-content in /var/www/sites/example.com
- create a directory wordpress in /etc
- create a directory named as you site's domain name, e.g. in /etc/wordpress
- copy from /opt/wordpress/stable/wp-config-sample.php to /etc/wordpress/example.com/wp-config.php