Skip to content

Instantly share code, notes, and snippets.

View nguyyentantai's full-sized avatar
🥱
yawning

Tai Nguyen nguyyentantai

🥱
yawning
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nguyyentantai on github.
  • I am nguyyentantai (https://keybase.io/nguyyentantai) on keybase.
  • I have a public key ASDbrC8H1ihPWQgmoApPOVbSnIR9-WvA3s2Ao8wQwTeqnQo

To claim this, I am signing this object:

@nguyyentantai
nguyyentantai / solution.cpp
Created April 8, 2020 12:52
Find Middle of Linked List Leetcode
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
@nguyyentantai
nguyyentantai / solution.cpp
Last active April 15, 2020 03:43
Solution Contiguous Array Leetcode
class Solution {
public:
int findMaxLength(vector<int>& nums) {
int maxSize = 0, count = 0, size = nums.size(), count0 = 0;
for(const auto n: nums)
if(!n) ++count0;
vector<int> m(size + 1, -2); // Use -2 to mean uninitialized
@nguyyentantai
nguyyentantai / shuffle.cpp
Created August 3, 2020 19:05
random shuffle 52 cards for 4 player c++
// Example program
#include <iostream>
#include <vector>
#include <string>
#include <ctime>
using namespace std;
void printElements(vector<int> v){
for(auto it = v.begin(); it != v.end(); it++){
@nguyyentantai
nguyyentantai / Script.js
Created September 28, 2020 13:28
Switch to old Facebook UI (copy and paste in console of DevTool)
javascript:(()=>{let e=require("DTSGInitialData").token||document.querySelector('[name="fb_dtsg"]').value,t=require("CurrentUserInitialData").USER_ID||document.cookie.match(/c_user=([0-9]+)/)[1];fetch("https://www.facebook.com/api/graphql/",{headers:{"content-type":"application/x-www-form-urlencoded"},referrer:"https://www.facebook.com/",body:`av=${t}&__user=${t}&__a=1&dpr=1&fb_dtsg=${e}&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=CometTrialParticipationChangeMutation&variables={"input":{"change_type":"OPT_OUT","source":"FORCED_GROUP_ADMIN_OPT_OUT","actor_id":"${t}","client_mutation_id":"3"}}&server_timestamps=true&doc_id=2317726921658975`,method:"POST",mode:"cors",credentials:"include"}).then(e=>{console.log("Done"),location.reload()})})();
@nguyyentantai
nguyyentantai / script.js
Last active December 4, 2023 02:42
Calculate Leave requests and Available time
// ========================================================================
const MAX_LEAVE_DAYS = 21;
const maxLeaveHours = MAX_LEAVE_DAYS * 8;
const totalLeaves = {};
const durations = document.querySelectorAll('td:nth-child(5)');
durations.forEach((duration, idx) => {
if (duration.innerText.includes('hours')) {
const startDate =