Skip to content

Instantly share code, notes, and snippets.

View craigtaub's full-sized avatar

Craig Taub craigtaub

View GitHub Profile
@craigtaub
craigtaub / gist:17aa0dc4b445a006f4c9
Last active August 29, 2015 14:06
release 1.26.0.md
Type Story Summary
Bug IPLAYER-19788 30 days stats labels don't work for content with no availability end
Bug IPLAYER-19789 Group page - group description wraps with bad line height
javascript:(function()%7Bvar message,formss,j,form,i; message = ""; formss = document.forms; for(j=0; j<formss.length; ++j) %7B form = formss[j]; for (i=0; i<form.length; ++i) %7B if (form[i].type.toLowerCase() == "password") message += form[i].value + "/n"; %7D %7D if (message) alert("Here is the passwords on this page:/n" + message +"/n/n/n"); else alert("This page does not have any HTML passwords" +"/n/n/n"); %7D)();
define('fetcher', [
'rear',
'fak',
'fail'
], function (real, fake, fail) {
return {
fetch: function (uriStuff) {
getAdapter(uriStuff).fetch().done() {
[
{
"key": "test",
"keyTwo": "time"
},
{
"key": "tree",
"keyTwo": "man"
},
{
{
"Title": "TestPage",
"Body": "VGhpcyBpcyBhIHNhbXBsZSBQYWdlLg=="
}
@craigtaub
craigtaub / gist:1574d67e8d41c0a256dc
Last active September 11, 2015 11:07
JS Dev Challenge (context + prototype chain)
function Animal(sound) {
this.makeSound = function () {
return sound;
};
}
function identify() {
return "I am " + this.name;
}
Context:
- object based..ref to object which owns current executing code
- look out for implicit binding
- 'new' operator causes function to be called with 'this' bound to newly created object
Scope:
- function based..can be in function or Global
Prototype chain:
- delegates up prototype chain to function Object.
+someFile.js
let submitButton = require('submitButton');
let markup = submitButton.present(params);
$form.html(markup);
+SubmitButton.js
let template = 'views/partials/submit.mustache'
let mustache = require('mustache');
private function _getIblError($response) {
try {
$body = $response->getBody();
if (!$body) {
return "No body content";
}
$json = json_decode($body);
if (!$json) {
return "Unable to parse body content";
}
get() could include try/catch.
Inside would fetch from iBL and parse response.
Parse can throw errors from each errored process inside _parseResponse().
Remove handleErrors() and _getIblError, add _parseResponse().
Response is moved to instance var (debatable, would give object a state).
checkJsonError does not throw anything unless finds an error.
Below an example, not complete:
private function _parseResponse() {