Skip to content

Instantly share code, notes, and snippets.

View KokoseiJ's full-sized avatar
🏠
Y'all, Stay home with your IDE.

Kokosei J KokoseiJ

🏠
Y'all, Stay home with your IDE.
View GitHub Profile
@KokoseiJ
KokoseiJ / goindex_clone.py
Last active July 8, 2022 02:08
Clone GoIndex recursively
#
# Requires requests module.
# First argument is the URL to the target goindex- this one is necessary, obviously.
# Second argument is the folder of the name where the contents will be stored-
# defaults to 'goindex_download' if not provided.
# Other arguments will be ignored.
#
# Since my target had an unstable worker which throws 500 quite frequently,
# `request` method automatically retries the request until it receives 200.
# The delay is hardcoded to 1 second- you can change it if you want.
@KokoseiJ
KokoseiJ / btmp_ban
Created May 1, 2021 20:08
Automatically ban IPs logged in btmp via firewall-cmd
#!/usr/local/bin/python3
"""
This is a quick and dirty solution I wrote in 10 minutes, which then I piled more stuffs
without properly reorganizing the code.
It surely works, but is ugly, slow, and a mess.
`ipblack` list includes IP address prefixes that should be excluded from being banned.
this includes internal IP, and maybe IP from your ISP's cellular in case you want to
connect to your server from the outside.
@KokoseiJ
KokoseiJ / oneindex_clone.py
Last active May 2, 2021 18:05
Clone OneIndex recursively
#
# Requires requests, bs4 module.
# also you need wget binary on your system too.
# First argument is the URL to the target oneindex- this one is necessary.
# Second argument is the folder of the name where the contents will be stored-
# defaults to 'oneindex_download' if not provided.
# Other arguments will be ignored.
#
import os
@KokoseiJ
KokoseiJ / urlcheck.py
Created May 2, 2021 18:07
Check if URLs are alive, in specific interval
import time
import requests
with open("urldata", "r") as f:
data = f.read().split("\n")
interval = int(data[0])
url_list = [x for x in data[1:] if x]
maxlen = max(map(len, url_list))
@KokoseiJ
KokoseiJ / I'm a night 🦉
Last active October 1, 2021 00:13
I'm a night 🦉
🌞 Morning 59 commits ██▋░░░░░░░░░░░░░░░░░░ 13.0%
🌆 Daytime 50 commits ██▎░░░░░░░░░░░░░░░░░░ 11.0%
🌃 Evening 111 commits █████▏░░░░░░░░░░░░░░░ 24.4%
🌙 Night 234 commits ██████████▊░░░░░░░░░░ 51.5%
@KokoseiJ
KokoseiJ / toggle_fullscreen.sh
Created August 2, 2021 07:38
Toggle fullscreen on Spotify in Linux
#!/bin/bash
xwininfo -root -tree | grep '("spotify" "Spotify")' | grep -oE '(0x[0-9a-z]{7,8})' | xargs -I % wmctrl -i -r % -b toggle,fullscreen
@KokoseiJ
KokoseiJ / gist:e4b7f9d5b129fbbfad9092a9a8fd708d
Created August 19, 2021 16:13
Batch convert FLAC to ALAC recursively
find /music -iname "*.flac" -print0 | xargs -P 16 -0 -I @ bash -c 'temp="@"; name="$(echo $temp | sed -E "s/\/.*?\///" | sed "s/.flac//")"; echo $name; ffmpeg -hide_banner -loglevel warning -i "$temp" -c:v copy -c:a alac -ar 44100 "/mnt/d/ALAC/$name.m4a"'
@KokoseiJ
KokoseiJ / Dockerfile
Last active April 26, 2022 05:37
openbox docker with VNC
FROM ubuntu:latest
ENV DISPLAY=:99
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y openbox xvfb x11vnc
CMD rm -rf /tmp/.X99-lock && \
Xvfb $DISPLAY -screen 0 1280x1024x24 & \
openbox & \
@KokoseiJ
KokoseiJ / tree.c
Last active December 11, 2021 09:35
Simple Int Binary Tree Implementation For C
#include <stdio.h>
#include <stdlib.h>
struct Node {
int key;
void *data;
struct Node *left, *right, *parent;
};
struct Node *insertNode(struct Node *node, int key, void *data) {
@KokoseiJ
KokoseiJ / list.c
Created December 17, 2021 08:03
Simple *char-key linked list implementation
#include "llist.h"
Linkedlist *llist_put(Linkedlist *list, char *key, void *value) {
if (list == NULL) {
list = calloc(1, sizeof(Linkedlist));
*list = (Linkedlist) {key, value, NULL};
return list;
}
if (!strcmp(key, list->key)) {