Skip to content

Instantly share code, notes, and snippets.

View rofr's full-sized avatar

Robert Friberg rofr

View GitHub Profile
public abstract class StreamCompressor : ICompressor
{
protected abstract Stream CreateStream(Stream inputStream, CompressionMode compressionMode);
public byte[] Compress(byte[] data)
{
var inputStream = new MemoryStream(data, writable:false);
var outputStream = new MemoryStream(data.Length);
var compressionStream = CreateStream(outputStream, CompressionMode.Compress);
inputStream.CopyTo(compressionStream);
@rofr
rofr / livedb_test.pl
Created February 7, 2013 15:11
LiveDomain Proxy with perl, step 1, intercept method calls and invoke on wrapped model.
package LiveDomain::Proxy;
sub new()
{
my ($package,$system) = @_;
return bless {system => $system};
}
sub AUTOLOAD
{
@rofr
rofr / gist:4961001
Created February 15, 2013 15:19
Here's one way to represent the hexagonal regex crossword puzzle, using Perl
# list of letters
my @letters = qw(a b c d e);
#each regex is associated with a list of indicies into the list of letters
my @puzzle =
(
['.*g.*v.*h.*' => [0..6]],
['[cr]*' => [7..14]],
['.*xexm*' => [15..23]],
['.*dd.*ccm.*' => [24..33]],
@rofr
rofr / Puzzle.cs
Created February 15, 2013 15:25
And here's using C# for a matrix based (not hexagonal) regex crossword puzzle
[Serializable]
public class Puzzle
{
public string Author{ get; set; }
public DateTime Created{ get; set; }
public string[] Rows{ get; set; }
public string[] Cols { get; set; }
public String[] RowConstraints { get; set; }
public String[] ColumnConstraints { get; set; }
@rofr
rofr / gist:5055827
Created February 28, 2013 10:40
Validation Nuget package install fails on VS2012
PM> install-package validation
Successfully installed 'Validation 2.0.2.13022'.
Successfully uninstalled 'Validation 2.0.2.13022'.
Install failed. Rolling back...
Install-Package : Could not install package 'Validation 2.0.2.13022'. You are trying to install this package into a
project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references that are
compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ install-package <<<< validation
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
<html>
<head>
<link
href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css"
rel="stylesheet" />
</head>
<body>
</body>
</html>
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar"
data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Lizzy</a>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
<div class="list-title">
<input class="title" value="Techs demonstrated">
</div>
<div id="list-items-container" style="padding-top:20px;padding-bottom:10px;">
<ul class="list" id="sortable" style="padding-top:4px">
<li id="1"><input class="list-item" value="jQuery"></li>
<li id="2"><input class="list-item" value="Bootstrap"></li>
<li id="3"><input class="list-item" value="OrigoDB"></li>
<li id="4"><input class="list-item" value="ASP.NET MVC"></li>
</ul>
@rofr
rofr / gist:5250761
Last active December 15, 2015 11:09
$(function(){
// ----------------------------------------------------------------------------------------------
// set up drag and drop reordering using jquery-ui sortable function
// ----------------------------------------------------------------------------------------------
$("#sortable").sortable(
{
axis:'y',
containment:'#list-items-container',
handle:'.drag-handle'
}