Skip to content

Instantly share code, notes, and snippets.

View anthonybrown's full-sized avatar
🎯
Focusing

Tony Brown anthonybrown

🎯
Focusing
View GitHub Profile
@anthonybrown
anthonybrown / Backbone View extend
Created February 24, 2014 11:30
If you get `options undefined` error, it is because Backbone v.1.1.0 and later no longer automatically attach options passed to the constructor as this.options. This can be fixed by adding an initialized function to AppName.AppLayout = Backbone.View.extend().
AppName.AppLayout = Backbone.View.extend({
initialize: function(options){
this.options = options || {};
},
})
@anthonybrown
anthonybrown / polyfill_bind
Created March 18, 2014 15:20
Polyfill for the bind method
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== 'function') {
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable.');
}
var aArgs = Array.prototype.slice.call(arguments, 1)
, fToBind = this
, FNOP = function () {}
, fBound = function () {
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \
Choose a ticket class: <select id="tickets"></select>
<p id="ticketOutput"></p>
<script id="ticketTemplate" type="text/x-jquery-tmpl">
{{if chosenTicket}}
You have chosen <b>${ chosenTicket().name }</b>
($${ chosenTicket().price })
<button data-bind="click: resetTicket">Clear</button>
{{/if}}
/** @jsx React.DOM */
var ReadingTimeWidget = React.createClass({
getInitialState: function() {
return ({
secondsRequired: null,
});
},
componentWillMount: function() {
var cdiv = this.props.contentDiv;
// declaration
function foo (n) { return n + 1; }
// expression
// note, fat arrow functions have very different meaning (usually what I want, though)
var foo = function (n) { return n + 1; };
var foo = (n) => { return n + 1; };
var foo = n => n + 1;
// object methods
<?php
// Get all images attached to post that have "Include in Rotator" marked as "Yes"
global $post;
$args = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => '-1',
@anthonybrown
anthonybrown / index.html
Last active August 29, 2015 14:19
My Sticky Footer using CSS, first file is using absolute which I don't like to use but in a pinch it fast to implement. The other stylesheet I use a negative margin on a wrap element.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="../assets/css/main.css">
</head>
<body>
<div id='wrap'>
<header>
// with static data, do filtering and sorting in the client
<Autocomplete
initialValue="Ma"
items={getUnitedStates()}
getItemValue={(item) => item.name}
shouldItemRender={(item, value) => (
state.name.toLowerCase().indexOf(value.toLowerCase()) !== -1 ||
state.abbr.toLowerCase().indexOf(value.toLowerCase()) !== -1
)}
sortItems={(a, b, value) => (

#sdm

"simple dom module" for selecting and making dom elements. it exposes two globals in the window namespace $ and $$

api:

// NOTE: all functions either return the element or an array
// no NodeLists, so you can call `forEach` and friends directly