This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
using System.Drawing.Drawing2D; | |
using System.Drawing.Imaging; | |
using System.IO; | |
public static class ImageUtil | |
{ | |
public static Image Resize(this Image image, int width, int height) | |
{ | |
var destRect = new Rectangle(0, 0, width, height); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 Giacomo Stelluti Scala. All rights reserved. See doc/License.md in the project root for license information. | |
package process | |
/* | |
#include <stdlib.h> | |
#include "libproc.h" | |
*/ | |
import "C" | |
import "unsafe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract BubbleSort { | |
function sort(uint[] memory array) public pure returns (uint[] memory) { | |
bool swapped; | |
for (uint i = 1; i < array.length; i++) { | |
swapped = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ tsc factorial.ts && node factorial.js | |
// 3628800 | |
function factorial(num: number) : number { | |
if (num == 0) return 1 | |
else return num * factorial(num - 1) | |
} | |
console.log(factorial(10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using SharpX.Extensions; | |
static class EnumerableExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> Partition<T, TKey>(this IEnumerable<T> source, Func<T, TKey> selector) | |
{ | |
var result = new List<IEnumerable<T>>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires Microsoft.IdentityModel.Clients.ActiveDirectory 5.29 | |
// Microsoft.Azure.Management.ResourceManager 3.15.1-preview | |
using System; | |
using System.Collections.Generic; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.Management.ResourceManager; | |
using Microsoft.Azure.Management.ResourceManager.Models; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
static class Guard | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void AgainstNull(string argumentName, object value) | |
{ | |
if (value == null) throw new ArgumentNullException(argumentName, $"{argumentName} cannot be null."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
public class YourClass | |
{ | |
[JsonProperty("type")] | |
[JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(LowerCaseNamingStrategy))] | |
public YourEnum YourProperty { get; set; } | |
} | |
*/ | |
using Newtonsoft.Json.Serialization; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
sealed class ConsoleEx | |
{ | |
public void Write(ConsoleColor color, string format, params object[] arg) | |
{ | |
var current = Console.ForegroundColor; | |
Console.ForegroundColor = color; | |
Console.Write(format, arg); | |
Console.ForegroundColor = current; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Require-AzCliVersion { | |
[OutputType([void])] | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] [ValidatePattern("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,9}$")] [string] $Version, | |
[switch] $Fail | |
) | |
$actual = ('az version' | Invoke-Expression | ConvertFrom-Json).'azure-cli' | |
if ($actual -eq $Version) { | |
"Azure CLI present in pinned version $Version" | Write-Verbose | |
} else { |
NewerOlder