Skip to content

Instantly share code, notes, and snippets.

View jessehattabaugh's full-sized avatar
🤠
pew pew

Jesse Hattabaugh jessehattabaugh

🤠
pew pew
View GitHub Profile
@jessehattabaugh
jessehattabaugh / DpzsG.markdown
Last active August 29, 2015 13:57
A Pen by Jesse Hattabaugh.
#!/usr/bin/env node
"use strict";
var fs = require('fs'),
gw = require('globwatcher').globwatcher;
var cssw = gw('./source/*.styl', {persistent: true});
cssw.on('added', function (filename) {
var gulp = require('gulp');
gulp.task('default', ['stylus']);
/* Stylus
-------------------------------------*/
var stylus = require('gulp-stylus');
var nib = require('nib');
gulp.task('stylus', function() {
return gulp.src('source/*.styl')
@jessehattabaugh
jessehattabaugh / helper.js
Created May 7, 2014 21:53
setsGets assertion helper for Chai
module.exports = function (chai, utils) {
var Assertion = chai.Assertion;
Assertion.addMethod('setsGets', function (val) {
var method = this._obj;
// setter/getters must be functions
new Assertion(method).to.be.a('function');
@jessehattabaugh
jessehattabaugh / gist:5e3b31a0fc20598dff20
Last active August 29, 2015 14:02
gulp image compression task with gulp-watch
/* Images
******************************************************************************/
gulp.task('images', function() {
// batch mode
watch({glob: './source/images/*'})
.pipe(plumber())
.pipe(imagemin({
progressive: true,
interlaced: true
@jessehattabaugh
jessehattabaugh / _fonts.styl
Last active August 29, 2015 14:13
Stylus Mixin for defining and using webfonts
/* Esplaination
****************************************************************************
This include represents a pattern for handling fonts which I have settled on after a lot of time
struggling to get fonts to render consistently across browsers. The jist of it is this; I don't
use font-weight or font-style. Instead I use a different font-family for each variation of the
font (ie. font-family: "FiraSans-Regular"; font-family: "FiraSans-BoldItalic"). The reason I do
this is that browsers don't always use the appropriate @font-face even when you declare them
with font-weight and font-size. This method allows me to control EXACTLY which font file is used.
*/
function get_analyze_terms(){
printp("total:",storage.site.terms)
storage.terms.sort(lastAnalyzed).limit(40).forEach(function(t){
t.volume = (100 / storage.site.count) * t.count
if(t.volume > 0.1) t.relevant = false
else if(t.volume < 0.008) t.relevant = false
else t.relevant = true
storage.interests.filter({term:t}).forEach(function(i){
i.volume = (100 / i.user.count) * i.count
i.difference = i.volume - t.volume
function cron_analyze_users(){
var subject = storage.users.sort(lastAnalyzed).first()
var interests = []
storage.interests.filter({user:subject,relevant:true}).forEach(function(i){
interests[i.term.string] = i.difference
})
var analyzed = []
storage.relations.filter({subject:subject}).forEach(function(r){
function niceDate(date) {
if(typeof date == 'object') {
if(Date.today().compareTo(date) == -1) return 'today'
else if(Date.today().add({days:-1}).compareTo(date) == -1) return 'yesterday'
else return date.toString('MM/dd/yy')
} else return '02/24/82'
}
function niceTime(date) {
if(typeof date == 'object') {
if(date > (1).minutes().ago())
function cron_refresh(){
storage.feeds.sort(stale).limit(5).forEach(function(feed){
var loadedFeed = loadFeed(feed.url)
// here would be a good place to update the rest of the feed's fields in case they've changed
var entries = loadedFeed.entries
var n=0
for(var i=0; i<entries.length; i++){
var someEntry = storage.entries.filter({feed:feed, title:entries[i].title}).first()
if(!someEntry) {
var published = parseDate(entries[i].publishedDate)