Skip to content

Instantly share code, notes, and snippets.

public Customer CurrentCustomer {
get {
if (_currentCustomer == null) {
_currentCustomer = CustomerFromSession();
if (_currentCustomer == null) {
_currentCustomer = CurrentUser.Customers.First();
PersistCustomer(_currentCustomer);
}
}
@eldewall
eldewall / gist:1178044
Created August 29, 2011 08:52
nullfest
public Models.Contact CurrentUser {
get {
if (_currentContact == null) {
_currentContact = GetUser();
}
return _currentContact;
}
}
public class ObjectCount {
public Dictionary<int, int> Values { get; private set; }
public ObjectCount(Dictionary<int, int> values) {
this.Values = values;
}
public int Total {
get {
return Values.Sum(v => v.Value);
@eldewall
eldewall / gist:1203030
Created September 8, 2011 09:38
MenuDiv example
function createMainImageContainer($img, $destination) {
var $container, $table, $menu;
$container = $('<div id="image">');
$table = $('<table class="imageTable"><tr><td align="center"></td></td></table>').appendTo($container);
$menu = $('<div>').attr('id', "removeMainImage")
.addClass("button buttonImage")
.text("Ta bort")
.click(function () { removeMainImage($container, $destination); })
@eldewall
eldewall / gist:1219482
Created September 15, 2011 15:02
jquery hell
function insertElements($obj) {
var $header = $('<div>').addClass("header");
$('<div>').addClass("headerText image")
.append($('<span>').text($obj.options.header))
.appendTo($header);
$('<div>').addClass("headerClose image").click(function () {
$obj.disable();
}).appendTo($header);
@eldewall
eldewall / gist:1241851
Created September 26, 2011 08:26
less stuff
#objectTable {
thead {
th {
&.checkbox { width: 40px; min-width: 40px; }
&.color { text-align: left; padding-left: 20px; }
&.model { width: 200px; }
&.modelraw { width: 200px; }
span {
&.text { height: 50px; line-height: 50px; cursor: pointer; }
@eldewall
eldewall / gist:1241852
Created September 26, 2011 08:27
utan less
#object_table { max-width: 780px; border-spacing: 0; width: 100%; }
#object_table th { min-width: 80px; height: 60px; }
#object_table div { cursor: pointer; margin-left: 15px; margin-right: 15px; text-align: center; }
#object_table th.checkbox { width: 40px; min-width: 40px; }
#object_table td.checkbox input { margin-left: 6px; }
#object_table .checkbox { width: 10px; }
#object_table th.modelraw { width: 200px; }
#object_table th.color { text-align: left; padding-left: 20px; }
#object_table th.model { max-width: 110px; min-width: 110px; }
#object_table thead th { font-weight: normal; font-size: 18px; text-align: center; }
public class ObjectStore {
private static Dictionary<int, SalesObject> _objects = new Dictionary<int, SalesObject>();
public static T GetObject<T>(int contactId) where T : SalesObject {
SalesObject tmpAccessory = null;
_objects.TryGetValue(contactId, out tmpAccessory);
return (T)tmpAccessory;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BBAdmin.Models;
using BBAdmin.DataAccess.DataHandler;
using BBAdmin.DataAccess;
using BBAdmin.Models.ViewModels;
@eldewall
eldewall / gist:1295346
Created October 18, 2011 12:52
std vimrc
set shiftwidth=2
set tabstop=2
set expandtab
set smarttab
set ai
set si
filetype plugin on
filetype indent on
colorscheme vividchalk