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 / firefoxheadless.py
Last active March 4, 2021 19:06
[Python] Start Selenium Firefox driver in headless (invisible) mode.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
options = Options()
options.set_headless(True)
binary = FirefoxBinary("/usr/bin/firefox") #Linux. In Windows/Mac this is different
driver = webdriver.Firefox(firefox_options=options, firefox_binary=binary)
print("started firefox in headless mode")
@jeromew21
jeromew21 / git_frontend.py
Last active July 30, 2019 22:08
Tired of git add .; git commit -m "made some changes"; git push origin master? Are you a strong independent big brain who don't need no branches? Now you can add-commit-push in one command. Git frontend for remote repos
#!/usr/bin/python3
import os
import sys
from random import choice
if len(sys.argv) > 1 and sys.argv[1] == "show":
from subprocess import Popen, PIPE
import webbrowser
@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
@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 / 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
*/
#include <fstream>
//STUFF
std::ofstream fileout;
fileout.open("filename.txt", std::ios_base::app);
fileout << "hello world";
//STUFF
@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
valgrind --tool=callgrind ./{}
./gprof2dot.py -f callgrind callgrind.out.{} | dot -Tsvg -o output.svg
sudo dd bs=4M if={PATH_TO_ISO} of=/dev/{DEVICE} conv=fdatasync status=progress
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()