Skip to content

Instantly share code, notes, and snippets.

View tabakerov's full-sized avatar

Dmitry Tabakerov tabakerov

View GitHub Profile
@tabakerov
tabakerov / torus2.pde
Created September 27, 2021 20:11 — forked from beesandbombs/torus2.pde
torus 2
float[][] result;
float t, c;
float ease(float p) {
p = c01(p);
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
p = c01(p);
@tabakerov
tabakerov / struthless-journaling-tips.md
Created August 5, 2021 13:47
Struthless' tips for journaling

https://www.youtube.com/watch?v=dArgOrm98Bk

Clarity

Just dump everything from mind

Breaking your mindset

  • Imagine 6 impossible things
  • How can I make someone else happy right now?
  • What's something in my immediate environment that I have never noticed?
@tabakerov
tabakerov / ts2fable-issue-with-types-p5.md
Created August 2, 2021 21:36
ts2fable issue with @types/p5

ts2fable issue with @types/p5

  • @types/p5 v1.3.0
  • ts2fable v0.7.1

Run: ts2fable node_modules/@types/p5/index.d.ts src/Fable.Import.p5.fs -e p5

Result: /.../src/Fable.Import.p5.fs(95,17): (95,24) error FSHARP: The namespace or module '__index' is not defined. (code 39)

Fable.Import.p5.fs:

version: "3"
services:
db:
image: mysql:5.7
container_name: "products_db_dev"
ports:
- "3396:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=products_db_dev
@tabakerov
tabakerov / MonadicTaskExtensions.cs
Created June 19, 2018 14:46
Return, Bind, Map and Tap for async tasks
static class TaskExtensions
{
static Task<T> Return<T>(T task) => Task.FromResult(task);
static async Task<R> Bind<T, R>(this Task<T> task, Func<T, Task<R>> cont) =>
await cont(await task.ConfigureAwait(false)).ConfigureAwait(false);
static async Task<R> Map<T, R>(this Task<T> task, Func<T, R> map) =>
map(await task.ConfigureAwait(false));
@tabakerov
tabakerov / fsharp-mongo.fs
Created May 28, 2018 15:21
F# with MongoDB
// Learn more about F# at http://fsharp.org
open System
open MongoDB.Driver
open System.Security.Authentication
type PostId = PostId of string
type CommentId = CommentId of string
@tabakerov
tabakerov / gist:f428e28ae9b68462d1049c018df59104
Created May 9, 2018 16:23
How to add extension to user
OpenTypeExtension newExtension = new OpenTypeExtension();
newExtension.ExtensionName = "com.contoso.trackingKey";
newExtension.AdditionalData = new Dictionary<string, object>();
newExtension.AdditionalData.Add("trackingKeyMajor", "ABC");
newExtension.AdditionalData.Add("trackingKeyMinor", "123");
var extension = await graphClient.Users[email].Extensions.Request().AddAsync(newExtension);
@tabakerov
tabakerov / splitter.fsx
Last active October 16, 2017 19:35
split text by limit in bytes
open System
open System.Globalization
type ISplitter =
abstract member Split: string -> int -> string[]
type Splitter () =
let folder (lim:int) (acc:string list) (el:string) =
match acc with
| head::tail ->
@tabakerov
tabakerov / Program.cs
Created December 29, 2016 12:47
Local functions and closures in C# 7
using System;
class Program
{
static Func<int, int> CreateAdder(int a)
{
int F(int i)
{
Console.WriteLine($"Closured {a}");
return a + i;
@tabakerov
tabakerov / fib.fs
Created November 2, 2016 09:34
Recursive Fibbonacci F#
let rec fib_a p =
if (p = 0) || (p = 1)
then 1
else
fib_a(p-1)+fib_a(p-2)
let rec fib_b p =
match p with
| 1 | 0 -> 1