Skip to content

Instantly share code, notes, and snippets.

View Albert-IV's full-sized avatar

Albert Engelbrecht Albert-IV

View GitHub Profile
@Albert-IV
Albert-IV / gist:4166261
Created November 29, 2012 01:53
Throw 'em OFF
var dis = 10
, shiz = 'hurp'
, bananas = false
, bro = 100000
each user in @userLinks
if (usrId != user._id)
repAlert = new Alert({ # Create new alert
alertTime: new Date()
leadId: @_id
userId: user._id
creatorId: usrId
category: 'new_application'
comment: 'New application process for this lead!'
})
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
</style>
</head>
<body>
<h1>What?! HOLY SHMOKES</h1>
</body>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/q.js/0.9.2/q.min.js"></script>
@Albert-IV
Albert-IV / wat.js
Created July 12, 2013 19:28
Actual documentation from MongoDB. This was a "simple example". http://mongodb.github.io/node-mongodb-native/api-generated/gridstore.html
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSetServers = require('mongodb').ReplSetServers,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Grid = require('mongodb').Grid,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
@Albert-IV
Albert-IV / gist:6003602
Created July 15, 2013 21:18
Saw this at work today.
$("#thedivtobehiddenifauserpressesonquestionbutton")
@Albert-IV
Albert-IV / example-mongo-connect.ion.js
Created August 15, 2013 18:57
Example for changing logic depending on mongo results.
CollectionOne.find( { 'search-term-here' : 'value' }, function(e, col1) {
if (e) return cb(e);
CollectionTwo.find( { 'your-search-here' : 'value' }, function(e, col2) {
if (e) return cb(e);
if (!results || !results.length) {
noPreviousResults(col1, cb);
} else {
previousResults(col1, col2, cb);
}
@Albert-IV
Albert-IV / mongoose.js
Created September 19, 2013 02:12
MongoDB Query
Lead.find( {'$where' : "['fresh', 'new'].indexOf(this.status) > -1"} )
// This runs JavaScript to figure out if the status wasn't "fresh" or "new"
Lead.find( {"status" : { "$nin" : [ "fresh", "new" ] } } )
// Much more performant
@Albert-IV
Albert-IV / har-har-har.js
Created October 23, 2013 14:06
Found this working on some code.
var date = new Date(date);
if (!date.isDate()) console.error("When is a date not a date? When it's a NaN, of course.");
@Albert-IV
Albert-IV / nofollow-check.js
Last active December 26, 2015 08:09
Chrome Snippet to validate if a page is set to noindex,nofollow
var $robots = $('meta[name="robots"]');
$robots.each( function() {
var attribute = this.getAttribute('content');
if ( attribute == "noindex,nofollow" || attribute == "nofollow,noindex" ) {
console.log( 'Page is%c noindex nofollowed', 'color: red; font-size: 2em;' );
}
});
!function() {
var DATE_EXT = {};
var extendMe;
DATE_EXT.getLabel = (function() {
return function() {
if( isNaN( this.getTime() ) ) return NaN;
return (this.getMonth() + 1) + '/' + this.getDate() + '/' + this.getFullYear().toString().substr(2,2);