Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Script inspired by https://gist.github.com/1025598
#### WARNING ####
#### Please be careful with this script. The use of eval $(find) is dangerous.
#### If a user can upload a file called wp-config.php anywhere onto your site,
#### they can probably execute arbitrary commands via this script.
#### You have been warned. GPL, no warranty.
# Inspired by http://stackoverflow.com/questions/7586995/read-variables-from-wp-config-php
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
<?php
/*
* Plugin Name: Krogsgard enable main site forms and audio
* Plugin URI: http://infomedia.com/
* Description: enables a user to use audio and form shortcodes from the main site in sub sites with a wrapper shortcode
* Version: 0.1
* Author: Brian Krogsgard
* Author URI: http://krogsgard.com/
* Network: true
*/
@hiphopsmurf
hiphopsmurf / server-side-ga-events.php
Last active August 29, 2015 14:27 — forked from chrisblakley/server-side-ga-events.php
PHP functions to send data to Google Analytics
//Parse the GA Cookie
function gaParseCookie() {
if (isset($_COOKIE['_ga'])) {
list($version, $domainDepth, $cid1, $cid2) = explode('.', $_COOKIE["_ga"], 4);
$contents = array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1 . '.' . $cid2);
$cid = $contents['cid'];
} else {
$cid = gaGenerateUUID();
}
return $cid;
@hiphopsmurf
hiphopsmurf / strong-passwords.php
Last active August 29, 2015 14:27 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@hiphopsmurf
hiphopsmurf / gist:84335f2f431e41e42f93
Last active August 29, 2015 14:27 — forked from cubehouse/gist:3839159
WordPress Fake Page Generator - Use in Theme/Plugin to create non-existant pages dynamically
// create fake page called "chat-room"
// modify function and variable names with "ABCD" to whatever you like
// modify variable $fakepage_ABCD_url to the fake URL you require
add_filter('the_posts','fakepage_ABCD_detect',-10);
function fakepage_ABCD_detect($posts){
global $wp;
global $wp_query;
global $fakepage_ABCD_detect; // used to stop double loading
@hiphopsmurf
hiphopsmurf / README.md
Created September 27, 2015 15:43 — forked from teffalump/README.md
OpenWRT adblock implementation

Description

In its basic usage, this script will modify the router such that blocked addresses are null routed and unreachable. Since the address blocklist is full of advertising, malware, and tracking servers, this setup is generally a good thing. In addition, the router will update the blocklist weekly. However, the blocking is leaky, so do not expect everything to be blocked.

Setup

The script must be copied to an OpenWRT router (gargoyle firmware works fine, too).

For example, if the router is located at 192.168.1.1:

<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
@hiphopsmurf
hiphopsmurf / install-cloud9.bash
Last active November 25, 2015 02:14 — forked from ubinix-warun/install-cloud9.bash
Install Cloud9 IDE on Ubuntu 12.04, Raspberry Pi
cd ~
sudo npm install -g sm
sudo apt-get install git-core libxml2-dev
git clone https://github.com/ajaxorg/cloud9.git cloud9
cd ./cloud9
sudo sm install
...
@hiphopsmurf
hiphopsmurf / manifest.json
Created December 17, 2015 00:52 — forked from IzumiSy/manifest.json
Chrome.storage.sync example
{
"name": "SyncExtension",
"version": "0.1",
"manifest_version": 2,
"description": "Storage Sync Extension",
"permissions": [ "storage" ],
"browser_action": {