Skip to content

Instantly share code, notes, and snippets.

@SteveSandersonMS
SteveSandersonMS / ITab.cs
Created November 15, 2018 11:33
Blazor tab example
using Microsoft.AspNetCore.Blazor;
public interface ITab
{
RenderFragment ChildContent { get; }
}
@danielcrenna
danielcrenna / PackagePrep.csproj
Last active November 21, 2019 17:10 — forked from attilah/X.Y.Z.Sources.csproj
X.Y.Z.Sources nuget package (with pre-processor transformations support)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
</Project>
@georgiosd
georgiosd / BlockingCollectionExtensions.cs
Last active October 31, 2018 22:09
Throttle items consumed from a BlockingCollection<T>
// Copyright (c) Georgios Diamantopoulos. All rights reserved.
// Licensed under the MIT license. See LICENSE in this gist for full license information.
// The Throttle class is the RateGate class published here http://www.jackleitch.com/2010/10/better-rate-limiting-with-dot-net/, renamed and copied for convenience.
public static class BlockingCollectionExtensions
{
// TODO: devise a way to avoid problems if collection gets too big (produced faster than consumed)
public static IObservable<T> AsRateLimitedObservable<T>(this BlockingCollection<T> sequence, int items, TimeSpan timePeriod, CancellationToken producerToken)
{
Subject<T> subject = new Subject<T>();
@JonCanning
JonCanning / update.ps1
Last active May 12, 2020 21:15
dotnet nuget update packages
$regex = [regex] 'PackageReference Include="([^"]*)" Version="([^"]*)"'
ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*proj"})
{
$proj = $file.fullname
$content = Get-Content $proj
$match = $regex.Match($content)
if ($match.Success) {
$name = $match.Groups[1].Value
$version = $match.Groups[2].Value
if ($version -notin "-") {
@DevinWalker
DevinWalker / Beanstalk_to_GitHub
Created October 9, 2015 17:19
Move Git Repository from Beanstalk to GitHub with full repository history
#Example moving the DPSG Global Library
# 1 Checkout the Beanstalk Repo
git clone --bare git@codeandtheory.beanstalkapp.com:/dpsg-global-library.git
# 2 Push into your desired GitHub repo. (Please note that you must create the github repo prior to this step)
git push --mirror git@github.com:codeandtheory/dpsg-global-library.git
@steveklabnik
steveklabnik / shallow-vs-deep.html
Created December 14, 2011 21:29 — forked from jonm/shallow-vs-deep.html
Shallow vs. deep representations in XHTML Hypermedia APIs
<html>
<body>
<!-- the following div is a sample representation of a 'car' domain object; it can be identified as
such by the presence of 'car' in its @class. In this case, the car has two attributes, a make
and a model, and both are included right here. This is what I call a deep/complete/concrete
representation. -->
<div id="car123" class="car">
<span class="make">Ford</span>
<span class="model">Mustang</span>
</div>
@kylefox
kylefox / liquid-mode.js
Created November 11, 2011 00:02
Liquid syntax highlighting for CodeMirror.
/*
This overlay provides a 'liquid' mode to the excellent CodeMirror editor (http://codemirror.net/).
Add something like this to your CSS:
.cm-liquid-tag {
color: #32273f;
background: #ead9ff;
}
.cm-liquid-variable {
@andrewgleave
andrewgleave / iOSMapKitFitAnnotations.m
Last active November 4, 2022 15:21
Zooms out a MKMapView to enclose all its annotations (inc. current location)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}
@mafis
mafis / UINavigationBar Custom Control.cs
Created March 27, 2011 19:47
UINavigationBar Custom Control
using System;
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.Foundation;
namespace CustomControls
{
[MonoTouch.Foundation.Register("CustomNavigationBar")]
public class CustomNavigationBar : UINavigationBar
{