Skip to content

Instantly share code, notes, and snippets.

@canton7
canton7 / 0main.md
Created September 17, 2012 12:57
Git Bisect and Feature Branches

Git Bisect and Feature Branches

There are people out there who claim that merge-based workflows (that is, workflows which contain non-fast-forward merges) are bad. They claim that git bisect gets confused by merge-based workflows, and instead advocate rebase-based workflows without explicit feature branches.

They're wrong.

Furthermore, the "advantages" of their workflows are in fact disadvantages. Let me show you.

@canton7
canton7 / 0main.md
Last active November 7, 2023 08:16
Local versions of tracked config files

How to have local versions of tracked config files in git

This is a fairly common question, and there isn't a One True Answer.

These are the most common techniques:

If you can modify your application

@canton7
canton7 / TreeViewExtensions.cs
Created July 19, 2019 09:33
TreeViewExtensions
/// <summary>
/// Extensions on TreeViews allowing users to bind to the SelectedItem property
/// </summary>
public static class TreeViewExtensions
{
private static readonly object initialBindingTarget = new object();
public static object GetSelectedItem(DependencyObject obj)
{
return obj.GetValue(SelectedItemProperty);
@canton7
canton7 / Setup.iss
Last active February 1, 2023 21:32
Installing .NET Framework 4.6.1 with Inno Setup
#define DotNetRuntimeExe "NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
[CustomMessages]
InstallingDotNetFramework=Installing .NET Framework. This might take a few minutes...
DotNetFrameworkFailedToLaunch=Failed to launch .NET Framework Installer with error "%1". Please fix the error then run this installer again.
DotNetFrameworkFailed1602=.NET Framework installation was cancelled. This installation can continue, but be aware that this application may not run unless the .NET Framework installation is completed successfully.
DotNetFrameworkFailed1603=A fatal error occurred while installing the .NET Framework. Please fix the error, then run the installer again.
DotNetFrameworkFailed5100=Your computer does not meet the requirements of the .NET Framework. Please consult the documentation.
DotNetFrameworkFailedOther=The .NET Framework installer exited with an unexpected status code "%1". Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this
@canton7
canton7 / gist:1053846
Created June 29, 2011 13:35
git push, tracking, and push.default

git clone path/to/test/repo.git

push.default = matching (the default)

git config push.default matching

git branch -a
   * master
@canton7
canton7 / RSAConverter.cs
Last active July 1, 2022 08:28
C# class to convert OpenSSL private keys into PuTTY'-format private keys. Can't handle encryption or anything else funky
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
// Usage:
public class GlobalKeyboardHook : IDisposable
{
private delegate IntPtr LowLevelKeyboardProc(int nCode, int wParam, IntPtr lParam);
private const int WH_KEYBOARD_LL = 13;
private const int WM_KEYDOWN = 0x0100;
private const int WM_KEYUP = 0x0101;
private const int VK_SHIFT = 0x10;
private const int VK_CONTROL = 0x11;
@canton7
canton7 / ##java takeover.txt
Created June 14, 2021 14:53
##java takeover
14:50 *** @ChanServ has changed the topic to: Welcome to ##java. Freenode community channel for java. Please keep it civil and dont spam or be political.
14:55 <cheeser> the fuck?
14:56 <cheeser> so i guess ##java has officially been hijacked by our new overlords.
14:59 <dreamreal> I wonder what the trigger was.
15:00 <dreamreal> Did they notify you at all?
15:02 <cheeser> not at all
15:03 <cheeser> so for the rest of you still here good luck. if you want something active, we're all at libera.
15:04 <dreamreal> Java has been taken over by freenode staff, given that they weren't acting as if they deserved to be trusted, and then acted upon that distrust. The old ops have set up shop in #java on libera.chat. If you want, join us there. if not, cool beans.
15:05 <@sorcerer> actually you guys failed to deal with spam thats what brought me here
15:06 <Maldivia> considering there has been no spam here, that's rich
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
public static class ReactiveExtensionsExtensions
{
public static async Task SubscribeAsync<T>(this IObservable<T> observable, Action<T> onNext, CancellationToken? cancellationToken = null)
{
CancellationToken token = cancellationToken ?? CancellationToken.None;
var cts = new TaskCompletionSource<bool>();
using(token.Register(() => cts.SetCanceled()))
{
observable.Subscribe(onNext, ex => cts.SetException(ex), () => cts.SetResult(true), token);
await cts.Task;