Skip to content

Instantly share code, notes, and snippets.

@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 <[email protected]>
## Date created: dd/mm/yyyy
## Installed by: My Name
##
## @param width:title=Width|type=string|required=false|desc=Video width
@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 / 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 / plugin-page.php
Created March 20, 2015 03:36
Bootstrap wrapper html example
<div class="bootstrap-wrapper">
<button class="btn btn-primary">Click me</button>
</div>
@rushfrisby
rushfrisby / MyNameValueInfoSurrogate.cs
Last active May 26, 2021 15:27
Example surrogate class for protobuf-net
[DataContract]
public class MyNameValueInfoSurrogate
{
//string is serializable so we'll just copy this property back and forth
[DataMember(Order = 1)]
public string Name { get; set; }
//byte[] is serializable so we'll need to convert object to byte[] and back again
[DataMember(Order = 2)]
public byte[] Value { get; set; }
@rushfrisby
rushfrisby / MyNameValueInfo.cs
Created April 2, 2015 05:04
Example class that cant be serialized by protobuf-net
[DataContract]
public class MyNameValueInfo
{
[DataMember(Order = 1)]
public string Name { get; set; }
[DataMember(Order = 2)]
public object Value { get; set; }
}
@rushfrisby
rushfrisby / Surrogate.cs
Last active August 29, 2015 14:21
Surrogate example question
class Parent {
DateTime CreatedOn {get;set;}
}
class DateTimeSurrogate {
long Value {get;set;}
}
//will other system need to mimic above structure or can other system deserialize as
@rushfrisby
rushfrisby / linq.js
Created June 10, 2015 13:16
linq.js with the addition of CRUD methods
/*--------------------------------------------------------------------------
* linq.js - LINQ for JavaScript
* ver 2.2.0.2 (Jan. 21th, 2011)
*
* created and maintained by neuecc <[email protected]>
* licensed under Microsoft Public License(Ms-PL)
* http://neue.cc/
* http://linqjs.codeplex.com/
*--------------------------------------------------------------------------*/
@rushfrisby
rushfrisby / bad_code.cs
Created June 15, 2015 19:53
Intentionally bad code...
public interface IUserService
{
User GetUser(string userName);
}
public static class UserService : IUserService
{
public User GetUser(string userName)
{
using(var context = new SomeDbContext())
@rushfrisby
rushfrisby / KeyLocker.cs
Created June 30, 2015 15:34
Class that locks on objects in a dictionary by key.
public class KeyLocker : IDisposable
{
private static readonly ConcurrentDictionary<object, object> Locks = new ConcurrentDictionary<object, object>();
private readonly object _locker;
public KeyLocker(object key)
{
_locker = Locks.GetOrAdd(key, new object());
Monitor.Enter(_locker);
}