Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Diagnostics;
namespace JsEnginePerformanceComparison
{
class Program
{
static void Main()
{
var done = false;
@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
@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 / IsPalindrome.cs
Created August 21, 2014 17:36
Check if a string is a palindrome - popular interview question!
class Program
{
static void Main(string[] args)
{
const string mom = "mom";
const string mother = "mother";
const int iterations = 10000;
var sw = new Stopwatch();
sw.Start();
@rushfrisby
rushfrisby / StartAzureStorageEmulator.cs
Last active August 29, 2015 14:10
Starts the Azure Storage Emulator if it is not running. Useful for running unit tests on a build server.
private async Task StartAzureStorageEmulator()
{
if (!Settings.Default.StartAzureStorageEmulator)
return;
try
{
var storageAccount = CloudStorageAccount.Parse(Settings.Default.AzureStorageConnectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("test");
@rushfrisby
rushfrisby / ruleplex_switch_pattern_example.cs
Created February 4, 2015 01:11
RulePlex Switch Pattern Example
switch(policy.LanguageType)
{
case LanguageTypes.CSharp:
// process c# rules
break;
case LanguageTypes.Python:
//process python rules
break;
@rushfrisby
rushfrisby / strategy_pattern.cs
Last active August 29, 2015 14:14
RulePlex Strategy Pattern Example
//do this once and cache it
var ruleEngineTypes = new Dictionary<LanguageTypes, Type>();
ruleEngineTypes.Add(LanguageTypes.CSharp, typeof(CSharpRuleEngine));
ruleEngineTypes.Add(LanguageTypes.Python, typeof(PythonRuleEngine));
ruleEngineTypes.Add(LanguageTypes.JavaScript, typeof(JavaScriptRuleEngine));
//switch turns into this...
var ruleEngineType = ruleEngineTypes[policy.LanguageType];
var engine = (IRuleEngine)Activator.CreateInstance(ruleEngineType);
engine.Execute(plan);
@rushfrisby
rushfrisby / ruleplex_heartbeat.js
Last active August 29, 2015 14:16
RulePlex JavaScript Rule "Compiled"
function ExecuteRules(data)
{
(function Rule004596ed979540878bc366521663501d(data)
{
var sw004596ed979540878bc366521663501d = new Stopwatch();
sw004596ed979540878bc366521663501d.Start();
var result004596ed979540878bc366521663501d = new Result();
result004596ed979540878bc366521663501d.RuleId = Guid.Parse("004596ed-9795-4087-8bc3-66521663501d");
## Macro title: HTML5 Video
## Macro has a body: N
##
## Output: HTML
##
## Developed by: David Simpson <[email protected]>
## Date created: dd/mm/yyyy
## Installed by: My Name
##
## @param width:title=Width|type=string|required=false|desc=Video width
## Macro title: HTML5 Video
## Macro has a body: N
##
## Output: HTML
##
## Developed by: David Simpson <[email protected]>
## Date created: dd/mm/yyyy
## Installed by: My Name
##
## @param width:title=Width|type=string|required=false|desc=Video width