Skip to content

Instantly share code, notes, and snippets.

View jinweijie's full-sized avatar
🎾

Weijie JIN jinweijie

🎾
View GitHub Profile
@jinweijie
jinweijie / KillPortOwner.cs
Created August 31, 2023 13:54 — forked from SteveSyfuhs/KillPortOwner.cs
Finding and killing a socket owner by port
public static void KillExistingHosts(int port)
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
return;
}
using (var existing = Win32.FindProcessOwner(port))
{
@jinweijie
jinweijie / proxy.md
Created April 3, 2023 01:18 — forked from yougg/proxy.md
complete ways to set http/socks/ssh proxy environment variables

set http or socks proxy environment variables

# set http proxy
export http_proxy=http://PROXYHOST:PROXYPORT

# set http proxy with user and password
export http_proxy=http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT

# set http proxy with user and password (with special characters)
@jinweijie
jinweijie / RSA_SignAndVerify.cs
Created March 6, 2023 13:15 — forked from itsho/RSA_SignAndVerify.cs
RSA - create signature and verify
// ----------------------------------------------------
// Notice, this code is using BouncyCastle NuGet:
// https://www.nuget.org/packages/BouncyCastle/1.8.4/
// Created by: Itsho
// Creation Date: 20 December 2018
// ----------------------------------------------------
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Generators;
@jinweijie
jinweijie / set-docker-proxy.sh
Last active January 22, 2022 14:27
Set proxy for Docker to run minikube.
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
sudo chmod 777 /etc/systemd/system/docker.service.d/proxy.conf
sudo echo '
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890/"
Environment="HTTPS_PROXY=http://127.0.0.1:7890/"
Environment="NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.39.0/24"
' >> /etc/systemd/system/docker.service.d/proxy.conf
sudo systemctl daemon-reload
@jinweijie
jinweijie / .imwheelrc
Created December 31, 2021 01:17
Fix mouse scroll with imwheel for Kubuntu with VMWare
".*"
None, Up, Button4, 3
None, Down, Button5, 3
Control_L, Up, Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L, Up, Shift_L|Button4
Shift_L, Down, Shift_L|Button5
@jinweijie
jinweijie / GeoHelper.cs
Last active December 27, 2021 06:35
Shrink Geo Coordinates Evenly
public class GeoHelper
{
public static List<GeoLocation> ShrinkCoordinates(
List<GeoLocation> coordinates,
int count,
bool removeDuplication = true,
bool isClosedLoop = false)
{
if (coordinates == null || coordinates.Count <= 1)
return coordinates;
@jinweijie
jinweijie / docker-load-and-push.sh
Created January 22, 2021 15:37 — forked from stefanvangastel/docker-load-and-push.sh
Bash scripts to pull, (optional) retag, save, load and push Docker images. Created to provide easy means to download an image, retag it to use a private registry and then save it to an external disk. In a offline or on-premise environment you can use the load and push script to load images and push them to a private registry.
#!/bin/bash
#### Functions ###
display_usage() {
echo "This script must be run with Docker capable privileges and you should login to your registry before pushing!"
echo -e "\nUsage:\n$0 <saved_image> [--push]\n"
echo -e " <saved_image>\t\t\tThe image file to load and push"
echo -e " [--push]\t\t\tPush to registry"
echo -e "\nExample: $0 /mydir/ubuntu.tar --push "
}
@jinweijie
jinweijie / getopt-boilerplate.sh
Created May 19, 2020 15:56 — forked from runswithd6s/getopt-boilerplate.sh
BASH Script Boilerplate
#!/usr/bin/env bash
################################################################################
# Boilerplate Shell Script with getopt parsing
#
# This script is released to the Public Domain by Chad Walstrom
# Chad Walstrom <chewie@wookimus.net>.
################################################################################
NOACT=0
NAME=$(basename $0|sed 's/\(\..*\)$//')
VERSION="0.1"
#!/bin/sh
#
# Postgresql backup script
# http://www.bitweaver.org/wiki/pg_backup+PostgreSQL+backup+script
#
# Author
# |
# +-- speedboy (speedboy_420 at hotmail dot com)
# +-- spiderr (spiderr at bitweaver dot org)
# +-- flexiondotorg (code at flexion dot org)