Skip to content

Instantly share code, notes, and snippets.

@guardam
guardam / parallelize.ts
Created December 5, 2021 18:09
Useful typescript code to manage promises.
const delay = (ms: number): Promise<void> =>
new Promise(r => setTimeout(r, ms));
const genRandomSleepInterval = (min: number, max: number): number =>
Math.floor(Math.random() * max) + min;
export async function* parallelize<T = unknown>({
funcs,
concurrency = Infinity,
sleepInterval = 0
@guardam
guardam / acrylic-titlebar.cs
Last active May 1, 2019 18:59
Windows 10 UWP Acrylic TitleBar
...
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.ViewManagement;
private void ExtendAcrylicIntoTitleBar()
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
@guardam
guardam / eslint-prettier.md
Created April 23, 2019 23:02
Configs for eslint + prettier

.editorconfig

root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
@guardam
guardam / ReplyKeyboardMarkup.php
Last active April 26, 2019 11:34
Telegram bot ReplyKeyboardMarkup in PHP
$bot_mex["reply_markup"] = json_encode(
[
"keyboard" => [
[
["text" => "0"],
["text" => "1"],
["text" => "2"],
["text" => "3"],
["text" => "4"],
],