Skip to content

Instantly share code, notes, and snippets.

@roidayan
roidayan / tocsv.js
Created November 2, 2015 12:18 — forked from JeffJacobson/tocsv.js
JavaScript object to CSV
/**
* Converts a value to a string appropriate for entry into a CSV table. E.g., a string value will be surrounded by quotes.
* @param {string|number|object} theValue
* @param {string} sDelimiter The string delimiter. Defaults to a double quote (") if omitted.
*/
function toCsvValue(theValue, sDelimiter) {
var t = typeof (theValue), output;
if (typeof (sDelimiter) === "undefined" || sDelimiter === null) {
sDelimiter = '"';
@roidayan
roidayan / autofocus.directive.js
Last active November 16, 2015 19:44 — forked from mlynch/autofocus.js
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus="true">
*
* License: MIT
*/
@roidayan
roidayan / timeago.filter.js
Last active September 11, 2015 08:32 — forked from rodyhaddad/timeago.filter.js
timeago filter for angularjs
.filter("timeago", function () {
//time: the time
//local: compared to what time? default: now
//raw: wheter you want in a format of "5 minutes ago", or "5 minutes"
return function (time, local, raw) {
if (!time)
return "never";
if (!local) {
local = Date.now();