Skip to content

Instantly share code, notes, and snippets.

@stvhwrd
stvhwrd / website-dl.md
Last active March 13, 2024 17:05
Download an entire website for offline use with wget. Internal inks will be corrected so that the entire downloaded site will work as it did online.

The best way to download a website for offline use, using wget

There are two ways - the first way is just one command run plainly in front of you; the second one runs in the background and in a different instance so you can get out of your ssh session and it will continue.

First make a folder to download the websites to and begin your downloading: (note if downloading www.SOME_WEBSITE.com, you will get a folder like this: /websitedl/www.SOME_WEBSITE.com/)


STEP 1:

@stvhwrd
stvhwrd / LeetCodeQuestions.md
Last active March 2, 2024 06:38 — forked from krishnadey30/LeetCodeQuestions.md
Curated List of Top 75 LeetCode
@stvhwrd
stvhwrd / hide-iterm-dock-icon.md
Last active November 3, 2023 16:18
Hide the iTerm dock icon on Mac OS X

Note: you can now configure this simply in iTerm2's application settings. Go to Preferences > Appearance > System and select "Exclude from Dock and ⌘-Tab Application Switcher".


On my dual-drive MacBook Pro I have remapped the eject key to F13 using Karabiner and NoEjectDelay. The eject key has been assigned as the hotkey for a guake-style visor terminal using iTerm2. Having its own hotkey precludes the need for an icon, so I prefer to hide the iTerm dock icon.

To hide the dock icon of iTerm2 on Mac OS X:

/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
@stvhwrd
stvhwrd / launchpad-reset.md
Last active May 10, 2023 21:31
Delete and rebuild LaunchPad on Mac OS X to improve appearance and eliminate obsolete app icons

####First - reset LaunchPad:

defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock

####Second - rebuild the database:

rm ~/Library/Application\ Support/Dock/*.db; killall Dock
@stvhwrd
stvhwrd / combine-pdf.md
Last active March 26, 2023 11:19
Combining PDF files on the command line in OSX

###While this script does concatenate pdf files, I haven't yet figured out in which order it does so. On a sample of 19 pdf files, logically named 01something.pdf, 02something.pdf, 03something.pdf, etc. the order of the merged product seemed almost random...

...from Tiger onwards, OSX ships with a Python script that concatenates pdf files (merges them together). The script is already executable, and Python is pre-installed on OS X, so all you need to do is point it at your pdf files and run

"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o PATH/TO/YOUR/MERGED/FILE.pdf /PATH/TO/ORIGINAL/1.pdf /PATH/TO/ANOTHER/2.pdf /PATH/TO/A/WHOLE/DIR/*.pdf

I prefer putting the link in /usr/local/bin, as it is in the $PATH and therefore I can run the command from anywhere. To set up the link, you need to navigate to the directory where you want the link.

@stvhwrd
stvhwrd / Vultr Ubuntu startup script.sh
Last active November 22, 2021 14:11
Setting up a general web dev Ubuntu VPS
# Startup script for Ubuntu 17.04 VPS on Vultr (Dev machine and cloud server)
# add a new user @todo: make this a one-liner
# adduser stvhwrd
# usermod -aG sudo stvhwrd
## MANUALLY LOG OUT AS ROOT AND LOG IN AS NEW USER
# OPTIONAL: to add ssh key, assuming that you have ssh-copy-id installed on local machine and your keypair is in ~/.ssh and named id_rsa:
# Locally, i.e. on your laptop. eg. ssh-copy-id stvhwrd@45.63.10.205
@stvhwrd
stvhwrd / .. Sync Settings for Sublime Text
Last active October 28, 2021 15:39
Sync Settings for Sublime Text 3
https://packagecontrol.io/packages/Sync%20Settings
@stvhwrd
stvhwrd / setup_tmux_zsh.sh
Last active July 9, 2020 04:20
Install tmux and zsh on a remote server without root
#!/usr/bin/env bash
# Connect to the server..
# ssh username@server_ip
mkdir ~/.local;
# Download source and build libevent
cd /tmp;
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz;
tar xvfz libevent-2.1.8-stable.tar.gz;
@stvhwrd
stvhwrd / manual-squash-commit.md
Last active April 3, 2020 19:10
Local steps for a nice clean squashed git commit.

Squashing git commits into one atomic commit

See Git-Branching-Rebasing for the built-in way. Here's how to do it manually:


Preconditions: On a new branch, forked off of develop and now ready to merge back into develop.

  1. Fetch updates from remote
@stvhwrd
stvhwrd / curl_loop.sh
Last active December 21, 2019 02:01
Submit CURL requests in a loop with approximate RPS calculation
# Submit CURL requests in a loop with rough RPS calculation
# Example usage: `make_requests 10.0.5.28`
_call($1) {
num_requests=0;
start_time="$(date -u +%s)";
base_url="$1/entities/"
sleep_time=5