Skip to content

Instantly share code, notes, and snippets.

View k8scat's full-sized avatar
:dependabot:
I may be slow to respond.

K8sCat k8scat

:dependabot:
I may be slow to respond.
View GitHub Profile
@k8scat
k8scat / sync_home.sh
Last active April 21, 2022 04:51
Sync user home between two remote servers.
#!/bin/bash
# server1 and server2 are defined in ~/.ssh/config
users=$(ssh server1 "ls /home")
for user in ${users}; do
user_home_found=$(ssh server2 "ls /home" | grep "${user}")
if [[ -n "${user_home_found}" ]]; then
echo "user home already created: ${user}"
continue
fi
@k8scat
k8scat / github.js
Last active February 24, 2022 02:41 — forked from ye11ow/github.js
Add a "Copy link" button to Github issue and pull requests
// ==UserScript==
// @name Copy Link for GitHub Issues and PRs
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Add a "Copy link" button to Github issue and pull requests
// @author ye11ow, K8sCat <[email protected]>
// @match https://github.com/*
// @include https://github.com/*/issues/*
// @include https://github.com/*/pull/*
// @icon https://www.google.com/s2/favicons?domain=github.com
@k8scat
k8scat / gist:213820c0204f452d5c67295c406b78fd
Created January 9, 2022 13:05 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@k8scat
k8scat / main.py
Created December 4, 2021 20:17
华为4G无线路由器2 Pro 自动修改密码
import random
import string
import time
from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
LOGIN_PASSWORD = ''
@k8scat
k8scat / harbor_delete_tags.rs
Created December 3, 2021 17:46
自动清理 harbor 镜像
use std::collections::HashMap;
use std::ops::Sub;
use std::str::FromStr;
use chrono::Duration;
use chrono::prelude::*;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
extern crate base64;
const HARBOR_BASE_API: &str = "";
### Keybase proof
I hereby claim:
* I am k8scat on github.
* I am k8scat (https://keybase.io/k8scat) on keybase.
* I have a public key whose fingerprint is 9136 F38B 2DC8 7ABB 204B D0D6 CFB6 A936 4A3D 8FF5
To claim this, I am signing this object:
@k8scat
k8scat / unprotect_gitlab_branches.py
Last active August 21, 2021 07:14
Batch Unprotect GitLab protected_branches via python
import requests
import json
import logging
class GitLab:
token = ''
auth_headers = None
base_api = 'https://gitlab.com/api/v4'
client = None
@k8scat
k8scat / git-template.sh
Created August 4, 2021 17:10
git-template
# centos: cd /usr/share/git-core/templates/
# https://stackoverflow.com/questions/2293498/applying-a-git-post-commit-hook-to-all-current-and-future-repos
git config --global init.templatedir '~/.git_template'
@k8scat
k8scat / git-fetch.sh
Last active August 4, 2021 05:43
git-fetch
# Delete local tags
git tag -l | xargs git tag -d && git fetch origin
# Prune local branches
git fetch origin --prune -q
# Prune local branches/tags
git fetch origin --prune --prune-tags -q
@k8scat
k8scat / install_openresty.sh
Last active March 12, 2024 04:48
Install OpenResty on Ubuntu from source code.
#!/bin/bash
set -e
rm -rf openresty-1.19.3.2 openresty-1.19.3.2.tar.gz
apt-get update -y
apt-get install -y libpcre3-dev \
libssl-dev \
perl \
make \
build-essential \