Skip to content

Instantly share code, notes, and snippets.

@mstarkman
mstarkman / classes.cs
Created September 20, 2011 17:48
Ignoring Extra Elements in mongodDB C# driver
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class PersonWithBirthDate : Person
{
public DateTime DateOfBirth { get; set; }
}
@mstarkman
mstarkman / gist:1218361
Created September 15, 2011 02:23
CoffeeScript Build System for Sublime Text 2
{
"cmd": ["/usr/local/bin/coffee", "-cp", "--bare", "$file"],
"selector": "source.coffee",
"path": "/usr/local/bin:$PATH"
}
@mstarkman
mstarkman / syntax_highlighting.py
Created September 15, 2011 01:51 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@mstarkman
mstarkman / FishidyMongo.cs
Created September 13, 2011 14:34
Mongo Protected Fields
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using Fishidy.Domain.Attributes;
using Fishidy.Domain.Models.Base;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Driver;
@mstarkman
mstarkman / GroupDocuments.js
Created September 7, 2011 18:56
mongoDB Many-to-Many Data Modeling
db.groups.insert({
"_id": ObjectId("4e54ed9f48dc5922c0094a42"),
"groupName": "mongoDB User",
"persons": [
ObjectId("4e54ed9f48dc5922c0094a43"),
ObjectId("4e54ed9f48dc5922c0094a40")
]
});
db.groups.insert({
@mstarkman
mstarkman / gist:1200724
Created September 7, 2011 14:32
Send method
#region Public Methods
public void Send(NotificationType type, NotificationTemplate template, ObjectId fromUserId, ObjectId toUserId)
{
if (type != NotificationType.Email)
return;
var fromUser = UserService.GetById(fromUserId);
var toUser = UserService.GetById(toUserId);
var toMailAddress = new MailAddress(toUser.EmailAddress, toUser.Name.FullName);
@mstarkman
mstarkman / gist:1137911
Created August 10, 2011 19:33
Social_GetNotificationCounts
using System;
using System.Linq;
using System.Collections.Generic;
using Fishidy.Domain.SqlServerStructures.Models.Persistence;
using Fishidy.Domain.SqlServerStructures.Models.Processing;
namespace Fishidy.Domain.SqlServerStructures.StoredProcedures
{
public class Social_GetNotificationCounts
{
@mstarkman
mstarkman / gist:1134634
Created August 9, 2011 17:21
JavaScript Masters Class - Exercise 8
// 1.
function Person(name) {
this.name = name;
}
var thomas = new Person('Thomas');
var amy = new Person('Amy');
console.log(thomas.name);
@mstarkman
mstarkman / gist:1133259
Created August 9, 2011 01:50
JavaScript Masters Class - Exercise 7
function convertToArray(iterable) {
return Array.prototype.slice.call(iterable);
}
Function.prototype.cached = function() {
var __method = this;
// This is to ensure there is only one argument, otherwise just return the results of the calling method.
if (__method.length != 1)
{
@mstarkman
mstarkman / Exercise1-FunctionalVersion.js
Created August 9, 2011 01:50
JavaScript Masters Class - Exercise 1
// Functional Version
window.logCar = function(carOptions){
if (carOptions.hasOwnProperty('color') && carOptions.hasOwnProperty('make'))
console.log("I'm a " + carOptions.color + " " + carOptions.make);
else
console.log("I can't tell you about the car!");
}
logCar({ color: 'blue', make: 'BMW' });