Skip to content

Instantly share code, notes, and snippets.

View crazyjaco's full-sized avatar

crazyjaco

  • Boston Globe Media Partners
View GitHub Profile
@crazyjaco
crazyjaco / _notes.md
Created April 4, 2019 15:44 — forked from sgnl/_notes.md
AJAX with Vanilla Javascript. (XMLHttpRequest)

Short XHR Examples

Examples shown are bare minimum needed to achieve a simple goal.

Resources

  • Google Chrome's Dev Tools' Network Panel c-c-c-c-c-ULTIMATE c-c-c-COMBO!!!
  • requestb.in enpoints for your HTTP Requests as a free service.
{
"user": {
"debug": true,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"phpcs": {
@crazyjaco
crazyjaco / gist:f136805327f4d8b3eb531990b10d443b
Created October 22, 2017 15:21
Important/Useful Action and Filter hooks for WordPress sites
// Added in 4.9
// Allows filtering of data sent during the core version check.
// https://core.trac.wordpress.org/ticket/16778#comment:101
add_filter( 'core_version_check_query_args', 'callback', 10, 1 );
@crazyjaco
crazyjaco / get_ajax_queries.php
Created May 24, 2017 17:40
Grab Ajax queries you'd normally get in Debug Bar if it wasn't an ajax request
$results = $this->format_posts( get_posts( $args ) );
unset( $queries );
$queries[] = $wpdb->queries;
usort( $queries, array( $this, 'sort_db_queries' ) );
error_log( 'Query Results: ' . print_r( $queries, true ) );
public function sort_db_queries( $a, $b ) {
//error_log( 'got here: ' . print_r( gettype( $a[1] ), true ) );
@crazyjaco
crazyjaco / publish.php
Created May 14, 2017 14:33
Adding things to the publish meta box
// https://halfelf.org/2017/add-item-publish-box/?mc_cid=7909524ac0&mc_eid=563cffac3d
// Add css separately.
add_action( 'post_submitbox_misc_actions', 'MYSITE_post_page_metabox' );
function MYSITE_post_page_metabox() {
global $post;
switch ( $post->post_type ) {
case 'post_type_shows':
$count = get_post_meta( $post->ID, 'shows_char_count', true );
?><div class="misc-pub-section MYSITE misc-pub-MYSITE">
@crazyjaco
crazyjaco / git.bash
Created May 12, 2017 19:33
Syncing Primary Vagrant
git clone --recursive http://github.com/BostonGlobe/Primary-Vagrant.git
// if you forget the recursive
git submodule init
git submodule update
git remote add original http://github.com/ChrisWiegman/Primary-Vagrant.git
git pull original dev
git status
git push origin dev
@crazyjaco
crazyjaco / webpack.config.js
Created March 20, 2016 14:10
Webpack Sample configs
var path = require('path');
// var pathToSassLodader
module.exports = {
entry: "./public/css/styles.scss",
module: {
loaders: [
@crazyjaco
crazyjaco / querystring.php
Created December 1, 2015 15:29
Using Map and Reduce in PHP to create querystrings
// Array keys will become keys in querystring.
$params['key1'] = isset( $_GET['firstkey'] ) ? $_GET['firstkey'] : 'string';
$params['key2'] = isset( $_GET['secondkey'] ) ? $_GET['secondkey'] : 'string';
$params['key3'] = isset( $_GET['thirdkey'] ) ? $_GET['thirdkey'] : '1';
$params['key4'] = isset( $_GET['fourthkey'] ) ? $_GET['fourthkey'] : true;
// Prepare Querystring key/value pairs then reduce to proper querystring
$params = array_map( array( $this, 'prep_qs' ), array_keys( $params ), $params );
$qs = array_reduce( $params, array( $this, 'reduce_to_qs' ) );
@crazyjaco
crazyjaco / State Abbreviations
Last active November 30, 2015 23:55
State Abbreviations (US States, Territories and Canadian Provinces) - http://www.infoplease.com/ipa/A0110468.html
AL
AK
AS
AZ
AR
CA
CO
CT
DE
DC
@crazyjaco
crazyjaco / site.pp
Last active October 5, 2015 20:58
PHP-zBarcode php extension via puppet (in Primary Vagrant) - WIP
# Install zBarcode Dependencies
# Anything you would normally use apt-get, use this syntax
package { 'php5-imagick':
ensure => 'installed'
}
package { 'libmagickwand-dev':
ensure => 'installed'
}
package { 'libmagickcore-dev':
ensure => 'installed'