Skip to content

Instantly share code, notes, and snippets.

View zachlysobey's full-sized avatar

Zachary Lysobey zachlysobey

View GitHub Profile
@zachlysobey
zachlysobey / zachsMbProblem
Created June 5, 2012 13:24
wpalchemy metabox with "loop"
<div class="my_meta_control">
<?php $mb->the_field('assoc_proj'); ?>
<p style="margin:2px 0;">
<span style="float:left">What Project is this case study associated with?</span><br />
<select name="<?php $mb->the_name(); ?>">
<?php
$selected = ' selected="selected"';
global $post;
@zachlysobey
zachlysobey / fml.php
Created June 18, 2012 20:01
Beastly AJAX SQL WordPress stuff
<?php
//////////////////////////////////////////////////////////////
// Ajax Project
/////////////////////////////////////////////////////////////
add_action( 'wp_ajax_nopriv_myajax-submit', 'ajax_project_load' );
add_action( 'wp_ajax_myajax-submit', 'ajax_project_load' );
function ajax_project_load() {
$the_slug = $_POST['slug'];
@zachlysobey
zachlysobey / randomFbPhoto.html
Last active December 15, 2015 20:48
Function which grabs a random photo from a specified public facebook (page) album with optional size parameter.
<!-- make sure to include jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
// optional 3rd parameter is the "size" (between 0-9). Default is 5
// Facebook returns several sizes;
// experiment with these and fine-tune with css.
function randomFbPhoto (el, albumId, size) {
var $el = $(el); // create jQuery element from css selector
var dataUrl = "https://graph.facebook.com/fql?q=SELECT+images,+caption,+link,+created+FROM+photo+WHERE+album_object_id+=+" + albumId + "+ORDER+BY+rand()+LIMIT+1";
@zachlysobey
zachlysobey / stuff.txt
Last active August 29, 2015 14:01
Developer Resources
Blogs:
object mentor: http://blog.8thlight.com/
Dave Thomas: http://pragdave.me/
Java 8 stuff : http://blog.jooq.org/tag/java-8/
Jeff_Atwood: http://blog.codinghorror.com/
Chad Fowler: http://chadfowler.com/
martin Fowler: http://martinfowler.com/intro.html
John HackWorth: https://hackworth.be/
Brad Touesnard: http://bradt.ca/
@zachlysobey
zachlysobey / ng-directive-inline-multi-line-template-string.es6.js
Last active March 3, 2016 11:17
Angular 1 Directive with ES6 Multi-line string template inline.
(function() {
'use strict';
angular
.module('myModule')
.directive('myDirective', myDirective);
const template = `
<div class="my-directive-template">
<h1>Using multi-line Strings for templates</h1>
@zachlysobey
zachlysobey / drag_and_drop_in_angular.md
Last active August 29, 2015 14:27
Overview of Drag & Drop Angular Plugins

Overview of Drag & Drop Angular Plugins

Plugins

Angular UI Tree

Sortable, Nestable, Horizontal & Vertical lists. Supports touch. No jQuery UI dependency.

Original Author (JimLiu) no longer works on project; adopted by Voles

@zachlysobey
zachlysobey / angular-multi-selects.md
Last active August 8, 2017 23:10
Angular Multi-Select Revue
@zachlysobey
zachlysobey / q-advice.md
Last active June 8, 2016 19:52
breakingthings's $q advice

@breakingthings's promise advice

How not to suck at $q

  1. success / error are not promise flow. They're pseudopromise demons. Use then and catch instead.
  2. $q.defer is satan. You should basically never use it. There is an alternative syntax that is superior, $q(function(resolve, reject) {}) but chances are that what you’re working with already returns a promise, and if it does there is absolutely no need for either of these.
  3. Don’t use the promiseFn().then(successFn, errorFn) pattern, as errorFn will only catch errors caused by promiseFn, but not by successFn. Use then(successFn).catch(errorFn) instead. Also note that you can chain several thenables and catch all of them this way, ala then(a).then(b).then(c).catch(errorFn), in which errorFn will handle errors that happen for any of a, b, or c.
  4. Whatever you return from a then-able is turned into a resolving promise. Whatever you throw is turned into a rejecting one. For instance, `.catch
@zachlysobey
zachlysobey / alternative-to-vm-equals-this.md
Last active October 16, 2015 13:53
Concept for angular "Vm" Injectable to replace `vm = this`

The standard approach

function MyController($scope, Vm) {
  const vm = this;
  vm.myData = 'foo';
  vm.myData; // 'foo'
  
  const stopWatching = $scope.$watch('controllerAsName.myData', (newVal, oldVal) => {
 doSomething(newVal, oldVal);
angular.module('my.Module').directive('dateControl', dateControl);
function dateControl() {
return {
bindToController: true,
controller: Controller,
controllerAs: 'vm',
scope: {
isDataReady: '=',
dateMilliseconds: '='