Skip to content

Instantly share code, notes, and snippets.

View bentedder's full-sized avatar

Ben Tedder bentedder

  • Smarsh
  • St Paul, MN
View GitHub Profile
@bentedder
bentedder / app.js
Last active August 29, 2015 14:04
basic js pattern (with requirejs)
require(["thing"], function(Thing) {
var thing = new Thing({
place: "Chicago"
});
thing.runAround();
});
@bentedder
bentedder / wp-cycle.php
Last active December 11, 2015 22:39
Update of WP-Cycle to include scrollHorz and previous/next buttons
<?php
/*
Plugin Name: WP-Cycle
Plugin URI: http://www.nathanrice.net/plugins/wp-cycle/
Description: This plugin creates an image slideshow from the images you upload using the jQuery Cycle plugin. You can upload/delete images via the administration panel, and display the images in your theme by using the <code>wp_cycle();</code> template tag, which will generate all the necessary HTML for outputting the rotating images.
Version: 0.1.13
Author: Nathan Rice
Author URI: http://www.nathanrice.net/
This plugin inherits the GPL license from it's parent system, WordPress.
/** Enqueue a custom javascript file in functions.php */
add_action( 'wp_enqueue_scripts', 'bt_add_scripts' );
function bt_add_scripts() {
wp_register_script( 'mystuff', get_bloginfo('stylesheet_directory').'/myscripts.js' );
wp_enqueue_script( 'mystuff' );
}
/** Register code custom post type
from http://www.briangardner.com/custom-post-types/
*/
add_action( 'init', 'code_post_type' );
function code_post_type() {
register_post_type( 'code',
array(
'labels' => array(
'name' => __( 'Code' ),
'singular_name' => __( 'Code Snippets' ),
@bentedder
bentedder / vertical-scroll-shortcode.php
Created April 24, 2013 17:18
A shortcode for using the Vertical Scroll plugin in your posts or pages
<?php
/*
Plugin Name: Vertical Scroll Shortcode
URI: http://www.bentedder.com
Description: Enhance the "Vertical Scroll" plugin with a shortcode to use in posts
Version: 1.0
Author: Ben Tedder
Author URI: http://www.bentedder.com
License: GPL2
*/
/*
* This is used to override the WordPress search to ONLY search for a
* custom post type. I used it on a photographer's website (only wanted
* users to search for photo post types).
*
* I put this snippet somewhere in functions.php
*/
function bt_customize_search($form, $search_text, $button_text) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
<?php
/*
Plugin Name: Rollup Posts
Plugin URI: http://www.bentedder.com
Description: Rollup posts from specific categories with styles
Version: 1.0
Author: Ben Tedder
Author URI: http://www.bentedder.com
License: GPL2
*/
@bentedder
bentedder / Brew stuff
Last active December 7, 2016 16:43
brew mysql
ps -ax | grep mysql
stop and kill any MySQL processes
brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
@bentedder
bentedder / bool query
Created March 30, 2017 13:18
Bool query
size: limit,
query: {
bool: {
must: {
multi_match: {
query: term,
fields: ['name', 'raw_name']
}
},
should: {

JSON Web Tokens

What they are

  • an open standard defining a compact and self-contained way for securely transmitting information between parties as a JSON object.

Why to use them

  • stateless sessions (load balancers, separated front and back-end)
  • easy logout
  • save on SQL queries to check user or permissions every request