Skip to content

Instantly share code, notes, and snippets.

@Poxios
Poxios / simple text bar.md
Created November 26, 2022 05:26
Simple text bar python
View simple text bar.md

Simple text bar (graph) with python

def generate_text_bar_graph(length: int, min_value: int, score: int, max_value: int):
    if score <= min_value:
        return f'[{min_value}{"―"*(length-1)} {max_value}]'
    elif max_value <= score:
        return f'[{min_value} {"―"*(length-1)}{max_value}]'

    def roundUp(num: int): return int(num) + \
 1 if (num - int(num)) &gt;= 0.5 else int(num)
@Poxios
Poxios / traefik-with-https-docker-compose.yml
Created November 3, 2022 06:50
Full docker-compose file for Traefik with secure settings
View traefik-with-https-docker-compose.yml
# Simple docker-compose file example for Traefik
# Feature: Let's encrypt(ACME), Log(Debug level), Secure Dashboard(https connection, require password), Redirect http requests to https, Example docker container connection(whoami)
# @Poxios, 2022
version: '3'
services:
reverse-proxy:
image: traefik
container_name: reverse-proxy
@Poxios
Poxios / aligning-images.md
Created September 19, 2022 05:44 — forked from DavidWells/aligning-images.md
Guide to aligning images in github readme.md files. https://davidwells.io/snippets/how-to-align-images-in-markdown
View aligning-images.md

Aligning images

left alignment

This is the code you need to align images to the left:

@Poxios
Poxios / throw-error-on-timeout.ts
Created August 13, 2022 02:04
Throw Error on Timeout (Typescript)
View throw-error-on-timeout.ts
export async function timeout<T>(promise: Promise<T>, ms: number): Promise<T> {
let timer: NodeJS.Timeout;
const res = await Promise.race([
promise,
new Promise<'timeout'>(resolve => {
timer = setTimeout(() => resolve('timeout'), ms);
})
] as const).finally(() => clearTimeout(timer));
if (res === 'timeout') {
@Poxios
Poxios / extract-am-pm.js
Created August 10, 2022 10:30
자바스크립트 오전 오후 뽑아내기
View extract-am-pm.js
export const getAMPMTimeFromDate = (date: Date) => {
let hours = date.getHours();
let minutes = date.getMinutes() as any;
let ampm = hours >= 12 ? '오후' : '오전';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes.toString().padStart(2, '0');
let strTime = ampm + ' ' + hours + ':' + minutes;
return strTime;
};
View youtube-dl-download-audio-only-on-best-quality.md

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@Poxios
Poxios / git-move-files-in-subfolder.md
Created May 8, 2022 08:29 — forked from ajaegers/git-move-files-in-subfolder.md
Git: move files in an subfolder keeping history
View git-move-files-in-subfolder.md

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

@Poxios
Poxios / ffmpeg-mp4-to-animated-webp.md
Created May 28, 2021 16:09 — forked from witmin/ffmpeg-mp4-to-animated-webp.md
Convert MP4 file to animated WebP in ffmpeg
View ffmpeg-mp4-to-animated-webp.md

Convert MP4 file to animated WEBP file in ffmpeg CLI

1. Install ffmpeg CLI through homebrew

In terminal.app, install ffmpeg through homebrew

brew install ffmpeg

Validate the installation:

@Poxios
Poxios / discord.py
Created April 21, 2021 14:38
Generate discord emoji
View discord.py
string = input('')
for i in string:
if i == ' ':
print(' ', end=' ')
else:
print(":regional_indicator_" + i + ":", end=' ')
@Poxios
Poxios / bypass_distil_security_selnium.py
Created April 11, 2021 11:22 — forked from 4sushi/bypass_distil_security_selnium.py
Bypass distil security with Selenium python
View bypass_distil_security_selnium.py
"""
Example to bypass distil security (https://www.distilnetworks.com/) with Selenium.
They use the javascript field navigator.webdriver to ban Selenium
The solution is to inject javascript code before the laoding og the webpage, to set webdriver to false
Works only with chromium driver
"""
from datetime import datetime
import os
import sys