Skip to content

Instantly share code, notes, and snippets.

View qlonik's full-sized avatar

Nikita Volodin qlonik

View GitHub Profile
import * as T from "@effect/core/io/Effect"
import type * as EX from "@effect/core/io/Exit"
import * as FID from "@effect/core/io/FiberId"
import * as HUB from "@effect/core/io/Hub"
import type * as RU from "@effect/core/io/Runtime"
import * as S from "@effect/core/stream/Stream"
import * as C from "@effect-ts/core/Case"
import { pipe } from "@tsplus/stdlib/data/Function"
import * as O from "@tsplus/stdlib/data/Maybe"
import * as ENV from "@tsplus/stdlib/service/Env"
@sindresorhus
sindresorhus / esm-package.md
Last active September 22, 2024 13:17
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@UberMouse
UberMouse / createDataStream.ts
Created October 29, 2020 20:53
GraphQL + Apollo + XState dump
type QueryResult<TTransformedData> =
| { type: "success"; data: TTransformedData }
| { type: "error"; errors: readonly GraphQLError[] };
type ParentEvents<TData, TId extends string = "dataLoader"> =
| { type: "dataStream.NEW_DATA"; data: TData; id: TId }
| { type: "dataStream.ERROR"; id: TId };
export function createDataStream<
TObservableFactory extends (...args: $YesReallyAny[]) => Observable<QueryResult<$YesReallyAny>>,
@christr
christr / update-dns.sh
Last active May 26, 2024 04:00 — forked from mhussain/update-dns.sh
Linode dynamic DNS updating script
#!/bin/bash
# Modified by Chris Richardson (https://github.com/christr and https://twitter.com/christr77) on 09/20/2020
# Previous versions of this script don't work because they hadn't been updated since 2012. There are now more steps involved to set this up.
# This script update is based on information found here: https://developers.linode.com/api/v4/domains-domain-id-records-record-id/#put
# You first must find out the domain ID and resource ID numbers. In order to do this follow the steps below.
# 1. Create a Linode API Key through your account profile at https://cloud.linode.com/dashboard. Give it rights to read/write to domains only.
# 2. From a shell run the following command: LINODE_API_KEY=[insert API key from step 1 here]
# 3. Run the following command to get the domain ID number for the domain you want to manage: curl -H "Authorization: Bearer $LINODE_API_KEY" https://api.linode.com/v4/domains/
@KiaraGrouwstra
KiaraGrouwstra / stdlib.ts
Last active March 24, 2020 03:17
Type-level standard library for TypeScript
// NOTE: code now moved to https://github.com/tycho01/typical
// older revision left here, but it no longer runs well in TS Playground
export type Obj<T> = { [k: string]: T };
export type NumObj<T> = { [k: number]: T };
// export type List = ArrayLike; // no unapplied generic types :(
export type List<T> = ArrayLike<T>;
// progress: https://github.com/Microsoft/TypeScript/issues/16392
export function force<T, V extends T>() {}
@hediet
hediet / main.md
Last active August 24, 2024 02:28
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
@ThePenguin1140
ThePenguin1140 / workspaces.ahk
Last active February 26, 2017 17:07
Series of Windows 10 macros to make workspaces usable.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#InstallKeybdHook
<!<^Up::
send, #{Tab}
Return
@joepie91
joepie91 / random.md
Last active September 21, 2024 08:51
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@anvaka
anvaka / 00.Intro.md
Last active September 21, 2024 08:49
npm rank

npm rank

This gist is updated daily via cron job and lists stats for npm packages:

  1. Top 1,000 most depended-upon packages
  2. Top 1,000 packages with largest number of dependencies
  3. Top 1,000 packages with highest PageRank score