Skip to content

Instantly share code, notes, and snippets.

@davecowart
davecowart / SelectExtensions.cs
Created March 22, 2011 18:34
DropDown source code
namespace System.Web.Mvc.Html {
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc.Resources;
@sintaxi
sintaxi / application.js
Created April 21, 2011 21:00
simple chat client using redis pub/sub
var q= function(s){ return document.getElementById(s) }
function send(){
var input = q('text');
socket.send(input.value);
input.value = '';
}
var socket = new io.Socket(null, {
port: 8001,
@huobazi
huobazi / CRUD_SP_Generation.sql
Created June 2, 2011 04:40 — forked from adamcarr/CRUD_SP_Generation.sql
Generate CRUD stored procedures from tables in schema
-- #########################################################
-- Author: www.sqlbook.com
-- Copyright: (c) www.sqlbook.com. You are free to use and redistribute
-- this script as long as this comments section with the
-- author and copyright details are not altered.
-- Purpose: For a specified user defined table (or all user defined
-- tables) in the database this script generates 4 Stored
-- Procedure definitions with different Procedure name
-- suffixes:
-- 1) List all records in the table (suffix of _GetAll)
@rally25rs
rally25rs / HtmlHelperDisplayNameExtensions.cs
Created November 20, 2011 03:29
Extension methods for ASP.NET MVC3 that provide helpers for getting display names from IEnumerable models.
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
namespace Web.Extensions
{
public static class HtmlHelperDisplayNameExtensions
{
/// <summary>
@phillip-haydon
phillip-haydon / Blobbed.cs
Created February 28, 2012 23:35
NHibernate Custom User Type for serializing a property to JSON
[Serializable]
public class Blobbed<T> : IUserType where T : class
{
public new bool Equals(object x, object y)
{
if (x == null && y == null)
return true;
if (x == null || y == null)
return false;
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ilake
ilake / gist:3658755
Created September 6, 2012 17:25
fileuploader-custom.js
/**
* http://github.com/Valums-File-Uploader/file-uploader
*
* Multiple file upload component with progress-bar, drag-and-drop.
*
* Have ideas for improving this JS for the general community?
* Submit your changes at: https://github.com/Valums-File-Uploader/file-uploader
*
* VERSION 2.0 beta
* Original version 1.0 © 2010 Andrew Valums ( andrew(at)valums.com )
@plaurin
plaurin / SelfCompile
Created October 7, 2012 21:00
Self Compiling LinqPad query
void Main()
{
Environment.CurrentDirectory = Path.GetDirectoryName(Util.CurrentQueryPath);
Compiler.CompileFiles(Options.CreateOnDiskDll(
@namespace: "LinqPad.QueriesCompiler",
outputFile: "LinqPad.QueriesCompiler.dll")
.AddCodeFile(CodeType.LinqProgramTypes, Util.CurrentQueryPath))
.Dump("Successfully created assembly at " + DateTime.Now.ToLocalTime());
}
@jmhdez
jmhdez / DuckType.cs
Created December 8, 2012 10:46
Duck Typing con C#
// Required libs
// - NUnit
// - Castle.DynamicProxy
using System;
using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;
using NUnit.Framework;
@seutje
seutje / jquery.events.js
Created January 21, 2013 16:26
attempt at mapping jQuery.fn.on to old jQuery versions (namely 1.4.4)
(function(){
var rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/,
core_rnotwhite = /\S+/g,
whitespace = "[\\x20\\t\\r\\n\\f]",
core_deletedIds = [],
core_slice = core_deletedIds.slice,
core_version = "@VERSION";