Skip to content

Instantly share code, notes, and snippets.

@eouw0o83hf
eouw0o83hf / CrazyCaseTestExtensions.cs
Created July 29, 2019 18:28
CrAzYcAsE test extensions
using System;
using System.Linq;
using Xunit;
namespace Example.Tests
{
public static class TestExtensions
{
public static string ToCrAzYcAsE(this string input)
=> input
@eouw0o83hf
eouw0o83hf / UploadController.cs
Created August 23, 2018 02:24
File upload with React component and dotnet core web API controller
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Demo.Web.Controllers
{
public class UploadController : Controller
{
@eouw0o83hf
eouw0o83hf / Change.cs
Created August 13, 2018 14:20
Change: A C# handler for null-safe change handling
using System;
using Newtonsoft.Json;
namespace eouw0o83hf.Gist.Change
{
/// <summary>
/// A lightweight wrapper which tracks a change to a property
/// and serializes to one json property for ease of reading in
/// an event stream.
/// </summary>
@eouw0o83hf
eouw0o83hf / listAllFields.js
Last active July 21, 2018 13:03
Javascript to list all fields of an object and types of their instances
function listAllFields(target) {
var allFields = Object
.entries(targetObject)
.map(a => `${a[0]}: ${typeof(a[1])}`)
.join(', ');
console.log(allFields);
}
@eouw0o83hf
eouw0o83hf / TasksInParallel.linq
Created June 21, 2016 14:02
Tasks in Serial and Parallel
async void Main()
{
var serialData = await ConvertSerially();
var parallelData = await ConvertParallelly();
}
async Task<ICollection<string>> ConvertSerially()
{
var convertedList = new List<string>();
var stopwatch = Stopwatch.StartNew();
private Guid LazyG(char a)
{
var sb = new StringBuilder();
for (var i = 0; i < 32; i++)
{
sb.Append(a);
}
return new Guid(sb.ToString());
}
@eouw0o83hf
eouw0o83hf / bitbucket-prs.htm
Last active December 6, 2015 06:36
Web page to pull all PRs from all Bitbucket repos you have access to
<html>
<head>
<title>
PRs
</title>
<style>
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margi
@eouw0o83hf
eouw0o83hf / some.cs
Last active October 20, 2015 15:29
GetSome(): A Scala-inspired C# IEnumerable Extension
public static class Extensions
{
/// <summary>
/// Grants the ability to peek into an IEnumerable and determine if some
/// (n > 0) items are in the collection *without multiply-enumerating it*
/// </summary>
public static ISomeEnumerable<T> GetSome<T>(this IEnumerable<T> source)
{
return new RepeatableEnumerableWrapper<T>(source);
}
@eouw0o83hf
eouw0o83hf / jQueryception.js
Created March 27, 2015 06:33
Tampermonkey: Inject jQuery and Do Something With It
// Gets called when jQuery is all loaded and ready to go.
// Use jq instead of $ here. For instance,
// jq("div") or jq.get("targeturl");
function runWith(jq) {
// Do cool stuff here
}
// Get jquery, copied this from here http://blog.reybango.com/2010/09/02/how-to-easily-inject-jquery-into-any-web-page/
// with some minor modifications to do a callback whenever jQuery is either detected as having already
// been loaded or is done loading.
@eouw0o83hf
eouw0o83hf / gist:7dfa97a5e08d245d0538
Last active August 29, 2015 14:13
Throttle Helper
public class Throttle
{
private Task _control;
private readonly int _minimumMillis;
public Throttle(int millis)
{
_minimumMillis = millis;
}