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 / fixacls.ps1
Created October 29, 2014 12:36
Fixes "This access control list is not in canonical form" on a folder
param([string]$dir);
$out = icacls "$dir" /verify /t /q
Foreach($line in $out)
{
if ($line -match '(.:[^:]*): (.*)')
{
$path = $Matches[1]
$acl = Get-Acl $path
Set-Acl $path $acl
@vbfox
vbfox / Dapper.fs
Last active April 21, 2022 02:58
Minimal dapper in F#
module DapperFSharp =
open System.Data.SqlClient
open System.Dynamic
open System.Collections.Generic
open Dapper
let dapperQuery<'Result> (query:string) (connection:SqlConnection) =
connection.Query<'Result>(query)
let dapperParametrizedQuery<'Result> (query:string) (param:obj) (connection:SqlConnection) : 'Result seq =
@vbfox
vbfox / UpdateAllNuget.md
Created November 19, 2014 08:25
Update all Nuget packages in a solution matched by name

From my CoderWall: https://coderwall.com/p/gvrn4w

Here is a better version of the code already present on Coderwall and on the official bug tracker.

The complexity of the original one is too big as it tries to update all packages found for all projects, instead of just the packages present on each project.

This one is a lot quicker to update everything in a big solution :

ForEach($project in get-project -all) { ForEach($package in Get-Package -ProjectName $project.ProjectName | ?{ $_.Id -like 'MyCompany*'}) { Update-Package -ProjectName $project.ProjectName -Id $package.Id;} }
@vbfox
vbfox / nullarg.DotSettings
Created November 26, 2014 17:16
NullReferenceException check -> custom function with ReSharper Structural Search And replace
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=2F4A0295AA4DD848965FCA6DA262D8B4/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=2F4A0295AA4DD848965FCA6DA262D8B4/Comment/@EntryValue">ArgumentNullException Thrown</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=2F4A0295AA4DD848965FCA6DA262D8B4/IsReplacePattern/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=2F4A0295AA4DD848965FCA6DA262D8B4/LanguageName/@EntryValue">CSHARP</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=2F4A0295AA4DD848965FCA6DA262D8B4/ReplaceComment/@EntryV
@vbfox
vbfox / FSharOptionCheckExtensions.cs
Created December 17, 2014 10:54
F# Option type support for NFluent
using Microsoft.FSharp.Core;
using NFluent;
using NFluent.Extensibility;
namespace UnitTests
{
public static class FSharOptionCheckExtensions
{
public static void IsNone<T>(this ICheck<FSharpOption<T>> check)
{
@vbfox
vbfox / RedirectPost.cs
Created February 10, 2015 16:18
Nancy Self-Host to redirect completely to another domain including 307 for POST
using System;
using Nancy;
using Nancy.Hosting.Self;
using Nancy.Responses;
namespace NancyRedirect
{
public class Program : NancyModule
{
static void Main()
@vbfox
vbfox / getline.fs
Last active August 29, 2015 14:16
A line-for-line port of getline.cs by Miguel de Icaza to F#
//
// getline.fs: A command line editor
//
// Authors:
// Miguel de Icaza (miguel@novell.com)
// Julien Roncaglia (julien@roncaglia.fr)
//
// Copyright 2008 Novell, Inc.
// Copyright 2015 Julien Roncaglia <julien@roncaglia.fr>
//
@vbfox
vbfox / Queue.fs
Created March 8, 2015 13:16
Small exercise of implementing a functional queue
module Queue
// "Purely Functional Data Structures" by Chris Okasaki, Page 18 (Figure 3.2)
open System
type queue<'a> = { F : 'a list; R : 'a list }
let empty = { queue.F = []; R = [] }
let isEmpty queue = List.isEmpty queue.F
let private makeQueue = function
| ([], r) -> { F = List.rev r; R = [] }
| (f, r) -> { F = f; R = r }
@vbfox
vbfox / UrlProtocol.cs
Last active August 29, 2015 14:17
Check if URL prototocol is handled on windows
using System;
using System.IO;
using System.Security;
using Microsoft.Win32;
static class UrlProtocol
{
public static bool IsSupported(string protocol)
{
if (protocol == null) throw new ArgumentNullException("protocol");
@vbfox
vbfox / WinScpFtp.fsx
Created April 9, 2015 09:50
Use WinSCP to upload a local directory by FTP in a Fake script
#r @"../packages/WinSCP/lib/WinSCPnet.dll"
open WinSCP
open System
open System.IO
type FtpServer =
{
HostName : string
UserName : string