Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@gwpl
gwpl / pychrome_fetch_images.py
Created July 26, 2021 07:57
pychrome scraping fetch images Chrome DevTools Protocol Viewer
import base64
import pychrome
# NOT WORKING, copied FTR as copy for "later" from:
# from https://stackoverflow.com/a/61311648/544721
def save_image(file_content, file_name):
try:
file_content=base64.b64decode(file_content)
with open("C:\\Crawler\\temp\\" + file_name,"wb") as f:
#![allow(dead_code)]
// playground: https://gist.github.com/rust-play/6d697a29901d4b82cc8b184526d4b8f1
fn all_postfixes_sorted(arr: &[&str]) -> Vec<String> {
let mut postfixes: std::collections::HashSet<String> = std::collections::HashSet::new();
for &w in arr {
for start_idx in 0..(w.chars().count()) {
let slice: &str = &w[start_idx..];
let w = String::from(slice);
#![allow(dead_code)]
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bda017580640d3b70ea211bec7e9038b
// Task: sorted postfixes for given list of strings
// Example: bcd -> bcd,cd,d
// Example: abc,bcd,xyz -> abc,bc,bcd,c,cd,d,xyz,yz,z
fn all_postfixes_sorted(arr: &[&str]) -> Vec<String> {
let mut postfixes: std::collections::HashSet<String> = std::collections::HashSet::new();
for &w in arr {
@gwpl
gwpl / docker-run.sh
Last active October 24, 2022 13:17
docker-run.sh - run command in docker just based on Dockerfile (no need for naming image etc - script uses hash of generated image)
#!/bin/bash
# https://gist.github.com/gwpl/badde4515f383665da640a2c6f98ff7a
#
# In directory with Dockerfile , you just use :
# $ docker-run.sh command...
# to run command inside dockerfile. Image hash etc will be automatically identified.
if [ -z "$0" ]; then
cat <<E
@gwpl
gwpl / Dockerfile
Created April 18, 2021 19:55
runki-git pacaur aur.archlinux.org Dockerfile AUR Archlinux Anki Ankiweb
FROM archlinux:latest
RUN pacman -Syyu --noconfirm
RUN pacman -S --noconfirm git
RUN pacman -S --noconfirm vim screen
RUN pacman -S --noconfirm base-devel
RUN pacman -S --noconfirm go go-tools
RUN pacman -S --noconfirm wget aria2 mc cmatrix htop vim
RUN git clone https://aur.archlinux.org/pacaur.git
#RUN set -x ; mkdir /home/nobody && chown -v nobody:nobody /home/nobody && cd /home/nobody/ && sudo -u nobody git clone https://aur.archlinux.org/pacaur.git && cd pacaur/ && sudo -u nobody makepkg -si
@gwpl
gwpl / Dockerfile
Last active April 21, 2021 11:03
gotty pacaur aur.archlinux.org Dockerfile AUR Archlinux
FROM archlinux:latest
RUN pacman -Syyu --noconfirm
RUN pacman -S --noconfirm git
RUN pacman -S --noconfirm vim screen
RUN pacman -S --noconfirm base-devel
RUN pacman -S --noconfirm go go-tools
RUN pacman -S --noconfirm wget aria2 mc cmatrix htop vim
RUN git clone https://aur.archlinux.org/pacaur.git
#RUN set -x ; mkdir /home/nobody && chown -v nobody:nobody /home/nobody && cd /home/nobody/ && sudo -u nobody git clone https://aur.archlinux.org/pacaur.git && cd pacaur/ && sudo -u nobody makepkg -si
@gwpl
gwpl / mime_types_check_with_strace
Last active April 12, 2021 15:02
strace checking mime Telegram handling
My Telegram was opening pdf-s in Mendeley instead of pdf reader,
(even most other apps open it in pdf reader, xdg-open etc...),
so I checked what's going on:
sf=$(mktemp --suffix=.strace.fifo)
#mkfifo "$sf"
echo "sf=$sf"
strace -o "$sf" -f telegram-desktop >/dev/null 2>/dev/null #&& rm -v "$sf"
# other terminal for clear output
sf=to_be_same_like_in_other_terminal
@gwpl
gwpl / Cargo.toml
Created December 31, 2020 19:07
playing with tracy
[package]
name = "profiling_test"
version = "0.1.0"
authors = ["root <root@localhost>"]
edition = "2018"
[dependencies]
profiling = "0.1"
tracy-client = { version = "0.10", optional = true }
@gwpl
gwpl / docker_aliases.sh
Created November 27, 2020 16:02 — forked from ropnop/docker_aliases.sh
Docker aliases
function dockershell() {
docker run --rm -i -t --entrypoint=/bin/bash "$@"
}
function dockershellsh() {
docker run --rm -i -t --entrypoint=/bin/sh "$@"
}
function dockershellhere() {
dirname=${PWD##*/}
@gwpl
gwpl / make_favicon.sh
Created October 8, 2020 11:32 — forked from nateware/make_favicon.sh
Imagemagick to create favicon.ico with 16x16 and 32x32 sizes in it
# IE is still braindead so still use favicon.ico
convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 input.png output-16x16.ico
convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 input.png output-32x32.ico
convert output-16x16.ico output-32x32.ico favicon.ico
# Then, HTML needs to specify size="XxY" as largest size due to browser bugs
<link rel="shortcut icon" href="/favicon.ico" sizes="32x32">