Skip to content

Instantly share code, notes, and snippets.

@lgrayland
lgrayland / emailCollector.js
Created February 24, 2017 16:56
uses regex to find email addresses on a page
// Returns a list of emails for every page on the domains of the URL list
var EightyApp = function() {
this.processDocument = function(html, url, headers, status, jQuery) {
var app = this;
$ = jQuery;
var $html = app.parseHtml(html, $);
var object = {};
// Get emails
Subscription.where([
"user_id NOT IN (?) OR channel_id NOT IN (?)",
User.pluck("id"),
Channel.pluck("id")
]).destroy_all
@lgrayland
lgrayland / vertAlign.scss
Created November 26, 2015 16:53
snippet of scss to vertically align a div
.item-to-align {
&:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
}
@lgrayland
lgrayland / placeholderFilter
Last active November 26, 2015 16:54
Filter to create place holder text when fiend is null of undefined
.filter('placeholdEmpty', function($timeout) {
var incre = 0
$timeout(function(){
incre = 0;
}, 5000);
return function (input) {
if (!(input == undefined || input == null)) {
return input;
} else {
incre += 1;
@lgrayland
lgrayland / capitalize
Created November 16, 2015 14:56
filter to capitalise first character use capitalize:true to set first letter of each word
.filter('capitalize', function() {
return function(input, all) {
var reg = (all) ? /([^\W_]+[^\s-]*) */g : /([^\W_]+[^\s-]*)/;
return (!!input) ? input.replace(reg, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}) : '';
}
})
@lgrayland
lgrayland / unixFilter.txt
Last active November 4, 2015 14:11
angular filter to convert unix timestamp using moment.js
.filter('fromUnix', function() {
return function (date) {
return moment.unix(date).format("DD/MM/YYYY");
}
})