Skip to content

Instantly share code, notes, and snippets.

View masonwan's full-sized avatar

Mason Wan masonwan

View GitHub Profile

Copy the following code into the URL of your bookmark.

javascript:openAiTabs();function openAiTabs(){const t=URL.parse(location.href);let e=t.searchParams.get("q");e==null&&(e=`tldr ${t}`),search(e)}function search(e){const t=["https://www.google.com/search?udm=50&q=%s","https://chatgpt.com/?hints=search&q=%s","https://grok.com/?q=%s","https://www.perplexity.ai/search/?copilot=false&q=%s"];t.forEach(t=>{window.open(t.replace("%s",e),"_blank")})}

The unminified version

// It opens popular AI search with the query parameter in the URL (`?q=`).
@masonwan
masonwan / fade-unwanted-meals.js
Created February 24, 2025 01:17
The script works with HelloFresh.com. It fades out veggie, vegan, no-cook, or anything with extra fee. It works best to be a bookmarklet.
const unwantedTags = [
'Veggie',
'Vegan',
'No Cook',
]
const menuElms = [...document.querySelectorAll(`#page > div > div > div > div > div.sc-54d3413f-0.cWKOLc > div.sc-54d3413f-0.cAaXLm > div > div > div`)]
const meals = menuElms
.map((menuElm, i) => {
fadeOutUnwantedMeals(menuElm)

Problem

When install Windows on a older devices, many devices could potentially wake up the computer from the sleep mode.

It's possible to identify them using the Event Viewer. But it's always a hassle.

Solution

Run the following PowerShell in terminal to disable all devices capable to wake the computer. And then identify the devices we really want to wake the computer in Device Manager, and set thier Power Management.

FFmpeg

A list of useful ffmpeg commands

See the video meta data

ffprobe video.mp4
@masonwan
masonwan / -manage-chrome-search-engines.md
Last active July 25, 2025 10:38
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.

@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 / -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.*"