Skip to content

Instantly share code, notes, and snippets.

View masonwan's full-sized avatar

Mason Wan masonwan

View GitHub Profile
@masonwan
masonwan / Shutdown-MySQL.ps1
Last active December 23, 2015 19:19
PowerShell script for running stuffs on Windows
# From <http://blogs.msdn.com/b/powershell/archive/2007/06/19/get-scriptdirectory.aspx>
function Get-ScriptDirectory {
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$dir = Get-ScriptDirectory
$cmd = $dir + '\bin\mysqladmin.exe'
& $cmd -u root shutdown
@masonwan
masonwan / printAllColors.sh
Last active December 25, 2015 09:19
Print all possible combinations of bash colors, according to [Advanced Bash-Scripting Guide](http://www.tldp.org/LDP/abs/html/colorizing.html)
#! /bin/bash
for isBold in {0..1}; do
for background in {40..47}; do
for foreground in {30..37}; do
colorTag='\e['$isBold';'$foreground';'$background'm'
colorResetTag='\e[0m'
text=$colorTag'isBold:'$isBold' foreground:'$foreground' background:'$background$colorResetTag
echo -e $text
done
@masonwan
masonwan / DbBenchmark.md
Created November 18, 2013 04:48
DbBenchmark.md

Screenshot

Output

Search all books which the title starts with "Survival".
========================================
Use normal query
28.2 ms
Use stored procedure
@masonwan
masonwan / grep-color.sh
Last active June 12, 2023 18:55
Print out Tomcat log file "catalina.out" with color
tail -200 catalina.out | ack-grep --flush --passthru --color --color-match=red "^.*ERROR.*" | ack-grep --flush --passthru --color --color-match=green "^.*DEBUG.*"
@masonwan
masonwan / JVM vs .NET.md
Created December 23, 2013 20:00
JVM vs .NET.md

Type erasure

  • Genetic
  • Reflection
  • Static method

In Java, it's impossible to get current class/type in static method. The C# code would be.

// C#
public static Type GetType() {
 return MethodBase.GetCurrentMethod().DeclaringType;
@masonwan
masonwan / seller-central-id-guide.md
Last active August 29, 2015 14:07
This is a guide with screenshots to get the app ID, client ID, and client secret from Amazon Seller Central.

Overview

This is a guide with screenshots to get the app ID, client ID, and client secret from Amazon Seller Central.

Step 1: Log in Amazon Seller Central

Go to Amazon Central and log in with your credentials.

Log in

@masonwan
masonwan / -setup-scripts
Last active November 28, 2022 07:43
A set of shell scripts to set up
For Gist title
@masonwan
masonwan / global-error-handler-example.html
Last active November 13, 2022 19:21
How to handle global error correct
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
let element
console.log(`Registering window error`)
@masonwan
masonwan / -manage-chrome-search-engines.md
Last active October 20, 2025 15:06
Better way to manage Chrome's search engines

Problem

Chrome has the feature to automatically add search engine when it detects an input field on websites. After using Chrome months, it often resutls a bunch of search engines stayed in the settings. And the setting page does not provide a convinient way to remove them.

Updates on 2024-11-21

The editting the Web Data as SQLite file did not seem to work anymore. Chrome seems to revert all the changes when restart.

To make it even worse, it seems that the DOM tree is not accessable from the development console on the setting page, so even a bookmarklet could not work. Neighter does Chrome provide an API to access the search engines.

FFmpeg

A list of useful ffmpeg commands

See the video meta data

ffprobe video.mp4