Skip to content

Instantly share code, notes, and snippets.

View nberardi's full-sized avatar
😀

Nick Berardi nberardi

😀
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nberardi on github.
  • I am nberardi (https://keybase.io/nberardi) on keybase.
  • I have a public key whose fingerprint is 2404 DB48 5F66 9949 BECB A593 FFE7 811A CF75 F8CE

To claim this, I am signing this object:

@nberardi
nberardi / HomeController.cs
Created March 20, 2014 14:35
Example For Flushing Before Execution for Nik Molnar
public class HomeController : Controller {
public ActionResult Index () {
ViewBag.ExecuteAction = () => {
// do stuff here
return model;
};
return View();
}
}
@TextSearchField("test", "test", true)
@helper TextSearchField(string name, string label, bool autocomplete)
{
<div class="searchCrit">
<label for="@name">@label</label>
@if(autocomplete) {
<input type="text" name="@name" class="autocompleteField" />
}
@nberardi
nberardi / cassandra_test-01.cs
Created November 15, 2011 08:49 — forked from kellabyte/cassandra_test-01.cs
Cassandra Performance Test
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using FluentCassandra;
using FluentCassandra.Types;
namespace CassandraTest1
{
class Program
{
@nberardi
nberardi / Microsoft.PowerShell_profile.ps1
Created May 2, 2012 14:01
Nick Berardi's PowerShell Profile
###############################################################################
# global variables
###############################################################################
$profileDir = [System.IO.Path]::GetDirectoryName($profile)
###############################################################################
# Set up a simple prompt, adding the git prompt parts inside git repos
###############################################################################
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
@nberardi
nberardi / zlip.cs
Created May 12, 2012 15:03
ZLIB compression in .NET
public static byte[] ZlibCompress(byte[] data)
{
using (MemoryStream outStream = new MemoryStream())
{
// zlib header
outStream.WriteByte(0x58);
outStream.WriteByte(0x85);
// zlib body
using (var compressor = new DeflateStream(outStream, CompressionMode.Compress, true))
@nberardi
nberardi / DateTimePrecise.cs
Created September 21, 2012 04:46
A more precise DateTime in .NET
using System;
using System.Diagnostics;
using System.Linq;
namespace System
{
public class DateTimePrecise
{
private static readonly DateTimePrecise Instance = new DateTimePrecise(10);
#r "System.Drawing.dll"
using System.IO;
using System.Drawing;
using System.Net;
var client = new WebClient();
var bytes = client.DownloadData("http://www.hdwallpapersplus.com/wp-content/uploads/2013/05/Funny-Cat-Pictures-cats-935656_500_375.jpg");
var stream = new MemoryStream(bytes);
var image = Image.FromStream(stream);
@nberardi
nberardi / executify.csx
Last active December 20, 2015 22:09
executify.csx
#r "System.Drawing.dll"
/*
* To use a GitHub Gist with Executify, you need to have a
* file named "executify.csx" in your Gist. Then you reference
* the Gist Identity in the Executify URL as
* http://executify.com/gist/{gist_id}
*/
using System.IO;
public unsafe class NSDataStream : UnmanagedMemoryStream
{
public NSDataStream(NSData data)
: base((byte*)data.Bytes, data.Length)
{
_data = data;
}
private readonly NSData _data;