Skip to content

Instantly share code, notes, and snippets.

View TommyPKeane's full-sized avatar
👻
"I'm cuckoo bananas [...], obvi."

Tommy P. Keane TommyPKeane

👻
"I'm cuckoo bananas [...], obvi."
View GitHub Profile
@TommyPKeane
TommyPKeane / latex-example-chapter.tex
Created March 9, 2023 16:49
Example of a standalone .tex file for a chapter in a LaTeX document, showing some various mathematical and typesetting features of the language.
% -*- coding: utf-8 -*-
%!TEX root = ../latex/Dissertation.tex
%% ! CHAPTER ! INTRODUCTION
% --------------------------------------------------------------------------------------------------
\chapter{Introduction}
\label{chap:Introduction}
Chapter text goes here. Indentation will be ignored, but it can be useful for you when you're
writing. The indentation helps to visually separate chapters and sections.
@TommyPKeane
TommyPKeane / bash-basics.sh
Created March 9, 2023 16:47
Introduction to some various functionality of bash Scripting and terminal commands (with a focus on macOS)
# NOTE:
# -------------------------------------------------------------------------------------------------
# The bash (Bourne Again SHell) language commands use whitespace instead of commas and parentheses.
#
# All arguments are separated by whitespace, flags are preceeded by dashes (-), and separate
# commands are delineated by semicolons (;).
#
# For flags, typically, single dashes refer to a single character flag (e.g., rm -r) which makes it
# easy to combine multiple single-character flags with only a single dash (e.g., rm -r), and thus
# two-dashes (--) tends to refer to multi-character (word-like) flags (e.g., pip --force-reinstall)
@TommyPKeane
TommyPKeane / create_macos_bundle.py
Created March 9, 2023 16:43
Python Example for creating an macOS (OS X) App Container for Binary Program (executable) without XCode
#!/usr/bin/env python
# --------------------------------------------------------------------------------------------------
# Tommy P. Keane
# https://www.tommypkeane.com
# --------------------------------------------------------------------------------------------------
'''
Use a function like this to easily create the Info.plist file necessary to create your own .app
container. You need an executable binary file to go along with this!
@TommyPKeane
TommyPKeane / bash-latex.sh
Created March 9, 2023 16:40
Useful Unix Terminal Commands for TeX, LaTeX, and XeLaTeX for document design and generation
## IF YOU ARE USING OS X, WE RECOMMEND USING MacTeX (BE AWARE: 2GB DOWNLOAD, REQUIRES SYSTEM RESTART AFTER INSTALLATION):
## https://tug.org/mactex/
##
## IF YOU ARE USING WINDOWS, WE RECOMMEND USING MikTeX (DOWNLOADED APP WILL CONNECT ONLINE TO DOWNLOAD PACKAGES):
## http://miktex.org/
##
## ON WINDOWS (WHILE NOT NECESSARY) YOU MAY ALSO WANT TO BE USING A TERMINAL/SHELL EMULATING SYSTEM LIKE mingw OR cygwin,
## NOT ONLY FOR LaTeX, BUT FOR GENERAL PROGRAMMING AND SCRIPTING PURPOSES AS WELL.
##
## THE FOLLOWING COMMANDS ARE ONLY TESTED AND CONFIRMED FOR UNIX (bash):
@TommyPKeane
TommyPKeane / bash-iptables.sh
Last active February 28, 2023 22:36
`iptables` Commands and Examples with `bash` for Local Configuration or Webserver Configuration
# Example Commands to Prevent DDoS Floods by Dropping TCP Packets/Requests
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags FIN,ACK FIN -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,URG URG -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags ACK,PSH PSH -j DROP
sudo -E iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
@TommyPKeane
TommyPKeane / nginx-snippets.nginx
Last active February 28, 2023 17:06
Examples of blocks of Nginx Configurations for a Site Config-File
# These examples are not complete and will use `[...]` to indicate missing
# text that may be necessary to build a full example.
#
# You would likely use/find code from these examples in your site config
# when using Nginx, which will usually be (in a Unix-like system) at the
# path:
# /etc/nginx/sites-available/{site-config-name}
# Custom HTTP Error Page for single HTTP Error
@TommyPKeane
TommyPKeane / bash-grep.sh
Created February 28, 2023 14:27
Examples and Syntax Explanations for using `grep` to parse Files or Output Streams from other commands/operations in `bash` Syntax
# `grep` vs. `ggrep`
#
# Note that in macOS as a Unix-like System (BSD-based), a majority
# of the Unix Commandline Tools are already pre-installed and used
# as part of the Operating System (OS). This, however, causes the
# problem that many of these tools are version-locked for the intent
# of retaining compatibility within the OS itself, meaning that they
# are often old/out-of-date. As such, we can use `brew` (Homebrew)
# in macOS to install the latest versions of these utilities. But,
# when using the latest GNU variant of a critical OS utility (like
@TommyPKeane
TommyPKeane / bash-macOS.sh
Last active March 9, 2023 16:40
macOS System Commands in bash Syntax for troubleshooting or configuring a macOS System.
# Stop (and Resart) the macOS User Interface Runtime (Menubar, Dock, etc.)
killall SystemUIServer
# Stop (and Resart) Finder (the macOS File Explorer)
killall Finder
# Set Screenshot/Screencapture Format
# Options: "png", "bmp", "gif", "jpg", "pdf", "tiff"
# Apply changes with: `killall SystemUIServer`
defaults write com.apple.screencapture type -string "png"
@TommyPKeane
TommyPKeane / bash-ffmpeg.sh
Last active September 12, 2023 00:50
ffmpeg Syntax and Examples in bash as a commandline utility for Video and Image Parsing, Conversion, Creation, and Editing (https://ffmpeg.org/ffmpeg.html)
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
ffmpeg -i filename.mp4 -loop 0 filename.gif
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
# that is resized to a fixed height of 240 [px] while preserving the original
# aspect-ratio of the input video
ffmpeg -i filename.mp4 -vf "scale=-1:240" -loop 0 filename.gif
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
# that is resized to a fixed width of 300 [px] while preserving the original
@TommyPKeane
TommyPKeane / bash-imagemagick.sh
Created February 22, 2023 20:23
imagemagick Utilities' Syntax and Examples in bash for commandline Image Conversion, Creation, and Parsing (https://imagemagick.org/Usage/)
# Create Multiscale ICO Image (filename.ico) from a given JPEG Image (filename.jpg)
convert -background transparent filename.jpg -define icon:auto-resize=16,24,32,48,64,72,96,128,256 filename.ico
# Convert MP4 Animated Video (animated.mp4) to Animated GIF (filename.gif)
convert filename.mp4 filename.gif
# Convert MP4 Animated Video (animated.mp4) to Animated GIF (filename.gif)
# with size restriction to width of 300 [px] while preserving aspect-ratio
# (Note that re-scaling may degrade quality)
convert -resize 300x filename.mp4 filename.gif