Skip to content

Instantly share code, notes, and snippets.

View tony-0tis's full-sized avatar
🧘
ヾ(@⌒ー⌒@)ノ

Tony Outis tony-0tis

🧘
ヾ(@⌒ー⌒@)ノ
View GitHub Profile
@tony-0tis
tony-0tis / raceWithTimeout.js
Last active December 23, 2025 05:24
Run Promise function with timeout
function raceWithTimeout(task, timeout = 1000){
return Promise.race([
task.catch(error=>({error})),
new Promise(resolve=>setTimeout(resolve, timeout, {error: 'Timeout'}))
]);
}
/* example for node.js:
const { unlink } = require('fs/promises');
@tony-0tis
tony-0tis / example.com.conf
Last active August 6, 2025 06:38
Nginx SSL parameters for A+ rating on https://www.ssllabs.com/ with letsencrypt
server{
#...
listen *:443 ssl http2;
listen [::]:443 ssl http2;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by user
@tony-0tis
tony-0tis / README.md
Last active June 24, 2024 10:02
UUID generator provides good uniqueness guarantees

0tis-uuid4

UUID generator provides good uniqueness guarantees

Install

npm i -S gist:816bc579e30c134e388478ca36ece750
@tony-0tis
tony-0tis / MultyLinesProcessLoader.mjs
Last active June 24, 2024 10:02
js module for load indication
import EventsEmitter from "0tis-eventemitter";
class MultyLinesProcessLoader extends EventsEmitter{
defaultOptions = {
el: null,
width: 150,
height: 150,
count: 8,
indent: 6,
textSize: '20px',
@tony-0tis
tony-0tis / EventEmitter.mjs
Last active June 24, 2024 10:01
Simple es6 eventEmitter
class EventsEmitter {
constructor(){
this.events = {};
}
on(name, callback, context, once = false){
if(name == null) throw new Error('No first argument passed');
if(callback == null) throw new Error('No second argument passed');
if(typeof callback !== 'function') throw new Error('Second argument must be a function');
if(typeof context === 'boolean' && context === true && once === false){
@tony-0tis
tony-0tis / README.md
Last active June 24, 2024 10:01
A simple script to run asynchronous tasks with auto. Alternative to async.auto

0tis-autotasks

A simple script to run asynchronous tasks with auto. Alternative to async.auto

Install

npm i -S gist:bf5ff86a2a20f88f3b327872427598ab
@tony-0tis
tony-0tis / README.md
Last active June 24, 2024 10:00
A simple script to run asynchronous tasks sequentially. Alternative to async.waterfall

0tis-waterfall

A simple script to run asynchronous tasks sequentially. Alternative to async.waterfall

Install

npm i -S gist:81cb708f0ef01ed2d3ecf6e6aae43013
@tony-0tis
tony-0tis / youtube-langs-sort.js
Last active May 8, 2023 15:53
Youtube. Move your lang to top of the list of translate languages
let langToUp = 'Русский';
settingsObserver = new MutationObserver((list, observer)=>{
list.forEach(mutation=>{
if(mutation.addedNodes.length){
let node = [...mutation.addedNodes].find(node=>node.innerText.indexOf(langToUp)>-1);
if(node){
setTimeout(()=>{
let doc = document.querySelectorAll('.ytp-panel-menu')[0];
if(!doc) return;
[...doc.children]
@tony-0tis
tony-0tis / .profile
Last active March 23, 2023 09:12
Short git aliases for .profile or .bashrc or .bash_profile or /etc/bash_profile
alias gs='git status '
alias ga='git add '
alias gap='git add --patch'
alias gaa='git add .'
alias gb='git branch '
alias gba='git branch --all'
alias gbag='git branch --all | grep '
alias gc='git commit'
alias gcm='git commit -m'
alias gacm='git commit -am'