Skip to content

Instantly share code, notes, and snippets.

View tracend's full-sized avatar
🎯
Focusing

✌ Makis Tracend tracend

🎯
Focusing
View GitHub Profile
Handlebars.registerHelper("prettyDate", function (time) {
var date = new Date((time || "")),
diff = (((new Date()).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);
// exit now if not a number...
if ( isNaN(day_diff)) return;
if ( day_diff < 0 ){
// this is in the future...

Float label

A web component that create a CSS-only floating label for input tags

@tracend
tracend / backbone.api.twitter.js
Created October 17, 2012 09:39 — forked from ryndel/backbone.twitter.js
[DEPRECATED] Backbone.js helper for Twitter requests Project moved: http://github.com/backbone-api/twitter
if(typeof APP == "undefined"){
var APP = {
Models: {},
Collections: {},
Views: {}
};
}
APP.Models.Twitter = {};
APP.Models.Twitter.Tweet = Backbone.Model.extend({
@tracend
tracend / jsonval.sh
Created July 17, 2012 05:54 — forked from cjus/jsonval.sh
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`
@tracend
tracend / backbone.router.js
Created July 3, 2012 23:25 — forked from daveaugustine/Inside_your_router.coffee
[DEPRECATED]: Super simple Google Analytics page tracking with backbone.js
Router = Backbone.Router.extend({
initialize: function() {
this.bind('all', this._trackPageview);
},
_trackPageview: function(){
var url = Backbone.history.getFragment();
_gaq.push(['_trackPageview', "/#"+url]);
}
@tracend
tracend / README.md
Created January 26, 2012 19:38 — forked from mbostock/.block
Hierarchical Bar Chart

This bar chart visualizes hierarchical data using D3. Each blue bar represents a folder, whose length encodes the total size of all files in that folder (and all subfolders). Clicking on a bar dives into that folder, while clicking on the background bubbles back up to the parent folder. The effect is similar to a zoomable partition layout, though in a more conventional display.

@tracend
tracend / README.md
Created January 26, 2012 19:37 — forked from mbostock/.block
Pie Multiples

An example of multiple pie (donut) charts created with D3. The data is represented as a two-dimensional array of numbers; each row in the array is mapped to a pie chart. Thus, each pie represents the relative value of a number (such as 1,013) within its rows. Note that in this dataset, the totals for each row are not equal.

@tracend
tracend / jasmine.md
Created January 16, 2012 23:45 — forked from addyosmani/jasmine.md
Rough-work for Jasmine section of Backbone Fundamentals

##Introduction

One definition of unit testing is the process of taking the smallest piece of testable code in an application, isolating it from the remainder of your codebase and determining if it behaves exactly as expected. In this section, we'll be taking a look at how to unit test Backbone applications using a popular JavaScript testing framework called Jasmine from Pivotal Labs.

For an application to be considered 'well'-tested, distinct functionality should ideally have its own separate unit tests where it's tested against the different conditions you expect it to work under. All tests must pass before functionality is considered 'complete'. This allows developers to both modify a unit of code and it's dependencies with a level of confidence about whether these changes have caused any breakage.

As a basic example of unit testing is where a developer may wish to assert whether passing specific values through to a sum function results in the correct output being re

@tracend
tracend / loadTemplates.js
Created January 16, 2012 23:45 — forked from superchris/loadTemplates.js
loading templates in jasmine specs
jasmine.Fixtures.prototype.loadTemplate_ = function(template) {
var templateUrl = "/backbone/templates/" + template;
var self = this;
$.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
dataType: 'html',
url: templateUrl,
success: function(data) {
$('#' + self.containerId).append(data);