Skip to content

Instantly share code, notes, and snippets.

View Liminiens's full-sized avatar
🏠
Working from home

Vlad Khapin Liminiens

🏠
Working from home
View GitHub Profile
@tech234a
tech234a / README.md
Last active June 10, 2023 14:03
Using unmodified third-party Reddit apps with a custom server
@bessgeor
bessgeor / AST_Conversion.fs
Created November 21, 2020 14:20
Convert F# quotation to C# expression including nested lambdas for a subset of closure types
open System
open System.Collections.Generic
open System.Linq
open System.Linq.Expressions
open System.Reflection
open LinqToDB
module AST_Conversion =
type private StubContext() =
interface IDataContext with
(*
WHAT'S GOING ON HERE?!
Sometimes you don't care about a particular type, you're interested in one field only, let's say `EntityId`.
Instead of using interface (which isn't even possible if don't own a type),
we can do structural typing in F# using SRTP and Active Patterns.
Active patterns are not required for this, but they do make code much easier to use.
*)
// So we have 2 types with field `EntityId: string`:
public class Result<T> : Result
{
public T Value { get; }
public Result(T result)
{
Success = true;
Value = result;
}
public Result()
@ForNeVeR
ForNeVeR / DelegateConverter.fs
Last active April 27, 2022 16:22
Mystical delegate converter in F#
open System
type Del = delegate of int -> int
let convert1 (d: Func<int, int>): Del = (# "" d : Del #)
let convert2 (d: Func<int, int>): Del = Del(fun x -> d.Invoke x)
[<EntryPoint>]
let main argv =
let x = Func<int, int>(fun x -> x)
@anschaef
anschaef / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active April 12, 2024 08:49
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
/*
// ########################################################################## */
// New cheat sheet for Bootstrap 5:
@ethanhuang13
ethanhuang13 / xcode-beta-slink.sh
Last active February 3, 2023 20:21
Symbolic link from Xcode.app to Xcode-beta.app (Xcode 11.2)
@rmoorman
rmoorman / babelrc-vs-webpack-babel-loader-configuration.md
Created July 30, 2016 16:54
.babelrc vs webpack babel-loader configuration

Either you use .babelrc to specify environment specific settings (plugins or transforms for example) using the env key:

{
  "presets": ["es2015", "stage-0", "react"],
  "env": {
    "development": {
      "plugins": [
        ["transform-object-rest-spread"],
 ["transform-react-display-name"],
@antiduh
antiduh / FastConcat.cs
Last active April 16, 2019 03:11
Concatenates a list of strings into a single string by performing exactly one allocation.
/// <summary>
/// Provides the ability to concatenate arrays of strings and arrays of character arrays into a
/// single string without performing intermediate copies of the strings/characters, nor the
/// arrays that contain them.
/// </summary>
/// <remarks>
/// Methods like `string.Concat( string[] )` make an intermediate copy of the array containing
/// the strings (but not the strings themselves). If you have a large array of strings, then
/// copying that array can represent a moderate amount of unnecessary work. For instance,
/// copying a 500k element array in a 64-bit process requires copying about 4 MB of memory.
@dsyme
dsyme / gist:bfed2eed788c7ba58ccc
Last active July 4, 2022 22:23
Naked type aliases can add and name constraints
// This F# language suggestion wants a way to name collections of constraints:
// http://fslang.uservoice.com/forums/245727-f-language/suggestions/8509687-add-constraints-as-a-language-construct
//
// This is a type alias X<T> = T, so X<int> = int etc.
type X<'T> = 'T
// This is a type alias X<T> = T which adds a constraint
type WithStruct<'T when 'T : struct> = 'T