Skip to content

Instantly share code, notes, and snippets.

View SanariSan's full-sized avatar
😯
1 2 Fizz 4 Buzz

SanariSan

😯
1 2 Fizz 4 Buzz
  • krak.ai
  • Georgia, Tbilisi
View GitHub Profile
@SanariSan
SanariSan / prettify-ts-type.md
Created November 26, 2024 17:48
Prettify, show full nested ts type

tsconfig.json This prevents typehints for big types from showing ... N more ...

{
  "compilerOptions": {
    "noErrorTruncation": true,
  }
}
@SanariSan
SanariSan / favicon-optimize.md
Created September 24, 2024 22:30
Favicon optimization

imagick cli

convert favicon.ico -define icon:auto-resize=64,48,32,16 compressed_favicon.ico

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@SanariSan
SanariSan / keys.txt
Created September 10, 2024 14:38 — forked from f0r34chb3t4/keys.txt
Proxifier.txt
Portable Version KEYS:
P6Z3T-UYJC9-YAK3F-APN9M-6ZDSD
FGZPK-93CWX-Q33Y6-D5URV-YXC3X
9CZQX-9YAQA-PF33L-XVUQH-NSD48
8RZ3L-H3Y5L-W2RY5-Z5M8N-C7Z2U
CCZNU-LW3LF-K9V2T-MYZFF-94667
EWZM6-3W4UX-KH922-C96GK-VGBH2
Standard Version KEYS:
4AZNW-S2YHE-LLMWM-J6EL8-7QKDL
@SanariSan
SanariSan / clear-old-snaps.sh
Created May 15, 2024 13:38
Clear old snaps
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@SanariSan
SanariSan / make_writable.js
Created May 4, 2024 00:10 — forked from moehlone/make_writable.js
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
/**
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
*
* @param {Any} value initial value of the property
*/
function createProperty(value) {
var _value = value;
/**
@SanariSan
SanariSan / extract-js-source.js
Last active April 20, 2024 12:31
Extract source from JS sourcemap
/**
* If you have a website source bundled with webpack and are lucky to have a sourcemap nearby,
* then you are able to fully reconstruct original code + folders structure.
* Place this file at the root of project.
* Provide the path to sourcemap + the path to where you'd like to extract original codebase.
*/
const fs = require('fs');
const path = require('path');
const sourceMap = require('source-map');
@SanariSan
SanariSan / rtt.sh
Last active April 10, 2024 19:28
RTT for all hostname ips
#!/bin/bash
# Useful for checking rtt to any sotname of interest.
# Since servers usually have balancers or dns balancing is in place it is helpful to test every ip.
IPS=$(host $1 | grep "has address" | awk '{ print $4 }')
REQ_AMOUNT=${2:-5}
# Loop through each IP address
for IP in $IPS; do
@SanariSan
SanariSan / readme.md
Last active January 3, 2024 23:03
ffmpeg cut video, subtitles, convert format

Cut video (possibly directly to mp4)

ffmpeg -ss 00:01:00 -to 00:02:00 -i ./in.mkv -c copy out.mkv

Cut external subs

ffmpeg -i in.srt -ss 01:00 -to 02:00 out.srt
@SanariSan
SanariSan / a.md
Created December 24, 2023 08:21
React persist state
import React from 'react';

/**
 * @param {string} storageKey
 * @param {*} initialState
 * @param {number} expiration
 */
export const useStateWithLocalStorage = (storageKey, initialState, expiration) => {
  const [value, setValue] = React.useState(() => {