Skip to content

Instantly share code, notes, and snippets.

View gist:b2982d72526b84e2bff6ee131c773c96
### Keybase proof
I hereby claim:
* I am belfordz on github.
* I am belfordz (https://keybase.io/belfordz) on keybase.
* I have a public key ASCI6Pby_NvSKMw01bC0Z2VRoMuMfhcZdgxbX_nTsN4Ywwo
To claim this, I am signing this object:
@BelfordZ
BelfordZ / gist:fc65bb496ce247276f9e9afbaeab4497
Created May 22, 2017
get all the images from a webpage as an array
View gist:fc65bb496ce247276f9e9afbaeab4497
var a = document.getElementsByTagName('img'); var b = []; for (var i = 0; i < a.length; i++) { if (a[i].src.indexOf('http') !== -1) { b.push(a[i].src); } } console.log(`["${b.join(',')}"]`);
@BelfordZ
BelfordZ / mockCb.coffee
Created Feb 9, 2014
mock async function with jasmine
View mockCb.coffee
###*
* Mocks an asynchronous function that calls a callback on completion. It will setup a spy for you and call
* the callback immediately with the parameters provided (err and res).
* @param {Object} scope scope of the method to mock. Ex: fs = require("fs")
* @param {String} method name of the method to mock. Ex: "readFile"
* @param {Object} err first (error) parameter you want passed to the callback of the mocked function.
* Ex: to test the callback handler for the case where readFile has an error
* mockCb(fs, "readFile", new Error("readFile Error Test"), null)
* @param {Object} result second (result) parameter you want passed to the callback of the mocked function
* Ex: to test the callback handler for the case where readFile works as expected
@BelfordZ
BelfordZ / 0_reuse_code.js
Created Nov 14, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console