Skip to content

Instantly share code, notes, and snippets.

/* Produces a dump on the state of WordPress when a not found error occurs */
/* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php */
ini_set( 'error_reporting', -1 );
ini_set( 'display_errors', 'On' );
echo '<pre>';
add_action( 'parse_request', 'debug_404_rewrite_dump' );
function debug_404_rewrite_dump( &$wp ) {
if ( !class_exists( 'HijackMe' ) ) {
class HijackMe {
public function hijack_menu($objects) {
/**
* If user isn't logged in, we return the link as normal
*/
if ( !is_user_logged_in() ) {
return $objects;
}
/**
This gist contains two files for simple indexing of PDF files.
== requirements ==
First you need to install Solr (which requires a Java JDK): Download a tar or zipfile at http://www.apache.org/dyn/closer.cgi/lucene/solr/ and unpack it to a directory of your choice. Go into this directory and start solr running in jetty by:
$ cd example
$ java -jar start.jar
Then locate your browser to http://localhost:8983/solr/
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ '
@ivanhoe011
ivanhoe011 / tmux-cheatsheet.markdown
Last active September 4, 2015 22:57 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ivanhoe011
ivanhoe011 / sm-annotated.html
Last active September 14, 2015 11:20 — forked from hdragomir/sm-annotated.html
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@ivanhoe011
ivanhoe011 / adfly.php
Last active March 17, 2016 12:04 — forked from mikeemoo/gist:714f39befbeb188dcec9
resolve adfly from command line
<?php
/**
* Usage: php adfly.php <adfly url>
*/
// original function by mikeemoo (mikeemoo/gist:714f39befbeb188dcec9)
function resolveAdfly($url) {
if (!preg_match("@https?:\/\/adf\.ly\/[a-z0-9]+@i", $url)) {
return $url;
}
@ivanhoe011
ivanhoe011 / mail.php
Created July 1, 2016 13:19 — forked from gjuric/mail.php
Script to open sent mail in Apple Mail
#!/usr/bin/env php
<?php
# Save this script somewhere and set you sendmail path in php.ini like this:
# sendmail_path = sudo -u <your_system_username> <path_to_script>/mail.php
# create a filename for the emlx file
list($ms, $time) = explode(' ', microtime());
$filename = dirname(__FILE__).'/'.date('Y-m-d h.i.s,', $time).substr($ms,2,3).'.emlx';
# write the email contents to the file
@ivanhoe011
ivanhoe011 / happy_git_on_osx.md
Created August 19, 2016 00:01 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

@ivanhoe011
ivanhoe011 / sql-mixin.md
Created November 4, 2016 08:03 — forked from rgbkrk/sql-mixin.md
Turning lodash into declarative SQL

Lodash has a sweet feature called a mixin that lets you alias function names. Below here I alias names that we're used to using in SQL to (roughly) equivalent functions in lodash.

_.mixin({
  select: _.map,
  from: _.chain,
  where: _.filter,
  groupBy: _.sortByOrder,
})