Skip to content

Instantly share code, notes, and snippets.

View tsvetomir's full-sized avatar

Tsvetomir Tsonev tsvetomir

View GitHub Profile
@tsvetomir
tsvetomir / l2e_dategrouping.cs
Created December 17, 2012 11:50
Date grouping with LINQ to Entities
var groupedData =
from s in db.Intraday
where s.Date >= dateFrom && s.Date <= dateTo
group s by new
{
Year = s.Date.Year,
Month = baseUnit >= BaseUnit.Months ? s.Date.Month : 1,
Day = baseUnit >= BaseUnit.Weeks ? s.Date.Day : 1,
Hour = baseUnit >= BaseUnit.Hours ? s.Date.Hour : 0,
Minute = baseUnit >= BaseUnit.Minutes ? s.Date.Minute : 0
@tsvetomir
tsvetomir / gist:3817178
Created October 2, 2012 07:56
Comparing JS dates
var d1 = new Date(),
d2 = new Date(d1.getTime());
console.log("d1 === d2 ->", d1 === d2); // false
console.log("d1 == d2 ->", d1 == d2); // false
console.log("d1 < d2 ->", d1 < d2); // false
console.log("d1 > d2 ->", d1 > d2); // false
console.log("d1 <= d2 ->", d1 <= d2); // true
console.log("d1 >= d2 ->", d1 >= d2); // true
// George Bool is really pissed at this point
function Point(a, b) {
if (arguments.length === 1) {
this.x = Math.round(a / 1000);
this.y = a - this.x * 1000;
} else {
this.x = a;
this.y = b;
}
}
@tsvetomir
tsvetomir / campfire-localtime.js
Created March 15, 2012 15:59
Local time in Campfire chats
// ==UserScript==
// @name Campfire local time
// @namespace http://tsonev.net/campfire/localtime
// @version 0.2
// @description Converts time stamps to local time in Campfire chats. Tested in Chrome.
// @match https://XXXXXX.campfirenow.com/room/*
// ==/UserScript==
var TIME_ZONE = "CDT";