Skip to content

Instantly share code, notes, and snippets.

@automatonic
automatonic / UriTemplateTableWildcardPrecedence.cs
Created September 9, 2015 21:18
Some tests to investigate the precedence/priority of UriTemplate wildcards in a UriTemplateTable for C#
var baseUri = new Uri("foo://testy");
//Test1 - "*"
var templates1 = new Dictionary<UriTemplate, object>()
{
{ new UriTemplate("*") , "[star]" },
};
var templateTable1 = new UriTemplateTable(baseUri, templates1);
templateTable1
@davideicardi
davideicardi / kuduSiteUpload.ps1
Last active July 29, 2022 01:43
Upload a local directory to an Azure Website using kudu and powershell
Param(
[Parameter(Mandatory = $true)]
[string]$websiteName,
[Parameter(Mandatory = $true)]
[string]$sourceDir,
[string]$destinationPath = "/site/wwwroot"
)
# Usage: .\kuduSiteUpload.ps1 -websiteName mySite -sourceDir C:\Temp\mydir
@automatonic
automatonic / ValidateXmlWithXsd.cs
Last active July 29, 2020 12:01
Programmatically validate an XML document with an XSD (XML Schema)
//License: MIT
//using System.Xml;
//using System.Xml.Schema;
public static List<ValidationEventArgs> ValidateXmlWithXsd(string xmlPath, string xsdPath)
{
XmlSchemaSet s = new XmlSchemaSet();
var args = new List<ValidationEventArgs>();
using (XmlReader reader = XmlReader.Create(xsdPath))
{
//These validations will be from reading the xsd itself
@mkchandler
mkchandler / DisableNuGetPackageRestore.ps1
Last active February 13, 2018 04:07
Disable the NuGet Package Restore functionality in a Visual Studio solution.
# Usage: .\DisableNuGetPackageRestore.ps1 C:\Path\To\Solution.sln
# Get the path that the user specified when calling the script
$solution = $args[0]
$solutionPath = Split-Path $solution -Parent
$solutionName = Split-Path $solution -Leaf
# Delete the .nuget directory and all contents
Remove-Item (Join-Path $solutionPath ".nuget") -Force -Recurse -ErrorAction 0
@gerrited
gerrited / GetHashCode32.cs
Last active November 7, 2017 02:48
Microsoft messed up the 64 bit version of GetHashCode. This is a platform independent port of the 32 bit version of Object.GetHashCode based on the unsafe code of Yoni Toledano on StackOverflow (http://stackoverflow.com/a/835571/2132050)
public static class StringExt
{
public static int GetHashCode32(this string s)
{
var chars = s.ToCharArray();
var lastCharInd = chars.Length - 1;
var num1 = 0x15051505;
var num2 = num1;
var ind = 0;
while (ind <= lastCharInd)
@anaisbetts
anaisbetts / FilesystemWatchCache.cs
Created May 8, 2013 22:14
An Rx-friendly Filesystem Watcher
using System;
using System.IO;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
namespace SaveAllTheTime.Models
{
interface IFilesystemWatchCache
{
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@tuzz
tuzz / github.css
Last active May 8, 2024 00:48
Github Markdown Stylesheet
/*
Copyright (c) 2017 Chris Patuzzo
https://twitter.com/chrispatuzzo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kamranayub
kamranayub / Transforms.xml
Created February 26, 2012 18:02
MSBuild Inline Task to Transform a Hierarchy of XML Files using XDT Transforms
<!-- This task takes in a XDT transform file and transforms it, following any inheritance chain.
There should be at least one base transform for this to work; otherwise just use Microsoft's
regular TransformXml task. -->
<!-- EXAMPLE USAGE:
<TransformXmlHierarchy
Source="source.xml"
Destination="transformed.xml"
TaskDirectory="path/to/directory/of/Microsoft.Web.Publishing.Tasks" />
-->
<UsingTask
@qwertie
qwertie / ValueConverters.cs
Created January 20, 2012 18:21
ValueConverter + MarkupExtension in one
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Markup;
using System.Globalization;
using System.Windows.Data;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;