Skip to content

Instantly share code, notes, and snippets.

@Roytangrb
Roytangrb / save-my-solution.js
Last active May 2, 2023 02:05
Tampermonkey script to save Leetcode question No., name, URL and current code in editor to a download file
// ==UserScript==
// @name Save My Solution
// @namespace https://gist.github.com/Roytangrb/7df5bd7c0321debb9df8e539662b08ea
// @version 2.2
// @updateURL https://gist.githubusercontent.com/Roytangrb/7df5bd7c0321debb9df8e539662b08ea/raw/save-my-solution.js
// @downloadURL https://gist.githubusercontent.com/Roytangrb/7df5bd7c0321debb9df8e539662b08ea/raw/save-my-solution.js
// @description Save Leetcode question No., name, URL and current code in editor to a download file
// @author Roy Tang
// @match https://leetcode.com/problems/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
@Roytangrb
Roytangrb / .zshrc
Last active January 29, 2022 10:43
Notify me on command exit if the prompt submitting the command is not in foreground
setopt prompt_subst
# Remember to chmod +x for these scripts
alias notifyme='~/notifyme.scpt'
alias frontapp='~/frontapp.scpt'
# Set Applcation of the current prompt
export APP_OF_PS1=$(frontapp)
# Adapted from: https://frantic.im/notify-on-completion/
@Roytangrb
Roytangrb / .zshrc
Last active December 11, 2021 15:36
My mac zsh config
# prompt
# include important env variable in prompt
PROMPT='$ENVIRONMENT_NAME %B%F{240}%2~%f %# '
# custom zsh config
# UP and DOWN startsWith search
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
@Roytangrb
Roytangrb / hexgame.cpp
Last active December 14, 2020 14:01
Hex Game with C++ 11 STL
/**
* Hex game implementation (use g++ -std=c++11 hexgame.cpp)
* By RT
* 12th Dec, 2020
*/
#include <iostream>
#include <iomanip>
#include <string>
#include <tuple>
@Roytangrb
Roytangrb / dijkstra_prim.cpp
Last active December 9, 2020 15:42
Implement Dijsktra's & Prim's algorithms
// Implement Dijsktra's algorithm, calc avg shortest path length & MST
// By RT
// 9th Dec, 2020
#include <iostream>
#include <chrono>
#include <random>
#include <vector>
#include <iterator>
#include <fstream>
@Roytangrb
Roytangrb / bst-inorder.c
Last active November 28, 2020 05:26
BST & inorder
/*
* Create BST from file read
* By RT
* 24 Nov, 2020
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
@Roytangrb
Roytangrb / file-io.c
Created November 22, 2020 16:43
File I/O
/*
* Read int from file and calc avg
* By RT
* 23 Nov, 2020
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
@Roytangrb
Roytangrb / dedupe.c
Last active November 22, 2020 08:59
Remove duplicates in a sorted list
/*
* Remove duplicate from a sorted doubly linked list
* By RT
* 22 Nov, 2020
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@Roytangrb
Roytangrb / list.c
Last active November 22, 2020 08:49
List struct and bubble sort
/*
* Bubble sort a list
* By RT
* 22 Nov, 2020
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@Roytangrb
Roytangrb / poker.c
Created November 21, 2020 16:57
Poker Hands Probabilities
/*
* Card Struct
* By RT
* 21 Nov, 2020
*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>