Skip to content

Instantly share code, notes, and snippets.

@rushfrisby
rushfrisby / bootstrap-wrapper.less
Created March 20, 2015 03:32
Bootstrap hack for wordpress admin panel - load with wrapper using less
.bootstrap-wrapper {
@import (less) url('bootstrap.min.css');
}
@rushfrisby
rushfrisby / bootstrap-hack.js
Created March 20, 2015 03:28
Bootstrap hack for wordpress admin
var bootstrapCss = 'bootstrapCss';
if (!document.getElementById(bootstrapCss))
{
var head = document.getElementsByTagName('head')[0];
var bootstrapWrapper = document.createElement('link');
bootstrapWrapper.id = bootstrapCss;
bootstrapWrapper.rel = 'stylesheet/less';
bootstrapWrapper.type = 'text/css';
bootstrapWrapper.href = '../wp-content/plugins/myplugin/css/bootstrap-wrapper.less';
bootstrapWrapper.media = 'all';
@rushfrisby
rushfrisby / html5-video-user-macro.vm
Last active August 29, 2015 14:16 — forked from dvdsmpsn/html5-video-user-macro.vm
HTML 5 Video user macro for Confluence / updated based on user comments of original
## Macro title: HTML5 Video
## Macro has a body: N
##
## Output: HTML
##
## Developed by: David Simpson <david@davidsimpson.me>
## 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 <david@davidsimpson.me>
## 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 <david@davidsimpson.me>
## Date created: dd/mm/yyyy
## Installed by: My Name
##
## @param width:title=Width|type=string|required=false|desc=Video width
@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");
@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_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 / 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 / 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();