Skip to content

Instantly share code, notes, and snippets.

View sapozhnikovay's full-sized avatar
🏠
Working from home

Aleksei Sapozhnikov sapozhnikovay

🏠
Working from home
  • @ Bright security ex. JAVAD GNSS
  • Asturias, Spain
View GitHub Profile
@rpggio
rpggio / parseOrNull.ts
Last active September 26, 2024 20:28
React hook to persist MUI DataGrid column settings
/**
* If argument is a string, try to parse as JSON.
* Otherwise return null.
*/
export function parseOrNull(raw: unknown) {
if (!raw) return null
if (typeof raw === 'string') {
try {
return JSON.parse(raw)
<link rel="shortcut icon" width=32px>
<canvas style="display: none" id="loader" width="16" height="16"></canvas>
<script>
class Loader {
constructor(link, canvas) {
this.link = link;
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.context.lineWidth = 2;
@gullyn
gullyn / flappy.html
Last active November 19, 2025 15:40
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>
@Andrey2G
Andrey2G / encoding.txt
Last active December 19, 2025 07:40
Video Encoding with multiple resolutions
ffmpeg -i "c:/videos/sample.mp4
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0
-c:v libx264 -crf 22 -c:a aac -ar 48000
-filter:v:0 scale=w=480:h=360 -maxrate:v:0 600k -b:a:0 64k
-filter:v:1 scale=w=640:h=480 -maxrate:v:1 900k -b:a:1 128k
-filter:v:2 scale=w=1280:h=720 -maxrate:v:2 900k -b:a:2 128k
-var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p"
-preset slow -hls_list_size 0 -threads 0 -f hls -hls_playlist_type event -hls_time 3
-hls_flags independent_segments -master_pl_name "name-pl.m3u8"
"c:/videos/encoded/name-%v.m3u8"
@geordyjames
geordyjames / eslint_prettier_airbnb.md
Last active October 27, 2025 08:29
VSCode - ESLint, Prettier & Airbnb Setup for Node.js Projects

VSCode - ESLint, Prettier & Airbnb Setup for Node.js Projects

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-config-airbnb-base eslint-plugin-node eslint-config-node
@pyrou
pyrou / docker-compose.yml
Last active March 9, 2026 14:16
Use https://traefik.me SSL certificates for local HTTPS without having to touch your /etc/hosts or your certificate CA.
version: '3'
services:
traefik:
restart: unless-stopped
image: traefik:v2.0.2
ports:
- "80:80"
- "443:443"
labels:
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
@pwshehan
pwshehan / app-material.module.ts
Last active May 2, 2023 07:48
Angular Material all modules use import { AppMaterialModule } from './app-material/app-material.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MatCheckboxModule} from '@angular/material';
import {MatButtonModule} from '@angular/material';
import {MatInputModule} from '@angular/material/input';
import {MatAutocompleteModule} from '@angular/material/autocomplete';
import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatNativeDateModule} from '@angular/material';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatRadioModule} from '@angular/material/radio';
@nzvtrk
nzvtrk / axiosInterceptor.js
Last active April 14, 2025 13:50
Axios create/recreate cookie session in node.js enviroment
/* Basic example of saving cookie using axios in node.js and session's recreation after expiration.
* We have to getting/saving cookie manually because WithCredential axios param use XHR and doesn't work in node.js
* Also, this example supports parallel request and send only one create session request.
* */
const BASE_URL = "https://google.com";
// Init instance of axios which works with BASE_URL
const axiosInstance = axios.create({ baseURL: BASE_URL });
@glendaviesnz
glendaviesnz / rxjs-chunker.ts
Created July 7, 2018 00:45
RxJs document chunker and uploader. This class takes a document and breaks it into 1Mb chunks and uploads those chunks sequentially to the server.
export class ChunkingService {
public chunkSize = 1024 * 1024;
private _chunkQueue$ = new Subject();
private _maxConnections = 3;
constructor(
private _apiService: apiService,
private _store: Store<any>) {
Guard.notNothing(_apiService, '_apiService');
Guard.notNothing(_store, '_store');
@Dyljyn
Dyljyn / sync-control.directive.ts
Last active August 2, 2021 12:09
Syncing reactive form controls - Angular (v6)
import {
Directive,
EventEmitter,
InjectFlags,
Injector,
OnDestroy,
OnInit,
Type
} from '@angular/core';
import { AbstractControl, FormControlDirective, FormControlName } from '@angular/forms';