Skip to content

Instantly share code, notes, and snippets.

View avestura's full-sized avatar
🍀
tell me about the odds

Avestura avestura

🍀
tell me about the odds
View GitHub Profile
@avestura
avestura / Tutorial.fsx
Last active February 1, 2019 12:48
F# one file tutorial
// This sample will guide you through elements of the F# language.
//
// *******************************************************************************************************
// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter or right-click
// and select "Execute in Interactive". You can open the F# Interactive Window from the "View" menu.
// *******************************************************************************************************
//
// For more about F#, see:
// http://fsharp.org
// https://docs.microsoft.com/en-us/dotnet/articles/fsharp/
@avestura
avestura / conemu_settings.xml
Created April 3, 2019 05:19
My ConEmu settings
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2019-04-03 09:47:48" build="190331">
<value name="Language" type="string" data="en"/>
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Shells::PowerShell Core (Admin)}"/>
<value name="StartFarFolders" type="hex" data="00"/>
{
"manifestVersion": 1,
"id": "my-first-extension",
"publisher": "AryanEbrahimpour",
"version": "1.1.3",
"name": "My First Extension",
"description": "A sample Visual Studio Services extension",
"public": false,
"categories": ["Azure Repos"],
"targets": [
@avestura
avestura / findSpecialMinMax.fsx
Last active October 17, 2021 20:36
F# Script to find min x and max y with condition index(y) > index(x) and maximum y-x
let findSpecialMinMax arr =
let rec f arr bestMin bestMax currentMin currentMax =
match arr with
| [] -> (bestMin, bestMax)
| cur::rest ->
match (bestMin, bestMax) with
| None, _ -> f rest (Some cur) None None None
| Some min, None ->
if cur > min then f rest (Some min) (Some cur) None None
else f rest (Some cur) None None None
const std = @import("std");
fn printaddr(a : anytype) void {
const stdout = std.io.getStdOut().writer();
stdout.print("address = {s}\n", .{&a}) catch unreachable;
}
fn foo() void {
const s1 = "literal";
@avestura
avestura / star-rating.fsx
Created September 3, 2022 08:25
Star Rating F# (🌕🌕🌕🌕🌑)
let getRating n =
let (*) = String.replicate
(n * "🌕") + ((5 - n) * "🌑")
getRating 5 |> System.Console.WriteLine
@avestura
avestura / closestPastShadowDom.ts
Created September 4, 2022 04:09
Closest get past shadow dom
const isShadowRoot = (maybeRoot) => {
return maybeRoot && maybeRoot.toString() === '[object ShadowRoot]'
}
const closestPastShadowDom = (elem, selector) => {
const closest = elem.closest(selector);
if(closest)
return closest;
const root = elem.getRootNode();
@avestura
avestura / cpu-affinity-test.fs
Created April 26, 2023 17:35
CPU Affinity Test
open System
open System.Linq
open System.Diagnostics
// change cpu affinity while app is running
// run in debug mode: optimizations off
printfn "Press enter to continue"
@avestura
avestura / write-dragon.js
Last active May 5, 2023 17:00
Get a "V" and "P" representation of dragon fractal
const getDragonBit = (n) => {
while ((n & 1) == 0) {
n = n >> 1;
}
return 1 - ((n >> 1) & 1)
}
const getDragon = n => {
let str = ""
for (i = 1; i < Math.pow(2, n); i++) {
const getDragon2 = n => {
const getDragonRecurse = (n, complement) => {
if(n === 1) {
return complement ? [0] : [1]
}
const right = getDragonRecurse(n - 1, complement);
const left = getDragonRecurse(n - 1, !complement);
return complement ? [...right, 0, ...left] : [...left, 1, ...right]
}