Skip to content

Instantly share code, notes, and snippets.

View minghao912's full-sized avatar

Ming minghao912

View GitHub Profile
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException e) {
System.out.println(e);
} catch (ClassNotFoundException e) {
System.out.println(e);
} catch (InstantiationException e) {
System.out.println(e);
} catch (IllegalAccessException e) {
System.out.println(e);
@minghao912
minghao912 / bestIDE_mac.java
Last active August 12, 2019 02:57
The best IDE ever created by man
import java.awt.List;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.charset.Charset;
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class bestIDE_mac {
@minghao912
minghao912 / layout.kbd.json
Created July 23, 2020 19:08
Untitled Keyboard Layout
[
[
"Esc",
{
"x": 1
},
"F1",
"F2",
"F3",
"F4",
@minghao912
minghao912 / config.h
Last active September 13, 2020 18:14
Custom keyboard layout combining ISO Enter and ANSI long shift. Keyboard made using QMK's Proton C controller.
/* Copyright 2020 minghao912
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@minghao912
minghao912 / myanimelistcustom.css
Last active November 1, 2020 03:13
Custom CSS for MAL
/* "Brink" by Valerio Lyndon
* Version 1.5.0
*
* = TABLE OF CONTENTS =
*
! IMPORTS
*
! VARIABLES
@ User
@ Internal
@minghao912
minghao912 / keymap.c
Created September 13, 2020 18:15
Keymap for custom keyboard
/* Copyright 2020 minghao912
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@minghao912
minghao912 / cloudflare-worker.js
Created December 22, 2020 20:05
Cloudflare Worker to route URLs to different ports based on their protocol
addEventListener('fetch', event => {
const request = event.request;
let url = new URL(request.url);
console.log(request.url);
console.log(url);
if (url.protocol == "http:")
url.host = 'dragonfruit.tk:8080';
else if (url.protocol == "https:")
@minghao912
minghao912 / CheckValidity.cpp
Last active July 31, 2021 05:21
Checks if a given hand is a valid Mahjong hand
#include "CheckValidity.h"
#include <iostream>
using namespace std;
int main() {
vector<int> hand = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6};
string validHand = (isValidHand(hand)) ? "true" : "false";
cout << "Hand is valid: " << validHand << endl;
@minghao912
minghao912 / TextSwapper.js
Last active August 9, 2021 05:18
For a club website, will switch out heading text on a delay
// Change these as you see fit
const BLOCKID = "#block-7c7d6afc1405682f08c2"; // block ID of Squarespace block, found via Inspect Element
const TEXT = ["text 1", "text 2", "text 3"];
const DELAY = 1000; // in milliseconds
let currentIndex = 0;
function textChanger() {
console.log("fire");
@minghao912
minghao912 / hw2_better.c
Last active October 9, 2022 02:55
Math 170E HW 2 Question 6
/**
* First, compile the program using clang or gcc
* Then, run the program using: ./hw2_better <value of N> <number of runs> <print? T/F=1/0>
* Output is in the file 'out.data', with each run on its own line
* ---
* Example run: ./hw2_better 20 1 1 will run the program once with N=20, printing out the
* contents of the handshake array (how many times each pair of students shook hands)
*
* Example output:
* 0 1 2 3 4