Skip to content

Instantly share code, notes, and snippets.

❄️
Winter is coming

Julien Roncaglia vbfox

❄️
Winter is coming
Block or report user

Report or block vbfox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vbfox
vbfox / Immutable.ts
Created Apr 16, 2019
Simple type immutable.js Map based immutable type with strongly typed keys
View Immutable.ts
import { Iterable, Map } from "immutable";
// tslint:disable:array-type
// tslint:disable:unified-signatures
export interface Immutable<T> {
set<TKey extends keyof T>(key: TKey, value: T[TKey]): Immutable<T>;
/**
* Returns a new Map which excludes this `key`.
*
@vbfox
vbfox / FableReactEquals.fs
Last active Apr 16, 2019
Prototype of Equals function for F# Fable React interop that does the same as the (=) operator except that all functions are equal
View FableReactEquals.fs
// Flawed try, I don't think a deep function ignoring compare is practical
//
// https://fable.io/repl/#?code=PYBwpgdgBAYghgIwDZgHQEkC2JgCcAuqAUgMoCwAUKJLIiqgMJ5pEDO6E+Yuol108ZGia4wlSgG0APFhwEAFACIwARwCucJAEFcuOAE9WAdQCW+ABaKANFEUAzOmAC0SEwj259AegCq+E0ioAFasigCUAHwAupQo+FAguCYAbnBcUKoa2roGxmbmUPIAHgBcUMAIQWGF+mUVVYUAxth1lVBOEeVtHVAIwMBIYWV9A1AAvJRQU1AhAHJpKWIUkjLYePhKjcDYcKIAImlgoTb2ji5uHt5+AcGhkTEUcQlJqelbO-uHrIWlXQ3ytT+QygJk440m0zmC2SSxWAFFMGYlAASAAM4zGUGRAEZwtFYmB4okUocZqw4epNN9ilBWv99LSgYyRkhxmT5v4YeIKNIEUjFGioABCTE4vEPJ7E15gdnAfAUrLUoqM+rVAEqyrVYb9VmYqGc2GPQnPEnpVhwTBgAAq+nAPzpasBqvBFGmsvllKQ3wZEDUSFZADIAxC3VN6qgAEpgOzcSCNMAKqnyEOht0AeUqYEahAA5oSAAo8fBy21gNN2YphAD8WwgrHwuDU2bwVhTqamGaCWdzBaLJfA5YB1dr9cbzdwYW5vMRG0U+FLwDsWNR4oJRJepJCNvAi8KAH0NQ0yqPQTm2frFlOpHzZ4LQfW4BB47uDlxV0b16aZSZWK+ZfIDwdZkdXPVgOUvZYPxBCBXAgGUpVJH8dD0BliiAiZXWmZCDFQJCcgZZUAB9CKgbD9AAITUOwY1wXDWAANRMMAAHcoCKblJQ3dJRC2XAABNCzlfsZQw9NM2zVA83wQTi3nAcKwAbxIzBdgAa24NkGzUGVCIAX0nSCnh4k1pRBVgo14vj7SZUTphMJcQkTL02KgX1-SgCxIDbaYHC9JY3TAPzvKmTih
@vbfox
vbfox / TraceChanges.ts
Created Mar 27, 2019
Trace props or state that changed and made a React PureComponent refresh
View TraceChanges.ts
export class Test extends React.PureComponent<{}, {}> {
UNSAFE_componentWillUpdate(nextProps: any, nextState: any) {
const changedProps = _.reduce(
this.props,
(result: string[], value, key) => value === nextProps[key] ? result : result.concat(key),
[]);
console.log("changedProps: ", changedProps);
const changedStates = _.reduce(
this.state,
(result: string[], value, key) => value === nextState[key] ? result : result.concat(key),
@vbfox
vbfox / MemoReactHelpers.fs
Last active Oct 24, 2018
React 16.6 Fable 1
View MemoReactHelpers.fs
module MemoReactHelpers
/// A special ReactElement that tell React to not render anything
[<Emit("null")>]
let noElement = jsNative<ReactElement>
[<Erase>]
type ComponentClass<'props, 'state> = class end
[<RequireQualifiedAccess>]
@vbfox
vbfox / vswhere.fs
Last active Aug 22, 2018
F# vswhere
View vswhere.fs
// 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 =
View dynamic.fs
// 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 Jan 28, 2018
Experimentations with using requestAnimationFrame in fable elmish
View requestAnimationFrame.md

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 Nov 20, 2017
Fable async node IO
View AsyncIo.fs
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 Nov 6, 2017
TeamCity agent upgrade with dedicated user account
View teamcity_agent_dedicated_non_admin_user.cmd
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 Jan 29, 2018
Allow to define FAKE targets with a syntax similar to Gulp tasks and typed !
View TypedTaskDefinitionHelper.fs
/// 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
You can’t perform that action at this time.