Skip to content

Instantly share code, notes, and snippets.

@smoak
smoak / gist:1503938
Created December 21, 2011 00:23
BeerAndCodeSeattle diff
diff --git a/package.json b/package.json
index faa6f57..545b39d 100644
--- a/package.json
+++ b/package.json
@@ -3,12 +3,16 @@
"version": "0.0.1",
"private": true,
"dependencies": {
- "express": "2.3.12",
+ "express": "*",
class Entity:
def __init__(self, data):
self.data = data
class Org(Entity):
@property
def avatar_url(self):
return self.data["avatar_url"]
class Entity:
def __init__(self, jsonData)
self.jsonData = jsonData
@classmethod
def register_fields(cls, *fields):
for name in fields:
setattr(cls, name, property(lambda cls: cls.jsonData[name]))
class Org(Entity):
@if (this.Model.Users.Count > 0)
{
@this.Model.Users.Count(a => a.IsAdmin) of @this.Model.Users.Count are admins
}
public class CountItem<T>
{
public int Count { get; set; }
public T Value { get; set; }
}
var states = new List<string>
{
"WA",
for (f in dbPerson.family) do
// try and find the fm in the api
foundFm = null
for (apiFm in apiPerson.family) do
if apiFm == f then
foundFm = apiFm
break
end
end
if foundFm != null then
public enum CallType {
Outgoing("Outgoing Call"),
Incoming("Incoming Call"),
Missed("Missed Call");
private String label;
public String getLabel() {
return this.label;
}
// assumes you have already gotten this json back from an Http server:
// [{"id":1,"firstName":"j","lastName":"v"},{"id":2,"firstName":"Dr. a","lastName":"b"}]
// and stored it in a String called json
JSONArray json = new JSONArray(json);
// loop over each individual json object:
// a single json object looks like: {"id":1,"firstName":"j","lastName":"v"}
int count = json.length();
for (int i = 0; i < count; i++) {
private struct Row
{
public int UserId;
public DateTime DateUtc;
}
List<Row> table = new List<Row>
{
new Row { UserId = 1, DateUtc = DateTime.Parse("2012-01-05 17:00:00.000") },
new Row { UserId = 1, DateUtc = DateTime.Parse("2012-01-26 17:00:00.000") }
;WITH base AS
(
SELECT UserId,
DateUtc,
ROW_NUMBER() over (partition BY UserId ORDER BY DateUtc) AS rn
FROM dbo.UserActivity WHERE DateUtc Between @startDate and @endDate
)
SELECT b1.UserId,
SUM(CASE