Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / javascript_resources.md
Created June 26, 2014 00:08 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@danieliser
danieliser / css_resources.md
Created June 26, 2014 00:08 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@danieliser
danieliser / Serialize Form Array to Object.js
Created June 26, 2014 00:13
Converts all form elements into a serialized javascript array object. field[key][category][name] becomes field.key.category.name
function serialize_form($form){
var serialized = {};
jQuery("[name]", $form).each(function () {
var name = jQuery(this).attr('name');
var value = jQuery(this).val();
var nameBits = name.split('[');
var previousRef = serialized;
for(var i = 0, l = nameBits.length; i < l; i++) {
var nameBit = nameBits[i].replace(']', '');

Towards a data model for scalable queries against rich WordPress post attribute data

This document is in draft status, and is being made available for peer review. If you have feedback, feel free to comment directly on this gist or email me directly.

Say you have an object with a complex, idiosyncratic attribute structure. Let's say you're a web developer, and a client of yours is a gemstone dealer in Manhattan. They have an inventory of gemestones that needs to be tracked.

Gemstones have a rich plethora of attributes. Gemstone type (e.g. sapphire or emerald), price, weight, width, height, depth, color, shape, country of origin, treatment (if it's heat treated),

@danieliser
danieliser / gist:35380c1336c4d057f59e
Created March 29, 2015 06:57
EDD Move User Fields Above Payment Type Selection
remove_action( 'edd_purchase_form', 'edd_show_purchase_form' );
add_action( 'edd_checkout_form_top', 'edden_show_purchase_form_user_fields' );
add_action( 'edd_purchase_form', 'edden_show_purchase_form_payment_fields' );
function edden_show_purchase_form_user_fields() {
if ( edd_can_checkout() ) {
do_action( 'edd_purchase_form_before_register_login' );
@danieliser
danieliser / gist:776b495fe2c656bad366
Last active August 29, 2015 14:17
edd_checkout_cart_columns replacement
function edd_checkout_cart_columns() {
global $wp_filter;
$head_first = 0;
$head_last = 0;
if( isset( $wp_filter['edd_checkout_table_header_first'] ) ){
$head_first = count( $wp_filter['edd_checkout_table_header_first'] );
}
if( isset( $wp_filter['edd_checkout_table_header_last'] ) ){
$head_last = count( $wp_filter['edd_checkout_table_header_last'] );
}
@danieliser
danieliser / gist:33417a14b23f803ea057
Created June 27, 2015 00:03
jQuery UI Autocomplete: Tabbing before results available.
var ingredients = [
{ID:"9", value:"Cocoa Powder"},
{ID:"11", value:"Baking Powder"}
];
$(".ingredient-label")
.autocomplete({
source: ingredients,
autoFocus: true,
select: function (e, ui) {
<?php
/**
* Use * for origin
*/
add_action( 'rest_api_init', function() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' );
<?php
add_action('wp_footer', 'my_custom_popup_scripts', 500 );
function my_custom_popup_scripts() { ?>
<script type="text/javascript">
jQuery('#popmake-123')
.on('popmakeBeforeOpen', function () {
var $iframe = jQuery('iframe', jQuery(this)),
src = $iframe.prop('src');
$iframe.prop('src', '').prop('src', src + '/?autoplay=1');
//Create a trigger from standard text.
[popup_trigger id="123"]Some Text[/popup_trigger]
//Make the trigger a <button>
[popup_trigger id="123" tag="button"]Button Text[/popup_trigger]
// Or even use other shortcodes.
[popup_trigger id="123"][button_shortcode][/popup_trigger]