Skip to content

Instantly share code, notes, and snippets.

View minghao912's full-sized avatar

Ming minghao912

View GitHub Profile
@minghao912
minghao912 / hw3q1.py
Last active March 10, 2023 02:04
C&EE 185/285 HW3 Q1: Code for Monte Carlo Simulation
import random
# Values given in table 3
# In the format [car, transit, taxi]
given_mode_choice_probabilities = [
[0.75, 0.23, 0.02],
[0.93, 0.06, 0.01],
[0.21, 0.41, 0.38],
[0.09, 0.24, 0.67],
[0.66, 0.13, 0.21],
@minghao912
minghao912 / attempt.ipynb
Created November 4, 2022 23:39
C&EE 181/281 HW 2 Q4
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@minghao912
minghao912 / hw4q3.ipynb
Created October 20, 2022 01:56
MATH 170E HW 4 Q3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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 / 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 / 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 / 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 / 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 / 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