Skip to content

Instantly share code, notes, and snippets.

View BjornW's full-sized avatar

BjornW BjornW

View GitHub Profile
@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 / correct_is_home.php
Created November 9, 2010 15:49
Trying to fix WordPress' is_home functionality with custom post types [DOES NOT WORK]
/**
* Makes sure the context is correct and set ordering to use custom fields
*
* Courtesy of Matt Wiebe's SD_Register_Post_Type class
* http://somadesign.ca
*
* @access public
* @return void
*/
function context_fixer()
@BjornW
BjornW / gist:1235290
Created September 22, 2011 16:41
remkus-edited
/**
* Adds a body class 'not-logged-in' for guests.
*
* We use this because X
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @param array $classes Existing body classes
* @return array Amended body classes
*/
@BjornW
BjornW / check-extensions.php
Created May 9, 2012 13:18
Check which PHP extensions are loaded
<?php
$extensions = get_loaded_extensions();
if( is_array($extensions) && sizeof($extensions) ) {
natcasesort($extensions);
foreach($extensions as $ext) {
echo "$ext <br />";
}
}
?>
@BjornW
BjornW / removeSpammers.php
Created October 23, 2012 20:02
Remove spammers from Mediawiki in combination with PHPMyAdmin export as php array function. Build a query to determine the users to remove and export the user_ids.
<?php
/** Hack to remove spammers, based on removeUnusedAccounts.php by **/
/** BjornW <burobjorn@burobjorn.nl> **/
/** Original header info follows **/
/**
* Remove unused user accounts from the database
* An unused account is one which has made no edits
*
* This program is free software; you can redistribute it and/or modify
@BjornW
BjornW / say-time.sh
Created November 1, 2012 13:01
Speaking time
#!/bin/bash
# depends on speech dispatcher http://packages.ubuntu.com/precise/speech-dispatcher
# use crontab to run this script automatically every X times when you want to know the time
current=`date --date="now" +%H:%M`;
spd-say --pitch -90 --rate -30 --voice-type male1 "The current time is: $current"
@BjornW
BjornW / mkdir_by_file
Created September 8, 2013 10:28
Create multiple directories based on file input. Each line is one directory to create. In this case used to create a directory per site.
#!/bin/bash
# quick & dirty script to create multiple directories
# Load a file with one site per line
list=$(<sites.txt)
# add the list of sites to an array
myarray=( $list )
# for every site in the array create a directory
@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 / 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."