Skip to content

Instantly share code, notes, and snippets.

@connected
connected / date_ranges.js
Created May 30, 2018 13:52 — forked from jllodra/date_ranges.js
Calculate start/end dates for common ranges in Javascript.
// Calculate and set ranges: today, yesterday, this week, past week, this month, past month, this year
switch(newValue) {
case 'today':
initial_date.setValue(new Date());
end_date.setValue(new Date());
break;
case 'yesterday':
var d = new Date();
d.setDate(d.getDate() - 1);
initial_date.setValue(d);
@connected
connected / services.js
Last active December 30, 2015 22:59 — forked from Mithrandir0x/gist:3639232
Angular services example
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"