This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Easier Frontend for varnishd | |
# Example: ./httpcache.py -u google.com | |
# Then, requests to localhost:8080 forwarded to google.com and cached | |
# Licence: MIT | |
import os | |
import tempfile | |
import subprocess | |
import shutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Print the size of sections in a ELF object file/binary. Thx ChatGPT | |
size -A -d $1 | awk 'NR > 2 {print $2, $1}' | sort -n | awk '{ | |
size=$1; | |
if (size >= 1024*1024*1024) { | |
printf "%7.2f GB %-20s\n", size / (1024*1024*1024), $2; | |
} else if (size >= 1024*1024) { | |
printf "%7.2f MB %-20s\n", size / (1024*1024), $2; | |
} else if (size >= 1024) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// can be replace by std::iter::from_fn(): https://doc.rust-lang.org/std/iter/fn.from_fn.html | |
struct EitherIterator<A, B, C> | |
where | |
A: Iterator<Item = C>, | |
B: Iterator<Item = C>, | |
{ | |
either: itertools::Either<A, B>, | |
} | |
impl<A, B, C> Iterator for EitherIterator<A, B, C> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#include <stdio.h> | |
static void foo() { | |
printf("Hello from C\n"); | |
} | |
*/ | |
import "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# This script will check for commands that you could most easily contribute to tldr (https://tldr.sh/) | |
# Run it in the root of the https://github.com/tldr-pages/tldr repository | |
import os | |
import sys | |
def get_used_commands(): | |
used_cmds = {} | |
for filepath, complex in {"~/.zsh_history": True, "~/.bash_history": False}.items(): | |
with open(os.path.expanduser(filepath), "rb") as file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binattrs(cls): | |
cls._fields_ = tuple(cls.__annotations__.items()) | |
return cls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # The voice in my head told me to. Run with `php main.py.php | python` ?> | |
def getOS(): | |
<?php | |
if (PHP_OS == "Linux"){ | |
?> | |
for line in open("/etc/os-release"): | |
key, value = line.split("=") | |
if key == "ID": | |
distro_id = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Everything here prints "OK" | |
# 1 is true | |
if (( 1 )); then | |
echo "OK" | |
else | |
echo "NOT OK" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple command combination to download + start tmate anywhere | |
wget https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-amd64.tar.xz -P /tmp && tar -xvf /tmp/tmate-2.4.0-static-linux-amd64.tar.xz -C /tmp && /tmp/tmate-2.4.0-static-linux-amd64/tmate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kubeenv() { | |
DIR=$(realpath ~/.config/kube) | |
if [ $# -eq 0 ]; then | |
>&2 echo "$0: Please specify a config file or -l to list them" | |
return 1 | |
fi | |
if [[ "$1" = "-l" ]]; then |
NewerOlder