Skip to content

Instantly share code, notes, and snippets.

@stephenplusplus
stephenplusplus / retry-failed-route.js
Created February 19, 2014 18:51
Angular API re-attempt
angular
.module('app')
.config(function ($httpProvider) {
$httpProvider.interceptors.push(['$injector', '$q', function ($injector, $q) {
return {
responseError: function (rejection) {
var $http = $injector.get('$http'),
$state = $injector.get('$state'),
MAX_RETRY_ATTEMPTS = 2,
request = rejection.config,
@stephenplusplus
stephenplusplus / byestyle.js
Last active August 29, 2015 14:00
remove inline styles from mean developers.
(function () {
[].slice.call(document.querySelectorAll('[style]')).
forEach(function (el) {
console.info(el.tagName.toLowerCase() + '.' + el.className);
console.log(el.getAttribute('style').split(/;\s*/g).join('\n'));
el.removeAttribute('style');
});
})();
@stephenplusplus
stephenplusplus / h5bp.js
Last active August 29, 2015 14:04 — forked from passy/h5bp.js
document.write("<!DOCTYPE html>");
document.write("<!--[if lt IE 7]> <html class=\"no-js lt-ie9 lt-ie8 lt-ie7\"> <![endif]-->");
document.write("<!--[if IE 7]> <html class=\"no-js lt-ie9 lt-ie8\"> <![endif]-->");
document.write("<!--[if IE 8]> <html class=\"no-js lt-ie9\"> <![endif]-->");
document.write("<!--[if gt IE 8]><!--> <html class=\"no-js\"> <!--<![endif]-->");
document.write(" <head>");
document.write(" <meta charset=\"utf-8\">");
document.write(" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">");
document.write(" <title><\/title>");
document.write(" <meta name=\"description\" content=\"\">");
@stephenplusplus
stephenplusplus / p.cpp
Created September 28, 2014 01:25
saySomethingCute
void Daughter::saySomethingCute(unsigned short int whatThing) const {
std::string cuteThings[5] = {
"hiii dayud",
"a-woo!",
"mommm",
"geooo",
"bae"
};
if (whatThing > 4) {
whatThing = 0;
datastore
✓ should allocate IDs (691ms)
✓ should be able to save keys as a part of entity and query by key (1067ms)
create, retrieve and delete
✓ should save/get/delete with a key name (3964ms)
✓ should save/get/delete with a numeric key id (977ms)
✓ should save/get/delete with a generated key id (981ms)
✓ should save/get/delete multiple entities at once (1127ms)
querying the datastore
✓ should limit queries (985ms)
var stream = require("stream")
getSourceStreamThatThrowsError().
on("error", console.error.bind(null, "source stream")).
pipe(getDestinationStreamThatThrowsError()).
on("error", console.error.bind(null, "dest stream"))
function getSourceStreamThatThrowsError() {
var rs = new stream.Readable
var fs = require('fs'),
gcloud = require('gcloud'),
knox = require('knox'),
path = require('path'),
ProgressBar = require('progress'),
RSVP = require('rsvp'),
tar = require('tar'),
through = require('through2'),
uuid = require('uuid'),
zlib = require('zlib');
@stephenplusplus
stephenplusplus / bucket.js
Created March 3, 2015 16:25
Make public / private
Bucket.prototype.makePublic = function(options, callback) {
var self = this;
if (util.is(options, 'function')) {
callback = options;
options = {};
}
// Allow public to read bucket contents while preserving original permissions.
this.acl.add({
{
"GAE_MODULE_VERSION": "18",
"npm_config_cache_lock_stale": "60000",
"API_PORT": "65435",
"npm_config_sign_git_tag": "",
"npm_package_dependencies_multiparty": "^3.3.2",
"npm_config_user_agent": "npm/1.4.28 node/v0.10.33 linux x64",
"npm_config_always_auth": "",
"npm_config_bin_links": "true",
"npm_config_key": "",