Skip to content

Instantly share code, notes, and snippets.

View jrusbatch's full-sized avatar

Justin Rusbatch jrusbatch

View GitHub Profile
public IEnumerable<T> ConquerFile<T>(Stream stream)
{
using (var reader = new PeekableTextReader(stream))
{
// find how big of an army we need
var conscriptInfo = _contextSurvey.AllOfTheLands<T>(reader);
// marshal the troops
var formation = _fileHelpersTypeDrafter.BuildPhalanx<T>(conscriptInfo);
@jrusbatch
jrusbatch / job.cs
Last active August 29, 2015 14:08 — forked from clairernovotny/job.cs
internal class Job : IDisposable
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
static extern IntPtr CreateJobObject(IntPtr a, string lpName);
[DllImport("kernel32.dll")]
static extern bool SetInformationJobObject(IntPtr hJob, JobObjectInfoType infoType, IntPtr lpJobObjectInfo, UInt32 cbJobObjectInfoLength);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
#!/usr/bin/env bash
if [ ! -d ".git" ]; then
echo "Directory is not a repository."
exit 1
fi
if [ ! -f ".gitattributes" ] && [ -f "../gitattributes" ]; then
cp ../gitattributes .gitattributes && git add .gitattributes && git commit -m "Create .gitattributes"
git rm -r --cached .
@echo Off
:: If an existing file is specified, open that file. Otherwise, search the
:: current directory for a solution file to open. If a solution file is not
:: found, don't do anything.
@set VS_LAUNCHER="%PROGRAMFILES(X86)%\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe"
@set VS_PATH="%PROGRAMFILES(X86)%\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe"
@set TARGET="%1"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
public class Mario
{
public void Win()
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
public static void Win()
{
Console.Beep(659, 125);
Console.Beep(659, 125);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
public static void Win()
{
Console.Beep(659, 125);
Console.Beep(659, 125);

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

public static Task<BrokeredMessage> OnMessageAsyncWrapper(CancellationToken cancellationToken = default(CancellationToken))
{
var tcs = new TaskCompletionSource<BrokeredMessage>();
try
{
if (cancellationToken.IsCancellationRequested)
{
tcs.SetCanceled();
return tcs.Task;
}
### Keybase proof
I hereby claim:
* I am jrusbatch on github.
* I am jrusbatch (https://keybase.io/jrusbatch) on keybase.
* I have a public key whose fingerprint is 5761 701E 5034 D7F1 3808 CA1D C759 FEAD ED2E 3488
To claim this, I am signing this object: