Skip to content

Instantly share code, notes, and snippets.

View nedzhang's full-sized avatar

Ned Zhang nedzhang

View GitHub Profile
@nedzhang
nedzhang / App.java
Last active November 24, 2018 16:45
[Java Console Application] Java Console Application - parameter check, usage, and interaction #Java #Console #display-usage #parameter
package com.nedzhang.util.jdbcverify;
//import java.nio.file.attribute.UserPrincipalLookupService;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
@nedzhang
nedzhang / check-sum.bat
Created November 24, 2018 17:21
[Windows Stuff] Windows stuff not scripting #Windows
certutil.exe -hashfile .\Downloads\VirtualBox-5.2.22-126460-Win.exe sha256
REM Result Below
REM SHA256 hash of .\Downloads\VirtualBox-5.2.22-126460-Win.exe:
REM 0c1a8f1de1c5bd18b00d81419f8190660ff36c9a5fddae4ed2c6a2216581d521
REM CertUtil: -hashfile command completed successfully.
@nedzhang
nedzhang / set-mac-os-high-sierra-vm-data.md
Last active November 28, 2018 20:09
[Mac OS VirtualBox] Install MacOS on virtualbox #macos #virtualbox

Follow installation guide from techsviewer.

Before starting the VM first time, need to setup some configuration values not exposed in VirtualBox UI. I used the script below. Run it with the VM's name as input parameter. Example: set-mac-os-high-sierra-vm-data.bat my_vm_name

set-mac-os-high-sierra-vm-data.bat


@nedzhang
nedzhang / bash_command_parsing.sh
Last active May 16, 2022 14:51
[Linux bash ninja] Bash Scripting skills #bash #linux #selinux
#!/bin/bash
usage() {
cat << EOF
NAME:
connect-ibmcloud - Connect cli to IBM Cloud
USAGE:
connect-ibmcloud [-r REGION] [-g (RESOURCE_GROUP_NAME | RESOURCE_GROUP_ID)]
@nedzhang
nedzhang / ng-serve-disable-host-check.sh
Last active November 25, 2018 15:53
[Angular nodes] Angular stuff #angular #ng
// --host=0.0.0.0 to bind to all interfaces
// --disable-host-check to avoid container refusing connection through host (url is for the host)
ng serve --host=0.0.0.0 --disable-host-check --proxy-config proxy.config.json
@nedzhang
nedzhang / docker-daemon-config-data-root-container-size.json
Created November 25, 2018 19:18
[Docker Tips] Docker and Docker Daemon stuff #docker #daemon
// Put this file as /etc/docker/daemon.json
// data-root to change where docker store data. Default /var/lib/docker
// storage-opt dm.basesize to change the container size. Default 10G
{
"debug": false,
"data-root": "/datahome/docker",
"storage-opt": [
{"dm.basesize": "20G"}
]
@nedzhang
nedzhang / how-to-run-docker-on-wsl.md
Last active November 27, 2018 23:12
[Docker on Windows Subsystem for Linux] #docker #wsl

It is possible!

You can run Docker near natively (without VM) on Windows Subsystem for Linux. It doesn't have all the functionalities but can run Node and Angular server.

Setup

Sounds great. How do I sign up?

Enable Windows Subsystem for Linux

@nedzhang
nedzhang / Install multiple Windows Subsystem for Linux.md
Last active November 27, 2018 23:31
[Install multiple copyiesWSL instance using LxRunOfflin] #wsl #linux #lxrunoffline

Multiple WSL in a Windows

Use LxRunOffline to install multiple Linux instances on Windows.

LxRunOffline installation

I used Chocolatey to install LxRunOffline

@nedzhang
nedzhang / get-duplicates-list.py
Last active December 18, 2018 07:12
[Dup file list] Search for duplicated files #python #duplicate
#!/usr/bin/python
import sys, os
# from sets import Set
import hashlib
HASH_TBD = "?"
def hashfile( filepath ):
BLOCKSIZE = 65536
@nedzhang
nedzhang / stringtonumber.py
Created March 8, 2020 15:54
[String to Number] Covert String to numbers #python #utility
# String to number testing
# Converting a string to a int64 number
# This method converts a string's first 10 characters to int64 number. It is a base27 number that
# 1. Convert the string to lowercase
# 2. map a=>1, b=>2, ..., z=>26, and anything else to 0
# 3. if it is not the 10's character, the method multiple its result by 27 and read the next character