Skip to content

Instantly share code, notes, and snippets.

View jeromew21's full-sized avatar
🏠
Working from home

Jerome Wei jeromew21

🏠
Working from home
View GitHub Profile
@jeromew21
jeromew21 / template.tex
Last active October 24, 2021 07:32
basic LaTeX math homework or notes template
\documentclass[letterpaper,11pt]{article}
\usepackage[margin=1in,footskip=0.25in]{geometry}
\usepackage{titlesec} % tbh i forgot why this is here
\usepackage[parfill]{parskip} % this makes paragraph indentation consistent
\usepackage{amsthm, amssymb, amsmath} % math packages
\newcommand{\sectionbreak}{\clearpage} % optional: this pagebreaks at every section
% optional: common shorthands
\newcommand{\bb}[1]{\mathbb{#1}}
@jeromew21
jeromew21 / Get subprocess output.py
Last active June 30, 2022 23:14
Run a shell command in Python and capture stdout
# Blocking version with `run`
output = subprocess.run(['ls', '-l'], capture_output=True).stdout.decode()
w, h = 8, 8
fig, ax = plt.subplots(w, h, sharex='col', sharey='row', figsize=(20,20))
for i in range(w*h):
a = ax[i//h][i%w]
plt.show()
sudo dd bs=4M if={PATH_TO_ISO} of=/dev/{DEVICE} conv=fdatasync status=progress
valgrind --tool=callgrind ./{}
./gprof2dot.py -f callgrind callgrind.out.{} | dot -Tsvg -o output.svg
@jeromew21
jeromew21 / wget_recursive.sh
Last active August 10, 2019 03:54
Download a website with one command
wget --recursive -e robots=off --random-wait --user-agent=Mozilla/5.0 http://example.com
#include <fstream>
//STUFF
std::ofstream fileout;
fileout.open("filename.txt", std::ios_base::app);
fileout << "hello world";
//STUFF
@jeromew21
jeromew21 / chrono_timer.cpp
Last active October 4, 2019 21:28
Simple execution timer (C++)
#include <chrono>
/*
* ...
*/
auto start = std::chrono::high_resolution_clock::now();
/*
* do stuff
*/
@jeromew21
jeromew21 / requests_useragent.py
Last active August 31, 2021 20:06
spoof a web browser with Python
r = requests.get(url, headers={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
})
@jeromew21
jeromew21 / spacemacs-cheshe.md
Created March 28, 2019 20:04 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers