Skip to content

Instantly share code, notes, and snippets.

View Klemek's full-sized avatar
127.0.0.1 sweet 127.0.0.1

Klemek Klemek

127.0.0.1 sweet 127.0.0.1
View GitHub Profile
@Klemek
Klemek / git-clone.sh
Last active April 19, 2021 14:04
Git clone that cd into the cloned repository
#!/bin/bash
git-clone() {
setopt local_options BASH_REMATCH
git clone "$1" && \
[[ $1 =~ (\\w+)(\\.git)?$ ]] && \
cd ${BASH_REMATCH[2]}
}
# git-clone https://github.com/Klemek/miniscord
@Klemek
Klemek / ascii.sh
Last active April 16, 2021 16:30
ASCII table colored in bash
for i in $(seq 32 47);do for j in $(seq 0 5);do echo $((i+j*16))|awk '{printf("| \033[91m%3d \033[95m%x \033[92m%1c\033[39m ",$1,$1,$1)}';done&&echo;done
# alias ascii=$'for i in $(seq 32 47);do for j in $(seq 0 5);do echo $((i+j*16))|awk \'{printf("| \\033[91m%3d \\033[95m%x \\033[92m%1c\\033[39m ",$1,$1,$1)}\';done&&echo;done'
# or
python3 -c 'print("\n".join([" | ".join([f"\033[91m{i+j*16:3d} \033[95m{hex(i+j*16)[2:]} \033[92m{chr(i+j*16)}\033[39m" for j in range(6)]) for i in range(32, 48)]))'
# alias ascii=$'python3 -c \'print("\\n".join([" | ".join([f"\\033[91m{i+j*16:3d} \\033[95m{hex(i+j*16)[2:]} \\033[92m{chr(i+j*16)}\\033[39m" for j in range(6)]) for i in range(32, 48)]))\''
@Klemek
Klemek / memory_watcher.py
Created April 7, 2021 15:47
memory debug for python
import os
import psutil # pip install psutil
import logging
import asyncio
process = psutil.Process(os.getpid())
async def watch_memory():
last_mem = 0
@Klemek
Klemek / us-altgr-intl-fr.md
Last active April 16, 2020 06:52
Alternative keyboard layout of "US international with AltGr dead keys" with french shortcuts

layout

To change the keyboard layout :

(On X11 unix systems) Backup and (sudo) edit /usr/share/X11/xkb/symbols/us

Replace

partial alphanumeric_keys
#!/bin/bash
set -e
echo ''
echo ' _ _________ __________ __ '
echo ' | | /| / / __/ _ )/ __/ __/ // / '
echo ' | |/ |/ / _// _ |\ \_\ \/ _ / '
echo ' |__/|__/___/____/___/___/_//_/ '
echo ' '
@Klemek
Klemek / MangaRockAPI.md
Last active September 15, 2020 20:34
MangaRock RESTful API
@Klemek
Klemek / manga_rock_exports.js
Last active January 4, 2020 09:45
Export Manga Rock Favorite List
// Go to https://mangarock.com/account/favorite
// Expand manga list to the bottom
// Type F12 and paste the following in the "console" tab
// Now you have your favorite list in CSV into your clipboard
var t = document.createElement("textarea");
t.textContent = 'Author;Title;\n'+$x('//*[@id="all"]/div/div[2]/div').map(n => '"'+n.childNodes[2].textContent + '";"' + n.childNodes[1].childNodes[0].textContent+'";').join('\n');
document.body.appendChild(t);
t.select();
document.execCommand("copy");
@Klemek
Klemek / github-cdn.js
Last active July 17, 2019 17:21
Github script loading
const github = (repo) => {
const self = {
loadScript: (file) => new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', `https://raw.githubusercontent.com/${repo}/master/${file}`);
xhr.onload = function() {
if (xhr.status === 200) {
const u = URL.createObjectURL(new Blob([xhr.responseText], { type: 'text/javascript' }));
const s = document.createElement('script');
s.src = u;
#!/bin/bash
set -e
if [[ -z "$1" ]]; then
echo "please enter file"
exit 1
fi
filename=$(basename -- "$1")
@Klemek
Klemek / font-awesome-png.sh
Last active June 26, 2019 07:38
Download then convert latest Font Awesome SVGs into PNGs
#!/bin/bash
#Automatically download then convert Font Awesome SVGs to PNGs
#need git, node installed, imagemagick and svgexport (npm install svgexport -g)
#First, in the folder, do :
#git clone https://github.com/FortAwesome/Font-Awesome --depth=1
task(){
svgexport Font-Awesome/svgs/$1/$2.svg pngs/$1/black/$2.png > /dev/null