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 / 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 / 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 / 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>
@vbfox
vbfox / fullscreenMode.js
Created January 31, 2012 12:54
Just reading around the full screen API and implementing as i read for fun a small wrapper
// http://hacks.mozilla.org/2012/01/using-the-fullscreen-api-in-web-browsers/
function fullscreenMode()
{
this.request = function() {
var documentElement = document.documentElement;
if (documentElement.requestFullscreen) {
return documentElement.requestFullscreen();
}
else if (documentElement.mozRequestFullScreen) {
@vbfox
vbfox / GetReferencedAssemblies.cs
Created August 6, 2012 09:26
GetReferencedAssemblies & GetDirectlyReferencedAssemblies
static class Utils
{
static IEnumerable<Assembly> GetDirectlyReferencedAssemblies(Assembly startAssembly)
{
return startAssembly.GetReferencedAssemblies()
.Select(TryLoad)
.Where(a => a != null && !a.GlobalAssemblyCache);
}
static IEnumerable<Assembly> GetReferencedAssemblies(Assembly startAssembly)
@vbfox
vbfox / ZipVisualStudioTemplates.cs
Created October 25, 2012 13:59
Create zips as expected by visual studio as templates
void Main()
{
var root = new DirectoryInfo(@"C:\temp\tmls\Visual Studio Templates");
var works = from dir in root.GetDirectories("*.*", System.IO.SearchOption.AllDirectories)
where dir.Parent.Name == "1033"
select new {
Archive = Path.Combine(dir.Parent.FullName, dir.Name + ".zip"),
Glob = Path.Combine(dir.FullName, "*"),
Dir = dir
@vbfox
vbfox / ExtractNestedClassesToSeparateFiles.fs
Last active November 3, 2015 00:00
Extract nested classes/struct/enums to their own files
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
open Microsoft.CodeAnalysis.CSharp.Syntax
open Microsoft.CodeAnalysis.MSBuild
open Microsoft.CodeAnalysis.Formatting
open System.IO
module FluentRoslynLite =
let (!!) t = Async.AwaitTask t
let emptyFile = SyntaxFactory.CompilationUnit()
@vbfox
vbfox / fixupDotCoverArgs.fs
Last active January 20, 2016 14:34
Fix dotcover args in FAKE to be correctly passed to CreateProcess
/// Escape arguments in a form that programs parsing it as Microsoft C Runtime will successfuly understand
/// Rules taken from http://www.daviddeley.com/autohotkey/parameters/parameters.htm#WINARGV
module MsvcrCommandLine =
open System.Text
let escapeArg (arg : string) (builder : StringBuilder) =
let needQuote = arg.Contains(" ") || arg.Contains("\t")
let rec escape (builder: StringBuilder) pos =
if pos >= arg.Length then
()
@vbfox
vbfox / web.config.xml
Created March 30, 2016 21:23
Suave IIS https with redir
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
stdoutLogEnabled="true"
stdoutLogFile="./logs/SuaveIIS.log"