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 / 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)
@jinweijie
jinweijie / Readme.md
Created April 28, 2020 06:17 — forked from leopoldodonnell/Readme.md
Install and run Postgres with an extension using docker-compose

Local Postgres

This gist is an example of how you can simply install and run and extended Postgres using docker-compose. It assumes that you have docker and docker-compose installed and running on your workstation.

Install

  • Requires docker and docker-compose
  • Clone via http: git clone https://gist.github.com/b0b7e06943bd389560184d948bdc2d5b.git
  • Make load-extensions.sh executable
  • Build the image: docker-compose build
@jinweijie
jinweijie / Demo.cs
Created February 12, 2016 13:52 — forked from rowanmiller/Demo.cs
EF6.x | Correlating SQL to code
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Infrastructure.Interception;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Demo
function createCORSRequest (poMethod, pcURL) {
var oXHR = new XMLHttpRequest();
if ('withCredentials' in oXHR) {
// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
oXHR.open(poMethod, pcURL, true);
} else if (typeof XDomainRequest != 'undefined') {
// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.