Skip to content

Instantly share code, notes, and snippets.

View jrusbatch's full-sized avatar

Justin Rusbatch jrusbatch

View GitHub Profile
public class ExecuteEndPoint : PersistentConnection {
/// <summary>
/// Handle messages sent by the client.</summary>
protected override Task OnReceivedAsync(string connectionId, string data)
{
var command = new ExecuteCommand
{
ClientId = connectionId,
Code = data
@jrusbatch
jrusbatch / gist:2775538
Created May 23, 2012 14:33
Find all columns in all tables that contain only null or empty strings
declare @tempTable table
(
TableSchema nvarchar(256),
TableName nvarchar(256),
ColumnName sysname,
NotNullCnt bigint
);
declare @sql nvarchar(4000);
declare @tableSchema nvarchar(256);
@jrusbatch
jrusbatch / gist:2931953
Created June 14, 2012 18:24
Crazy Parsing
private static unsafe int ParseFast(string data)
{
int count = 0, valid = 0, pos, stop, temp;
byte[] buffer = new byte[ushort.MaxValue];
const byte Zero = (byte) '0';
const byte Nine = (byte) '9';
const byte Dot = (byte)'.';
const byte Space = (byte)' ';
const byte Tab = (byte) '\t';
@jrusbatch
jrusbatch / gist:3129503
Created July 17, 2012 13:53
Jabber Count
(function(){
var totalPop = 0
, roomPops = $('#userlist-lobby .room .count').text().match(/\d+/g);
for (var i = 0, l = roomPops.length; i < l; i++) {
totalPop += parseInt(roomPops[i]);
}
return totalPop;
})();
@jrusbatch
jrusbatch / gist:3130163
Created July 17, 2012 15:39
Count unique user names in Jabbr
(function($) {
if (typeof Array.prototype.unique !== 'function'){
Array.prototype.unique = function() {
var a = this.concat();
for (var i = 0, l = a.length; i < l; ++i) {
for (var j = i + 1; j < l; ++j) {
if (a[i] === a[j]) {
a.splice(j, 1);
Action x;
x = () => x();
return x();
public interface IHaveState
{
object State { get; }
}
@jrusbatch
jrusbatch / Base36.cs
Created September 2, 2012 21:23
A C# type representing a base-36 encoded 64-bit integer.
using System;
using System.Collections.Generic;
[Serializable]
public struct Base36 : IEquatable<Base36>, IComparable<Base36>
{
private const string Characters = "0123456789abcdefghijklmnopqrstuvwxyz";
public static readonly Base36 MaxValue = new Base36(long.MaxValue);
public static readonly Base36 MinValue = new Base36(long.MinValue + 1);
@@@ // dont' really want external subclasses
internal RedisConnectionBase(string host, int port = 6379, /* ... */)