Skip to content

Instantly share code, notes, and snippets.

riivanov / todo.entity.ts
Created February 1, 2023 16:36
Todo entity that is both an ORM entity, and part of a GQL schema definition
import { Field, ID, InputType, ObjectType } from "type-graphql";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
export class Todo {
id: number;
riivanov / .etc.profile
Created February 4, 2023 20:30
/etc/profile with startup root apps modifications at the bottom
# /etc/profile
# Set our umask
umask 022
# Append "$1" to $PATH when not already in.
# This function API is accessible to scripts in /etc/profile.d
append_path () {
case ":$PATH:" in
riivanov / 30-touchpad.conf
Created February 4, 2023 20:32
/etc/X11/xorg.conf.d - Enable tapping on Lenovo Thinkpad E15 Gen2
Section "InputClass"
Identifier "touchpad"
Driver "libinput"
MatchIsTouchpad "on"
Option "Tapping" "on"
riivanov / config
Last active February 5, 2023 18:18
~/.ssh/config - How to create alias for ssh connection: End Result - `ssh aws-eu-north-1` to connect
Host aws-eu-north-1
User ubuntu
IdentityFile /home/rivanov/.ssh/aws_ed25519-eu-north-1
riivanov /
Last active February 5, 2023 19:20
Types vs Interfaces

Most of the times, type aliases in TypeScript are used to alias a more complex type, like a union of other types, to a reusable name. On the other hand, interfaces are used for more traditional object-oriented purposes, where you define the shape of an object and then use that as a contract for function parameters or for a class to implement.


type Pet = IDog | ICat;

interface IAnimal {
  age: number;
  eat(): void;
riivanov / deep-read-only
Created February 7, 2023 22:51
Recursive Type Example
type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> };
type DeepReadonly<T> = T extends (infer E)[] ?
ReadonlyArray<ReadonlyArray<DeepReadonlyObject<E>>> :
T extends object ? DeepReadonlyObject<T> :
riivanov / addToImage.js
Created March 7, 2023 13:36
Sets alt of all images to random word; Watches for image additions, adds input box, changes alt to input value, sets border color
(async function addRandomWordToImgs() {
async function getRandomWord() {
const word = await fetch("");
const ary = await word.json();
return ary.shift();
async function getAllImgElements() {
return document.querySelectorAll("img");
"key": "alt+r",
"command": "workbench.action.reloadWindow",
"when": "editorFocus"
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.suggest.insertMode": "replace"
riivanov / reverse-and-sum.ts
Last active March 30, 2024 04:00
reverse two linked lists, sum them and return the sum as a linked list
// You are given two non-empty linked lists representing two non-negative integers.
// The digits are stored in reverse order, and each of their nodes contains a single digit.
// Add the two numbers and return the sum as a linked list.
// You may assume the two numbers do not contain any leading zero, except the number 0 itself.
// Example 1:
// Input: l1 = [2,4,3], l2 = [5,6,4]
// Output: [7,0,8]
// Explanation: 342 + 465 = 807.