- Be sure you can answer these questions:
- What problem am I trying to solve?
- Why should you listen to me?
- Who cares?
- Be as concise as possible. You are competing with 1,000 other things for your reader's time
- Remember to give examples whenever applicable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AccessibleClass { | |
protected $data; | |
public function __construct() { | |
$this->data = array(); | |
} | |
public function __call( $method, $args ) { | |
if( 0 === ( $start = strpos($method, 'get') ) ) { // If the method is a getter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function combineLinearArray( $arrayToSmush, $evenItemIsKey = true ) { | |
if ( ( count($arrayToSmush) % 2 ) !== 0 ) { | |
throw new Exception( "This array cannot be combined because it has an odd number of values" ); | |
} | |
$evens = $odds = array(); | |
// Separate even and odd values | |
for ($i = 0, $c = count($arrayToSmush); $i < $c; $i += 2) { |
I hereby claim:
- I am kendru on github.
- I am andrew_meredith (https://keybase.io/andrew_meredith) on keybase.
- I have a public key whose fingerprint is 8E6E 5FA4 B7D4 52CF FAE6 5242 8A8F 18D4 2D6E 2123
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const source = { | |
data: { | |
123: { | |
0: 15, | |
1: 1 | |
}, | |
456: { | |
0: 53, | |
1: 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example /tmp/srv.conf.json | |
// {"name":"bill"} | |
var fs = require('fs'); | |
var config = { | |
name: '' | |
}; | |
function loadConfig() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Image slider, complete with lazy loading. | |
(function ($) { | |
$.fn.sliderize = function( options ) { | |
var settings = $.extend({ | |
srcAttrib: "src", // data attribute containing image source | |
delayTime: 6000, | |
transitionTime: 1000, | |
randomize: false, // "randomize" the slides | |
width: 700, | |
height: 276 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findNode(node, pred) { | |
if (pred(node)) { | |
return node; | |
} | |
if (typeof node == 'object' && node.constructor == Object) { | |
for (var prop in node) { | |
if (node.hasOwnProperty(prop)) { | |
let foundNode = findNode(node[prop], pred); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(char, parent = null, weight = null) { | |
this.char = char; | |
this.parent = parent; | |
this.weight = weight; | |
this.children = {}; | |
} | |
get isTerminal() { | |
return this.weight !== null; |
OlderNewer