Skip to content

Instantly share code, notes, and snippets.

@dannycabrera
dannycabrera / Log.cs
Created March 24, 2017 19:10
NSLog workaround for Xamarin Console.WriteLine bug
const string FoundationLibrary = "/System/Library/Frameworks/Foundation.framework/Foundation";
[System.Runtime.InteropServices.DllImport(FoundationLibrary)]
extern static void NSLog(IntPtr format, IntPtr s);
[System.Runtime.InteropServices.DllImport(FoundationLibrary, EntryPoint = "NSLog")]
extern static void NSLog_ARM64(IntPtr format, IntPtr p2, IntPtr p3, IntPtr p4, IntPtr p5, IntPtr p6, IntPtr p7, IntPtr p8, IntPtr s);
static readonly bool Is64Bit = IntPtr.Size == 8;
static readonly bool IsDevice = ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.DEVICE;
@robfe
robfe / Hubs.tt
Last active March 18, 2020 16:17
T4 template that creates Typescript type definitions for all your Signalr hubs. If you have C# interface named "I<hubName>Client", a TS interface will be generated for the hub's client too.If you turn on XML documentation in your build, XMLDoc comments will be picked up.Licensed with http://www.apache.org/licenses/LICENSE-2.0
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".d.ts" #>
<# /* Update this line to match your version of SignalR */ #>
<#@ assembly name="$(SolutionDir)\packages\Microsoft.AspNet.SignalR.Core.2.2.0\lib\net45\Microsoft.AspNet.SignalR.Core.dll" #>
<# /* Load the current project's DLL to make sure the DefaultHubManager can find things */ #>
<#@ assembly name="$(TargetPath)" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Web" #>
<#@ assembly name="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ assembly name="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
@joelverhagen
joelverhagen / Program.cs
Created February 13, 2018 19:06
NuGet API, get download count per version
// All you need is the NuGet.Protocol package from NuGet.org.
using System;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
namespace ConsoleApp1
{
@RolandPheasant
RolandPheasant / EnsureUniqueChanges.cs
Last active October 7, 2020 17:56
Unique changes
public static class ChangeSetEx
{
public static IObservable<IChangeSet<TObject, TKey>> EnsureUniqueChanges<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source)
{
return source.Select(EnsureUniqueChanges);
}
public static IChangeSet<TObject, TKey> EnsureUniqueChanges<TObject, TKey>(this IChangeSet<TObject, TKey> input)
{
var changes = input
@gluck
gluck / FromEventBenchmark.cs
Last active October 15, 2021 09:03
Benchmark showing performance increase using FromEvent with conversion over FromEventPattern, using BenchmarkDotNet library
[BenchmarkTask(platform: BenchmarkPlatform.X86, jitVersion: BenchmarkJitVersion.LegacyJit)]
[BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
[BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
public class FromEventBenchmark
{
readonly Control control = new Control();
[Benchmark]
public void FromEventPattern()
{
Observable.FromEventPattern<EventHandler, EventArgs>(h => control.SizeChanged += h, h => control.SizeChanged -= h).Select(p => p.EventArgs)
@xiaomi7732
xiaomi7732 / PolymorphicSerialization.md
Last active January 6, 2023 22:58
How do I leverage .NET 7 Polymorphic Serialization when building Roshambo API

How did I leverage .NET 7 Polymorphic Serialization when building Roshambo API

Brief about the Roshambo project

It is a simple rock, paper, and scissors game used to study how to build a full RESTful API. You will be able to find the latest code in this repo. BTW, if you like it, give it a star.

To make it fun, I also released a live client at https://roshambo.codewithsaar.com.

The feature I want to build

@praeclarum
praeclarum / mactestflight.yaml
Created January 5, 2023 19:22
GitHub Actions to build a Mac AppStore app
- name: Import Apple Certificate
uses: apple-actions/import-codesign-certs@v1
with:
create-keychain: true
keychain-password: ${{ secrets.APPSTORE_CERTIFICATE_P12_PASSWORD }}
p12-file-base64: ${{ secrets.APPSTORE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPSTORE_CERTIFICATE_P12_PASSWORD }}
- name: Import Mac Installer Certificate
uses: apple-actions/import-codesign-certs@v1
@agungf
agungf / gist:8803512
Created February 4, 2014 13:25
Remove passphrase (password) from private RSA key
Should also work for:
[v] any OpenSSH installation
Given, your key is in id_rsa
1
Passphrase is needed?
Try some host which has your public key (id_rsa.pub)
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active March 27, 2024 10:02
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"