Skip to content

Instantly share code, notes, and snippets.

View masonwan's full-sized avatar

Mason Wan masonwan

View GitHub Profile

FFmpeg

A list of useful ffmpeg commands

See the video meta data

ffprobe video.mp4
@masonwan
masonwan / -handle-chrome-search-engines
Last active July 11, 2024 15:24
Better way to manage Chrome's search engines
Keep for gist name
@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 / upstart-template.conf
Created June 8, 2015 07:13
A basic Upstart script
#!upstart
#
# Copy me to /etc/init/
# This installs a daemon as a system level call and ensures the process can be monitored and is consistently restarted on error.
# Manual start, stop, and restart respected.
#
description 'An Upstart configuration tempalte'
# Let upstart attempt to restart the daemon on error, exit, or otherwise non-manual termination
@masonwan
masonwan / -setup-scripts
Last active November 28, 2022 07:43
A set of shell scripts to set up
For Gist title
@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 / 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 / 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 / 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 / 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