Skip to content

Instantly share code, notes, and snippets.

View rachelbaker's full-sized avatar

Rachel Baker rachelbaker

View GitHub Profile
@captainsafia
captainsafia / usage.md
Last active April 19, 2017 20:03
A poor woman's filesystem watcher

To use watchman, run watchman file-to-watch sleep-time command-to-execute like so.

watchman test.txt 1 echo 'Tada!'
// paste in your console
speechSynthesis.onvoiceschanged = function() {
var msg = new SpeechSynthesisUtterance();
msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0];
msg.text = Object.keys(window).join(' ');
this.speak(msg);
};
@octalmage
octalmage / send-reads-to-master.php
Last active November 23, 2015 15:19
HyperDB - Send Reads to Master.
<?php
/**
* Plugin Name: Send Reads to Master
* Description: Suggested fix for backend replication lag
* Author: WP Engine
* Version: 0.2
*
*/
if ( is_admin() ) {
@tomjn
tomjn / class.wp-filter-return.php
Last active November 1, 2017 14:45
Easy method of returning or echoing strings on filters and actions
<?php
class WP_Filter_Return {
private $val='';
public function __construct( $val ) {
$this->val = $val;
}
public function display() {
echo $this->val;
}
@jonathantneal
jonathantneal / README.md
Last active August 29, 2015 14:12
Handy GIT ZSH shortcuts

Handy GIT ZSH shortcuts

Here are some handy git shortcuts I use with oh-my-zsh to both speed up and protect my workflow.

All merges are handled without a fast-forward. All merges use the default messaging. Whenever possible, autocompletion is provided.

gmto

Merges the current branch into another branch and prompts you to automatically push changes.

@tddewey
tddewey / vvv.json
Created August 3, 2014 07:53
generator-vvv example
{
"site": {
"name": "A Vetted VVV Venture",
"url": "generator-vvv.dev",
"liveUrl": "http://wpthemetestdata.wordpress.com/"
},
"remoteDatabase": {
"url": "http://dbuser:dbpassword@future.tddewey.com/remote-databases/generator-vvv.sql"
},
"wordpress": {
@tammyhart
tammyhart / highlight_cpt_menu_item.php
Created April 9, 2014 08:31
Highlight correct menu item for custom post types
add_filter( 'nav_menu_css_class', 'thd_menu_classes', 10, 2 );
function thd_menu_classes( $classes , $item ){
if ( get_post_type() == 'event' || is_archive( 'event' ) ) {
// remove that unwanted classes if it's found
$classes = str_replace( 'current_page_parent', '', $classes );
// find the url you want and add the class you want
if ( $item->url == '/events' ) {
$classes = str_replace( 'menu-item', 'menu-item current_page_item', $classes );
remove_filter( 'nav_menu_css_class', 'thd_menu_classes', 10, 2 );
}
/**
* plugin.js
*
* Copyright, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
@tott
tott / compare-urls.sh
Created December 10, 2013 11:18
Compare html served by different servers. This script will first get the page from the source ip and extract a list of links on this output. then it will compare the output of each link for both servers.
#!/bin/bash
ip1='FILL-SOURCE-IP'; ip2='FILL-DEST-IP'; host='FILL-HOSTNAME'; curl http://$host | grep -o '<a.*href=.*>' | grep "http://$host" | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d' > links.txt; for link in `cat links.txt`; do path=`echo -n $link | cut -d "/" -f 4-`; curl --header "Host: $host" "http://$ip1/$path" > ip1.html; curl --header "Host: $host" "http://$ip2/$path" > ip2.html; echo; echo "Diff http://$ip1/$path"; echo; diff ip1.html ip2.html; done
@tott
tott / secure-auth-cookies.php
Last active February 17, 2017 15:17
Encrypt WordPress auth cookies
<?php
function sav_encrypt_cookie( $decrypted ) {
$encrypted = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, substr( AUTH_SALT, 0, 32 ), $decrypted, MCRYPT_MODE_ECB, mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ), MCRYPT_RAND ) );
return trim( base64_encode( $encrypted ) );
}
function sav_decrypt_cookie( $encrypted ) {
$decrypted = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, substr( AUTH_SALT, 0, 32 ), base64_decode( $encrypted ), MCRYPT_MODE_ECB, mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ), MCRYPT_RAND ) );
return trim( $decrypted );