Skip to content

Instantly share code, notes, and snippets.

@riivanov
riivanov / downgrade.sh
Created May 15, 2024 15:05
How to downgrade all Arch packages
# https://linuxconfig.org/how-to-rollback-pacman-updates-in-arch-linux
$ grep -a upgraded /var/log/pacman.log| grep 2020-11-30 > /tmp/lastupdates.txt
$ awk '{print $4}' /tmp/lastupdates.txt > /tmp/lines1;awk '{print $5}' /tmp/lastupdates.txt | sed 's/(/-/g' > /tmp/lines2
$ paste /tmp/lines1 /tmp/lines2 > /tmp/lines
$ tr -d "[:blank:]" < /tmp/lines > /tmp/packages
$ cd /var/cache/pacman/pkg/
$ for i in $(cat /tmp/packages); do sudo pacman --noconfirm -U "$i"*; done
@riivanov
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.
{
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.suggest.insertMode": "replace"
[
{
"key": "alt+r",
"command": "workbench.action.reloadWindow",
"when": "editorFocus"
},
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
@riivanov
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("https://random-word-api.herokuapp.com/word");
const ary = await word.json();
return ary.shift();
}
async function getAllImgElements() {
return document.querySelectorAll("img");
}
@riivanov
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> :
T;
@riivanov
riivanov / TypesvsInterfaces.md
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.

fundamental.ts

type Pet = IDog | ICat;

interface IAnimal {
  age: number;
  eat(): void;
@riivanov
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
HostName ec2-16-170-180-221.eu-north-1.compute.amazonaws.com
User ubuntu
IdentityFile /home/rivanov/.ssh/aws_ed25519-eu-north-1
@riivanov
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"
EndSection