Skip to content

Instantly share code, notes, and snippets.

View letam's full-sized avatar
🐢
Sometimes remembering to breathe.

Tam Le letam

🐢
Sometimes remembering to breathe.
View GitHub Profile
@letam
letam / pycharm
Last active November 28, 2023 19:56
pycharm setup for sublime merge
#!/bin/sh
open -na "PyCharm.app" --args "$@"
# # Notes for PyCharm command-line launcher script:
# ## Installation (Ref: https://www.jetbrains.com/help/pycharm/working-with-the-ide-features-from-command-line.html):
# Place this file in: /usr/local/bin/pycharm
@letam
letam / darknight.py
Created August 10, 2023 14:09
iTerm2 console script to change color preset based on time
#!/usr/bin/env python3.7
# Daemon script for iTerm2, to change color preset based on time of day
# Simpler than https://iterm2.com/python-api/examples/darknight.html#darknight-example
import asyncio
import datetime
import iterm2
@letam
letam / rm-docker-files.sh
Created July 6, 2023 16:54
Remove docker installation-related files on macOS
sudo rm /usr/local/bin/docker*
sudo rm /usr/local/bin/hub-tool
sudo rm /usr/local/bin/kubectl*
sudo rm /usr/local/bin/vpnkit
sudo rm /usr/local/bin/com.docker.cli
@letam
letam / venv-path-replace.sh
Created May 9, 2023 01:25
Replace venv path in files
#!/usr/bin/env bash
new_venv_path=/Users/tams/code/django-app-starter/.venv
old_venv_path=`tail -1 ./.venv/pyvenv.cfg | cut -d' ' -f6`
echo Old venv path is at: $old_venv_path
echo Files containing path:
for x in `grep -rnw . -e "$old_venv_path" --binary-files=without-match | cut -d: -f1`;
do echo $x
sed -i "s|$old_venv_path|$new_venv_path|g" $x
@letam
letam / chatgpt-modify-page.js
Created April 13, 2023 04:58
Script to modify/cleanup ChatGPT UI for screencasts
// Declare reusable variable
let x;
// Hide Sidebar
document.querySelector('.dark.bg-gray-900').classList.toggle('md:hidden');
// Fix app alignment
document.querySelector('.flex.h-full.flex-1').classList.toggle('md:pl-[260px]')
@letam
letam / install-git.plugin.zsh
Created December 14, 2021 17:46
Install Git Plugin for Zsh
#!/usr/bin/env bash
# Install git.plugin.zsh from Oh My Zsh framework (https://github.com/ohmyzsh/ohmyzsh)
mkdir -p ~/.config/zsh
cd ~/.config/zsh
curl -O https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/git/git.plugin.zsh
if ! grep -q 'source ~/.config/zsh/git.plugin.zsh' ~/.zshrc; then
echo -e '\n# Load git plugin from Oh My Zsh framework (https://github.com/ohmyzsh/ohmyzsh)' >> ~/.zshrc
@letam
letam / print-twin-filenames.py
Last active May 12, 2021 18:23
Print out cases of matching filenames but with different extension
#!/usr/bin/env python
# Get all js and jsx files in project and print out the situations
# in which there is a file named *.js beside an identically-named *.jsx file
import subprocess
# Get sorted list of paths of all {js,jsx} files in project, excluding node_modules dir
command = "find -L . \
@letam
letam / nginx.conf
Created May 2, 2021 23:49
nginx.conf for node/vite dev server with hot module replacement HMR
location / {
index index.html index.htm;
#try_files $uri $uri/ =404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://localhost:3000;
@letam
letam / nginx.conf
Created May 2, 2021 22:39 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@letam
letam / escape-regex-replacement-string.sh
Last active June 12, 2020 13:55
escape regex replacement string
#!/usr/bin/env bash
# Return a string that's escaped and ready to be used as
# the replacement string in a basic regular expression.
# Reference: https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script/33005#33005
escape_regex_replacement_string() {
# Reference: https://github.com/koalaman/shellcheck/wiki/SC2001
string=$1
if [[ $string =~ \\ ]]; then