Skip to content

Instantly share code, notes, and snippets.

View robbenmu's full-sized avatar
🤒
Out sick

Mr.Q robbenmu

🤒
Out sick
View GitHub Profile
@carlesso
carlesso / phantomtumblr.js
Last active March 15, 2016 04:01
Phantom Tumblr https error
var page = require('webpage').create();
var system = require('system');
page.onResourceRequested = function (request) {
system.stderr.writeLine('= onResourceRequested()');
system.stderr.writeLine(' request: ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function(response) {
system.stderr.writeLine('= onResourceReceived()' );
@sqndr
sqndr / phantom-responsive.js
Created June 27, 2014 08:14
Phantom Responsive.
var async = require('async');
var sizes = [
[320, 480],
[600, 1024],
[1024, 768],
[1280, 800],
[1440, 900]
];
var url = 'http://one-pager.dev/nl';
@sorribas
sorribas / phantom-process.js
Created June 13, 2014 12:31
New Phantom process.
// Code to be run by PhantomJS.
// The docs for these modules are here: http://phantomjs.org/api/
// Note that the 'fs' module here has a different API than the one in node.js core.
var webpage = require('webpage');
var system = require('system');
var fs = require('fs');
var page = webpage.create();
var inc = 0;
@colingourlay
colingourlay / Array.apply
Last active May 28, 2018 09:35
Function.prototype.apply 's handling of an object instead of an array. It forces the object through Array.prototype.slice function as 'this' to create an array, pretty much what we do to turn an arguments object into a real array.
Array.apply(null, [1, 2, 3])
> [1, 2, 3]
Array.apply(null, [1, 2, 3]).length
> 3
Array.apply(null, {length:3})
> [undefined, undefined, undefined]
Array.apply(null, {length:3}).length
@LinusU
LinusU / README.md
Last active July 17, 2021 08:06 — forked from apla/icons_and_splash.js
Icons and Splash images for your Cordova project. (with iOS 7 support)

Usage

Install cordova into node_modules

npm install cordova

Add icons_and_splash.js

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2025 08:16
A badass list of frontend development resources I collected over time.
@ssddi456
ssddi456 / gist:5566866
Last active December 17, 2015 06:39
for browser gbkescape
define([],function() {
var iframe=document.createElement("iframe");
iframe.src="about:blank";
iframe.setAttribute("style","display:none;visibility:hidden;");
document.body.appendChild(iframe);
var d=iframe.contentWindow.document;
d.charset=d.characterSet="GBK";
function getGBKEscape(s) {
d.write("<body><a href='?"+s+"'>X</a></body>");
d.close();
@mikermcneil
mikermcneil / associations-proposal.js
Last active April 16, 2016 17:32
another proposal for instance methods and associations
// Note that instance and class methods could also be defined at the adapter level
// (e.g. CRUD adapters add .save() and .destroy() methods, but the Twillio API might add a .call() method)
// User.js
module.exports = sails.Model.extend({
// Adapters are applied from left to right
// (methods defined in more than one adapter use the rightmost adapter's version, just like _.extend)
adapter: ['mysql', 'twilio'],
@paulirish
paulirish / performance.now()-polyfill.js
Last active December 11, 2024 09:06
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
@neilk
neilk / nonBlockingForEach.js
Last active November 25, 2021 11:06
Works a little bit like `Array.prototype.forEach()`, but uses `process.nextTick` to allow other processes to execute. NOTE. This isn't meant to be practical; if you use this in production code you're probably doing it wrong.
/**
* Allow other processes to execute while iterating over
* an array. Useful for large arrays, or long-running processing
*
* @param {Function} fn iterator fed each element of the array.
* @param {Function} next executed when done
*/
Array.prototype.nonBlockingForEach = function(fn, next) {
var arr = this;
var i = 0;