Skip to content

Instantly share code, notes, and snippets.

View benbabics's full-sized avatar

Ben Babics benbabics

View GitHub Profile
selected_tags = @collection.filter (model) ->
# get data
is_client = model.get 'int_is_client'
last_posted = model.get 'dtm_last_posted'
# get morning time
morning = new Date()
morning.setHours 0
morning.setMinutes 0
morning.setSeconds 0
define [
'BaseController'
],
(BaseController) ->
class NavigationController extends BaseController
initialize: (settings) ->
@benbabics
benbabics / Image Preloader
Created May 28, 2014 13:50
Image Preloader
preloadImage = (image_data) ->
deferred = $.Deferred()
# preload the image, so it's ready to display
cache_bust = ( new Date() ).getTime()
img = new Image()
img.src = "#{image_data.src}?size=large&cachebust=#{cache_bust}"
# image has loaded, resolve deferred
$( img ).on 'load', ->
@benbabics
benbabics / ApplicationController.js
Last active August 29, 2015 14:07
AngularJS BaseController
(function() {
var app, ApplicationController;
ApplicationController = window.BaseController.extend({
inject: ['$rootScope', 'MyService'],
initialize: function($scope, $rootScope, MyService) {
// (optional) intitialize stuff
@benbabics
benbabics / gist:517810aee2d1a596cfd8
Last active August 29, 2015 14:12
LabNetwork - Form
<form>
<fieldset>
<legend>Personal Information</legend>
<div class="form-group required">
<label for="first-name">First Name:</label>
<div class="field">
<input class="form-control" id="first-name" name="first-name">
</div>
</div>
{
"enemy_clan_name": "Huge Assholes",
"sluggified_clan_name": "huge-assholes",
"result_display": ["Declared", "Ongoing", "Victory", "Defeat", "Tie"],
"friendly_stars": 15,
"enemy_stars": 12,
"friendly_attacks_used": 8,
"enemy_attacks_used": 6,
"starts_at": "2014-12-25 12:30:00+00:00",
"ends_at": "2014-12-26 12:30:00+00:00",
###
possible schema
###
User
has_many :posts
has_many :tools
has_many :products, through: :tools
Post
@benbabics
benbabics / example.js
Created January 25, 2012 13:23 — forked from doubleclickdetroit/example.js
JS Inheritance
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
};
function Author(name, books) {
Author.superClass.constructor.call(this, name);
this.books = books;
@benbabics
benbabics / UI Helper Classnames
Created January 31, 2013 14:23
Fortunately Twitter Bootstrap arms us with an arsenal of classnames for components, grids and other UI-goodies. Unfortunately, they don't supply us with something as basic as layout helpers. Here's what I've used:
.margin-top {
margin-top: 20px;
}
.margin-right {
margin-right: 20px;
}
.margin-bottom {
margin-bottom: 20px;
}
.margin-left {
@benbabics
benbabics / MyClass.js
Created March 6, 2013 21:12
This is in-regard to a comment someone made about having a triple nested return for "getInstance".
define([ 'utils/Singleton' ],
function(Singleton) {
'use strict';
var MyClass;
MyClass = (function() {
function MyClass() {}