Skip to content

Instantly share code, notes, and snippets.

@rushfrisby
rushfrisby / stopwatch.js
Last active April 7, 2022 13:28
Stopwatch class in JavaScript
function Stopwatch()
{
var sw = this;
var start = null;
var stop = null;
var isRunning = false;
sw.__defineGetter__("ElapsedMilliseconds", function()
{
return (isRunning ? new Date() : stop) - start;
@rushfrisby
rushfrisby / pclbreakage.cs
Created August 3, 2014 15:49
PCL breaks in roslyn
using AutoMapper;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.IO;
using System.Text;
namespace PclBreakage
{
class Program
using System;
using System.Diagnostics;
namespace JsEnginePerformanceComparison
{
class Program
{
static void Main()
{
var done = false;
@rushfrisby
rushfrisby / arraytests.js
Created August 2, 2014 06:49
JavaScript Array Tests
var ret = [], tmp, num = 500, i = 1024;
for ( var j1 = 0; j1 < i * 15; j1++ ) {
ret = [];
ret.length = i;
}
for ( var j2 = 0; j2 < i * 10; j2++ ) {
ret = new Array(i);
}
@rushfrisby
rushfrisby / JsonSchemaToPocos.cs
Last active June 2, 2023 07:45
Converts a JSON schema to C# POCO classes
class Program
{
private const string Cyrillic = "Cyrillic";
private const string Nullable = "?";
static void Main()
{
string schemaText;
using (var r = new StreamReader("schema.txt"))
@rushfrisby
rushfrisby / PagedResultSet.cs
Created July 2, 2014 17:06
PagedResultSet used for paging
public class PagedResultSet<T>
{
private int _endRecord;
private int _startRecord;
public PagedResultSet()
{
PageResults = new List<T>();
TotalRecords = 0;
StartRecord = 0;
@rushfrisby
rushfrisby / FilterCriteria.cs
Created July 2, 2014 17:04
FilterCriteria used for paging
public class FilterCriteria
{
public int Skip { get; set; }
public int Take { get; set; }
}
<#@ template language="C#" debug="true" hostspecific="True" #>
<#@ output extension=".cs"#>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Text.RegularExpressions" #>
@rushfrisby
rushfrisby / REST API Contract Spec.js
Last active August 29, 2015 14:02
REST API Contract Spec
{
BasePath: "http://www.domain.com/", //the url of your application's root
Version: 1.0,
Types: [{ //includes custom types and not built-in types like "string". Generics supported.
Name: "NameOfType",
Properties: [{
"NameOfProperty": "TypeOfProperty"
}]
}],
Methods: [{
using System;
using System.Security.Cryptography;
using System.Text;
public static class Crypto
{
#region MD5
public static string HashMD5(string phrase)
{