Skip to content

Instantly share code, notes, and snippets.

app.directive('faFastScroll', ['$parse', function ($parse) {
var Interval = function(min, max) {
this.min = min || 0;
this.max = max || 0;
};
Interval.prototype.clip = function(min, max) {
if(this.max <= min || this.min >= max) {
this.min = this.max = 0;
@timelf123
timelf123 / ngjson.js
Created January 27, 2017 23:08 — forked from tshaddix/ngjson.js
Very basic modification of Express JS res.json(). Adds the safety prefix for Angular JS to the body of all json responses. Extends the response object with one method: ngJSON. Simply require file somewhere in application (normally app.js) before executing ngJSON responses.
var http = require('http');
var NG_PREFIX = ")]}',\n";
http.ServerResponse.prototype.ngJSON = function(obj){
// allow status / body
if (2 == arguments.length) {
// res.json(body, status) backwards compat
if ('number' == typeof arguments[1]) {
this.statusCode = arguments[1];
@timelf123
timelf123 / shopify.md
Created November 8, 2016 20:50 — forked from lambtron/shopify.md
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@timelf123
timelf123 / app.js
Last active October 29, 2016 20:02 — forked from ezekielchentnik/app.js
import express from 'express';
const app = express();
if (IS_DEV) {
require('piping')(); // https://www.npmjs.com/package/piping -- live reload app - replaces nodemon
}
//express routes, etc.
export default app;
@timelf123
timelf123 / gist:b04e2a4b7599d510fd7f7975bc5ec7fe
Created October 25, 2016 16:04 — forked from zachleat/gist:2008932
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@timelf123
timelf123 / find_one_by_id.js
Created September 15, 2016 20:36 — forked from ofirski/find_one_by_id.js
Add findOneById to MongoShell's DB collection
/****************************************************************************
* Add this snippet to ~/.mongorc in order to load it to any shell initiated
* Usage:
* db.myCollection.findOneById("5149cdbb62d5cbb22c000024")
* db.myCollection.findOneById("5149cdbb62d5cbb22c000024",{"field":1})
*****************************************************************************/
DBCollection.prototype.findOneById = function(objId ,fields, options ){
return this.findOne({"_id":ObjectId(objId)}, fields, options);
}
@timelf123
timelf123 / instagram-follow-script.js
Created September 12, 2016 18:07 — forked from underdown/instagram-follow-script.js
Instagram script for followers
/* source https://www.youtube.com/watch?v=UKi1NwqKCz8
_aj7mu _r4e4p _95tat _o0442
*/
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict()
@timelf123
timelf123 / gist:b76f73855ab83ee22c8a3d8b1497a72b
Created September 12, 2016 18:06 — forked from derekmartinla/gist:b719840542406322bb27
AdWords Countdown Ads Updater Script
/***************************************************************************************
* AdWords Countdown Ad Updater -- Find stale countdown ads and replace them with
* Ads that are updated with new dates.
* Version 1.0
* Created By: Derek Martin
* DerekMartinLA.com or MixedMarketingArtist.com
****************************************************************************************/
var DESCRIPTION2_TEXT = "Sale Ends In"
@timelf123
timelf123 / textLike.js
Created September 12, 2016 18:05 — forked from edinella/textLike.js
MongoDB Query similar to SQL "LIKE"
module.exports = function textLike(str) {
var escaped = str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
return new RegExp(escaped, 'i');
};
@timelf123
timelf123 / mongooseUniquenessValidation.js
Created September 12, 2016 17:42 — forked from edinella/mongooseUniquenessValidation.js
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