Skip to content

Instantly share code, notes, and snippets.

View HUGHNew's full-sized avatar
摸鱼中

Hugh Liu HUGHNew

摸鱼中
View GitHub Profile
@HUGHNew
HUGHNew / server.js
Last active February 18, 2022 07:58
exmaple server to fetch public ip address
// get your public ip of the subnet
// base code fetch from <https://nodejs.dev/learn/build-an-http-server>
// how to run? : `node ./GetPublicIpAddrServer.js`
const http = require('http')
const port4 = 12345
const port6 = 12346
const svn_fn = (req, res) => {
res.statusCode = 200
@HUGHNew
HUGHNew / time_example.kt
Created February 18, 2022 07:57
time-relative functions in Kotlin/Java
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.format.DateTimeFormatter
fun main(){
print("local date: ${LocalDate.now()}") // 2022-02-18
print("local time: ${LocalTime.now()}") // 15:46:05.838
print("instant now: ${Instant.now()}"); // 2022-02-18T07:46:05.838Z
@HUGHNew
HUGHNew / ch_src.sh
Created February 21, 2022 09:41
Maybe works for Debian and its derivative versions which use apt/dpkg as package manager
#!/bin/bash
set -e
fn=sources.list
sfn=/etc/apt/$fn
ali="mirrors.aliyun.com"
ustc="mirrors.ustc.edu.cn"
ts="mirrors.tuna.tsinghua.edu.cn"
raw="$(awk -F / '{print $3}' /etc/apt/sources.list.raw |grep -v "^$"|head -n 1)"
cp $sfn ./$fn
sudo mv $sfn $sfn.raw
@HUGHNew
HUGHNew / docker-snippet.sh
Created February 28, 2022 04:34
some bash code snippet for docker operation(updating)
alias Docker="sudo docker"
# rm <none> images which is generated by error when building
Docker rmi $(Docker images|grep none|awk '{print $3}'|xargs)
# remove all containers
Docker rm $(Docker ps -aq|xargs)
#!/bin/bash
# need parameters check
sudo useradd --create-home --groups sudo --shell /bin/bash $1
# useradd -m -G sudo -s /bin/bash $1
echo -e -n "$2\n$2" | passwd $1
# Set-ExecutionPolicy RemoteSigned # enable script exec
#------------------------ Import BEGIN ---------------------------#
Import-Module PSReadLine # Install-Module -Name PSReadLine
# to know more: https://github.com/PowerShell/PSReadLine/blob/master/README.md
#------------------------------- Set Hot-keys BEGIN -------------------------------
# 设置 Tab 键补全
# Set-PSReadlineKeyHandler -Key Tab -Function Complete
# 命令行使用 Emacs 模式 (与Bash一致)
Set-PSReadLineOption -EditMode Emacs
#!/bin/env bash
#
# lework
# Os repo mirror site speed test.
######################################################################################################
# environment configuration
######################################################################################################
@HUGHNew
HUGHNew / spirits_compose.py
Created April 3, 2023 12:40
Stitching equal parts of the picture
import requests as reqs
from PIL import Image
urls = [ # your images in group
[
"", "", ""
],
[],
[]
]
@HUGHNew
HUGHNew / concat.py
Created June 25, 2023 05:17
concat screenshots in vertical view
"""
for Android Termux images concat vertically usage
requirements.txt:
pillow
typer
mannul installation
typer: pip
pillow:
@HUGHNew
HUGHNew / clash-corpse.md
Last active November 3, 2023 13:01
Cyber-tombstone for clash and clash family