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 / vswhere.fs
Last active August 22, 2018 07:45
F# vswhere
// Microsoft.VisualStudio.Setup.Configuration.Interop.dll
module VsInstances =
open System.Runtime.InteropServices
[<Guid("B41463C3-8866-43B5-BC33-2B0676F7F42E")>]
[<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>]
[<ComImport>]
[<AllowNullLiteral>]
type private ISetupInstance =
@vbfox
vbfox / dynamic.fs
Created July 17, 2018 13:53
F# dynamic
// dynamic x = "Foo";
// Console.WriteLine(x.ToString());
open System
open System.Runtime.CompilerServices
open Microsoft.CSharp.RuntimeBinder
let mutable toStringSite: CallSite<Func<CallSite, obj, obj>> option = None
let mutable writelineSite: CallSite<Action<CallSite, Type, obj>> option = None
@vbfox
vbfox / requestAnimationFrame.md
Created January 28, 2018 12:55
Experimentations with using requestAnimationFrame in fable elmish

If the Elmish state should be updated by the event but not the view a wrapper component might do:

[<Import("cloneElement", from="react")>]
let cloneElement(element: ReactElement, props: obj, [<ParamList>] children: obj) = jsNative

type RequestAnimationFrameState<'a> = {
    props: 'a
}
@vbfox
vbfox / AsyncIo.fs
Created November 20, 2017 20:47
Fable async node IO
module AsyncIO
let private readdir (dir: string): Promise<ResizeArray<string>> =
Promise.Create(fun resolve fail ->
Fs.readdir(U2.Case1 dir, fun err files ->
if isDefined err then fail.Invoke(err) else resolve.Invoke(U2.Case1 files)))
let private unlink (path: string): Promise<unit> =
Promise.Create(fun resolve fail ->
Fs.unlink(U2.Case1 path, fun err ->
if isDefined err then fail.Invoke(err) else resolve.Invoke(U2.Case1 ())))
@vbfox
vbfox / teamcity_agent_dedicated_non_admin_user.cmd
Last active November 6, 2017 16:52
TeamCity agent upgrade with dedicated user account
REM When TC Agent is using a dedicated account that isn't admin it can update itself
REM To solve it it's enough to give the user full control of the service account
REM Install SubInAcl from https://www.microsoft.com/en-us/download/details.aspx?id=23510
REM For service TCBuildAgent
REM And user Domain\User
"c:\Program Files (x86)\Windows Resource Kits\Tools\subinacl" /service TCBuildAgent /GRANT=Domain\User=F
@vbfox
vbfox / TypedTaskDefinitionHelper.fs
Last active January 29, 2018 13:01
Allow to define FAKE targets with a syntax similar to Gulp tasks and typed !
/// Allow to define FAKE tasks with a syntax similar to Gulp tasks and using instances instead of strings
/// https://gist.github.com/vbfox/2eee346524d688af55ccc467e154e1b4
module BlackFox.TypedTaskDefinitionHelper
open Fake
open System
type TaskMetadata = {
name: string
dependencies: TaskInfo list
{
"FSharp.lineLens.enabled": "replaceCodeLens",
"workbench.colorCustomizations": {
"editorCodeLens.foreground": "#4C4B4B"
},
"[fsharp]": {
"editor.codeLens": false
}
}
@vbfox
vbfox / redux.tsx
Last active October 4, 2017 09:10
Redux with discriminated unions
import { List } from "immutable";
import * as React from "react";
import { connect } from "react-redux";
import { Action, Dispatch } from "redux";
export enum ActionKind {
AddTodo = "ADD_TODO",
RemoveTodo = "REMOVE_TODO"
}
@vbfox
vbfox / config.json
Last active August 4, 2017 22:06
VS Code no editor decorations
{
"editor.folding": false,
"editor.lineNumbers": "off",
"editor.renderWhitespace": "none",
"editor.codeLens": false,
"editor.minimap.enabled": false,
"editor.dragAndDrop": false,
"editor.renderIndentGuides": false
}
@vbfox
vbfox / msiexec.ps1
Created June 28, 2017 13:11
Finding where is an installed package msi file (Windows Installer)
get-wmiobject Win32_Product | Where-Object { $_.Name -like "*foo*" } | Format-Table Name, LocalPackage, PackageCache, PackageName, InstallSource