Skip to content

Instantly share code, notes, and snippets.

View tshu-w's full-sized avatar
🤯
Exploring

Tianshu Wang tshu-w

🤯
Exploring
View GitHub Profile
@tshu-w
tshu-w / save_safari_tabs.scpt
Last active February 3, 2023 03:24
Save all safari tabs in a single file and reopen them with a double click.
-- Detect if the Safari window exists
tell application "System Events"
if not (exists (front window of process "Safari")) then
return
end if
end tell
-- Assume the frontmost Finder window (or the Desktop)
-- is where we want to store the script.
try
@tshu-w
tshu-w / stlib.cpp
Created December 15, 2016 03:19
ACM/ICPC header
#include <bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
// #define __DEBUG__
#ifdef __DEBUG__
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define filename ""
@tshu-w
tshu-w / Meisell-Lehmer.cpp
Created October 12, 2016 09:57
calculate the prime number lower and equal than n quickly.
#include<bits/stdc++>
/Meisell-Lehmer
const int MAX_N = 5e6 + 2;
bool np[MAX_N];
int prime[MAX_N], pi[MAX_N];
int getprime()
{
int cnt = 0;
np[0] = np[1] = true;
pi[0] = pi[1] = 0;