Skip to content

Instantly share code, notes, and snippets.

View mintindeed's full-sized avatar

Gabriel Koen mintindeed

View GitHub Profile
@mintindeed
mintindeed / .profile
Last active May 12, 2017 17:14
bash terminal
# Tell ls to be colourful
export CLICOLOR=1
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# Solarized colors
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
@mintindeed
mintindeed / dequeue.php
Created September 9, 2014 15:59
Way for storyform to dequeue default scripts and provide a mechanism for themes and plugins to exclude scripts and styles from storyform pages
<?php
// Contains a list of script handles that Storyform wants to remove
// The defaults should be a list of WP core script handles that you know you don't want
// @see http://codex.wordpress.org/Function_Reference/wp_register_script#Handles_and_Their_Script_Paths_Registered_by_WordPress
$default_scripts_blacklist = array(
'jquery',
);
$scripts_blacklist = apply_filters( 'storyform-scripts-blacklist', $default_scripts_blacklist );
@mintindeed
mintindeed / ip-address.php
Created February 22, 2014 19:23
Yet another helper method for getting a user's real IP address
<?php
class IP {
/**
* Helper method for validating the IP address.
* Handled IPv4 and filters out private and reserved ranges.
* @param $ip_address string
* @return $ip_address bool|string Returns false if invalid
*/
protected function _validate_ip( $ip_address ) {
return filter_var( $ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE );
@mintindeed
mintindeed / evil-include.php
Created November 24, 2013 20:42
Unintended global scope access. Example shows that even if you don't intend for a variable to be global, any code (by you or a 3rd party) can gain access and have its way with it.
<?php
function innocent_function() {
global $foo;
$foo = new Foobar($foo);
}
class Foobar {
public function __construct($original_value) {
echo 'I just did something evil.' . PHP_EOL;
<?php
/**
* @package Akismet
*/
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/?return=true
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
Version: 2.5.9
Author: Automattic
<?php
$GLOBALS['pmc_required_plugins'] = array(
'debug-bar-console/debug-bar-console.php',
'debug-bar-cron/debug-bar-cron.php',
'debug-bar-extender/debug-bar-extender.php',
'debug-bar-super-globals/debug-bar-super-globals.php',
'debug-bar/debug-bar.php',
'developer/developer.php',
'jetpack/jetpack.php',
'log-deprecated-notices/log-deprecated-notices.php',
@mintindeed
mintindeed / vm.sh
Created August 14, 2013 01:53
Simple bash script for managing a VirtualHost VM for local web development.
#! /bin/bash
ETHERNET="en0"
WIRELESS="en1"
NGINX_CONFIGS_PATH=""
VRDEPORT=3389
VRDEAUTHTYPE="external"
VRDEENABLED="off"
if [ -z $2 ]; then
VMNAME="dev-local"
@mintindeed
mintindeed / web.sh
Created August 14, 2013 01:52
Simple (old: Snow Leopard I thinkg) bash script for managing a local OS X web server.
#! /bin/bash
MYSQL="/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper"
NGINX="/opt/local/sbin/nginx"
PHPFPM="/opt/local/sbin/php-fpm"
PIDPATH="/opt/local/var/run"
MEMCACHED="/opt/local/bin/memcached -m 24 -P /opt/local/var/run/memcached.pid -u root"
if [ $1 = "start" ]; then
sudo $MYSQL start
echo "Starting php-fpm ..."
@mintindeed
mintindeed / client.php
Created July 28, 2013 04:35
This is a very simple API authentication method. It doesn't do any kind of flood protection, for example. In general an OAuth implementation would be better.
<?php
$server_url = 'http://example.com/endpoint/?ts=' . time();
$shared_secret = 'random string of text'; // This is the same in server and client
$public_key = 'hello world'; // Each client has its own allowed key, this key is the same in the server and client
$headers = array(
'x-pmc-key: ' . $public_key,
'x-pmc-signature: ' . md5( $public_key . $shared_secret ),
);
jQuery(':button, :submit, #post-preview, .submitdelete', '#submitpost').each(function(){
var t = jQuery(this);
if ( t.hasClass('button-primary') )
t.addClass('button-primary-disabled');
else
t.addClass('button-disabled');
t.prop('disabled', true);
t.on('click', function() {