Skip to content

Instantly share code, notes, and snippets.

// Copyright 2012 Google Inc. All Rights Reserved.
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
// initial utilities
var gutil = require('gulp-util'); // tools to help, e.g. detect env, colour our output + logging
var changeEvent = function(evt) {
// log
gutil.log('File', gutil.colors.cyan(evt.path.replace(new RegExp('/.*(?=/' + paths.appSrc + ')/'), '')), 'was', gutil.colors.magenta(evt.type));
};
require('autostrip-json-comments'); // https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr
// 'development' is just default, production overrides are triggered by adding the production flag to the gulp command e.g. `gulp build --production`
@totty90
totty90 / email.js
Created August 6, 2014 00:22
React.js HTML email
define(function(require, exports, module){
var React = require('react');
var constants = require('constants');
var _ = require('underscore');
var motivationalLines = [
'Life isn’t about getting and having, it’s about giving and being.',
'Whatever the mind of man can conceive and believe, it can achieve.',
'You miss 100% of the shots you don’t take.',
'Every strike brings me closer to the next home run.',
'The mind is everything. What you think you become.',
@edinella
edinella / mongooseUniquenessValidation.js
Last active September 12, 2016 17:42
Mongoose uniqueness validator, case-sensitive or not
// context
var mongoose = require('mongoose');
mongoose.connect('mongodb://...');
/**
* Generates Mongoose uniqueness validator
*
* @param string modelName
* @param string field
* @param boolean caseSensitive
@derekmartinla
derekmartinla / gist:46bbbcd2e800111fd46f
Last active November 24, 2016 16:09
Copy Existing AdWords Ads With A New Destination URL
function main() {
// change the CampaignName condition to whatever suits you
var adIter = AdWordsApp.ads().withCondition("CampaignName contains WP").withCondition("Status = ENABLED").get();
while(adIter.hasNext()) {
var ad = adIter.next();
var headline = ad.getHeadline();
var d1 = ad.getDescription1()
var d2 = ad.getDescription2();
@simondahla
simondahla / vwo-blink-prevention.css
Created October 22, 2013 11:49
How to prevent "the blink" in Visual Website Optimizer
@Valve
Valve / sixpack-production-setup.md
Last active February 4, 2017 20:32
Sixpack, Gunicorn, Nginx, Supervisord, Ubuntu setup

1. Create a new EC2 instance, add TCP ports 22, 80 and 8080 to the security group

2. I did everything on Ubuntu 14.04.2 server 64bit
3. Log in
sudo apt-get update
sudo apt-get upgrade

redis

@insin
insin / Google Closure.sublime-build (Linux)
Created December 22, 2011 01:06
Google Closure Compiler build for Sublime Text 2
{
"cmd": ["java", "-jar", "${packages}/Google Closure/compiler.jar", "--js", "$file", "--js_output_file", "/dev/null", "--compilation_level", "WHITESPACE_ONLY"],
"file_regex": "^(.*):([0-9]+):() ERROR - (.*)",
"selector": "source.js"
}
@andrewrocco
andrewrocco / ga-ratio.js
Created July 17, 2012 15:48
Pixel Aspect Ratio Google Analytics Custom Variable
// Create the test
var pixelRatio = (window.devicePixelRatio >= 1.5) ? "high" : "normal";
..
// Pass it along through GA
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
// --- IMPORTANT LINE!
// params: event method, custom variable slot, variable name, variable value, scope level

What if a package did something like this, but instead of logging to the console, they sent it back to a server?

Have you actually reviewed every dependency and every child dependency in every app you deploy?

Why are people not more scared of this?

Analytics