Skip to content

Instantly share code, notes, and snippets.

View vbfox's full-sized avatar
❄️
Winter is coming

Julien Roncaglia vbfox

❄️
Winter is coming
View GitHub Profile
@vbfox
vbfox / DataUrlToImage.cs
Created July 21, 2010 15:35
Convert from a DataUrl to an Image in C#
using System;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
class Program
{
static string data = @"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAA8CAYAAACZ1L+0AAAABHNCSVQICAgIfAhkiAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAuhSURBVHic7Zx5kBT1Fcc/r2f2EhZQDq9IvBADiRoGROWaBXcWTCokhaIVb4scRaQUhlJMorCgUiizSoyliWKZMjGR9UghCswSaQVEgQZEJAoiQiJqonJ44B7TL3/0zO7M7Bw7uz0Dhv1WTc30r1+/95vf6/f7vd97r1tUlaMRaklfoB+wRnz69eHqhxytCgBQS7oBU4DuwCPi0x2F7sNRrYAY1JLBwNPRzyzx6ReFkm0UStCRDPHpBmAYMBp4Wy25rFCyC6uANVLONikuqMw2Qnz6ATAC2AAsUkuWqiU98y23cArYJsV2KTMZQFPBZOYI8emXwATgBWAs8LpacnY+ZRZIASIcYpEBD4HahZHZPohPI8BE4HXgDOA1taQyX/IKo4CNLMRgOT7dWRB5HYT49Cvgh8AOHA/pRbXk+rzIyrcXZFtyuyEMZJBekVdBeYBa8h1gI1AKRIDx4tMX3JSRXwvYJDeIMB7lhrzKyRPEp/8EZkUPPcBTaonPTRn5U8Aq6a02t4tNCMekv6mYD6yP/u4CLFFLvu0W8/xNQRtlocJZMkhH5EdA4aCWDAQ2AUXRps3AEPFphz26/FjAOrlQlQmiPNkm+k0ymPVyUV764gLEp28Bj8c1nQcE3eCdFwWoh1nATt7jj1mJN0s/O8Ikhuir+eiLi5gLCXuYmWrJ6R1l6r4CLJkEjFGo5TKNZKRdJz2x+ZMhTHO9Hy5
@vbfox
vbfox / Program.cs
Created August 26, 2010 15:33
Sample code for SHOpenFolderAndSelectItems in C#
namespace SHOpenFolderAndSelectItems
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
@vbfox
vbfox / SvnFixBinaryCsFiles.cs
Created November 10, 2010 10:35
LINQPad program to remove 'svn:mime-type' properties with 'application/octet-stream' value from '.cs' files.
void Main()
{
var dir = "C:\\Code\\Repo\\";
var onlyChanged = true;
if (onlyChanged)
{
Console.WriteLine("Getting files from SVN... ");
var changed = GetSvnStatus(dir)
.Where(t => t.Item1 == 'A' || t.Item1 == 'M')
@vbfox
vbfox / pre-commit-check-binary-csfile.sh
Created November 10, 2010 16:56
Pre-Commit hook for svn checking that no .cs file is committed as a binary file.
#!/bin/bash
function script {
local repo="$1"
echo "repo=$repo"
local txn="$2"
echo "txn=$txn"
local selector="-t $txn"
@vbfox
vbfox / minecraft_blocks.cs
Created May 2, 2011 18:48
Simple LINQPad script to spawn blocks in Minecraft
// This LINQPad script is usin the "C# Statement(s)" mode
// It requires a reference to System.Windows.Forms.dll
// and an import of the System.Windows.Forms namespace
//
// To use it click Execute, switch to minecraft and wait 5s.
var item = 20;
var user = "vbfox";
var stacks = 54;
var itemsPerStack = 64;
@vbfox
vbfox / FileTags.cs
Created October 14, 2011 00:19
Uses the Windows API to get the tags entered by the user in windows explorer
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
/// <summary>
/// Extract the tags that windows store for a file (internally called keywords)
/// </summary>
/// <code>
@vbfox
vbfox / abuse.cs
Created November 3, 2011 19:54
Abuse C# operators
struct T
{
public static Action<string>[] operator + (T inst)
{
return new Action<string>[] { i => Console.WriteLine(i) };
}
}
void Main()
{
@vbfox
vbfox / DisableTouchConversionToMouse.cs
Created November 4, 2011 15:54
Globally disable the conversion of touch events to mouse events in Windows 7
namespace BlackFox
{
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
/// <summary>
/// As long as this object exists all mouse events created from a touch event for legacy support will be disabled.
/// </summary>
@vbfox
vbfox / Mvvm.cs
Created December 7, 2011 23:56
CommandBindings from ICommands for WPF MVVM
namespace BlackFox
{
using System;
using System.Windows;
static class Mvvm
{
public static readonly DependencyProperty CommandBindingsProperty = DependencyProperty.RegisterAttached(
"CommandBindings", typeof(MvvmCommandBindingCollection), typeof(Mvvm),
new PropertyMetadata(null, OnCommandBindingsChanged));
@vbfox
vbfox / AndroidTaskScheduler.cs
Created January 15, 2012 22:06
An implementation of a TaskScheduler running code on a thread designated by an Android.OS.Handler (MonoDroid)
namespace BlackFox
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Android.OS;
/// <summary>
/// Provides a <see cref="TaskScheduler"/> using an android <see cref="Handler"/> to run the tasks.
/// </summary>