Skip to content

Instantly share code, notes, and snippets.

View brandonhimpfen's full-sized avatar
🎯
Focusing

Brandon Himpfen brandonhimpfen

🎯
Focusing
View GitHub Profile
@brandonhimpfen
brandonhimpfen / convert-dogs-age-human-years-ruby.rb
Created May 2, 2026 03:36
Ruby script to convert a dog's age to human years.
dog_age = 6 # replace with the actual age of your dog
human_age = 0
if dog_age == 1
human_age = 15
elsif dog_age == 2
human_age = 24
else
human_age = 24 + (dog_age - 2) * 4.5
end
@brandonhimpfen
brandonhimpfen / input.csv
Created April 24, 2026 03:45
Python script that will allow you to add multiple photography prints in a CSV file and will output another CSV file with the price of each photography print.
Size Edition Reputation Factor Production Cost Framing Cost Subject Value
16 50 1.5 200 200 0
20 100 1.2 300 250 1.5
24 25 1.8 350 300 -0.5
@brandonhimpfen
brandonhimpfen / notes.md
Created April 24, 2026 03:42
Python script that you may run at the command line to determine the selling price of a photography print.

You can run this script from the command line by entering the required input values as arguments. For example, to calculate the price of a 16x20 inch photographic print from a limited edition of 50, with a reputation factor of 1.5, production cost of $200, subject value of 0, and a framing cost of $200, you would run the script like this:

python print_price.py 16 50 1.5 200 200 0

The output should be $840.80

@brandonhimpfen
brandonhimpfen / minimize-css-python-cli.py
Created April 24, 2026 03:29
Minimize your CSS file with a command line interface (CLI) using Python.
import argparse
import csscompressor
parser = argparse.ArgumentParser(description='Minimize CSS code.')
parser.add_argument('input_file', help='the input CSS file')
parser.add_argument('output_file', help='the output file for the minimized CSS')
args = parser.parse_args()
# Load the CSS file
@brandonhimpfen
brandonhimpfen / minimize-html-python-cli.py
Created April 24, 2026 03:24
Minimize your HTML file with a command line interface (CLI) using Python.
import argparse
from bs4 import BeautifulSoup
# parse command line arguments
parser = argparse.ArgumentParser(description='Minimize HTML code')
parser.add_argument('input_file', type=str, help='path to the input HTML file')
parser.add_argument('output_file', type=str, help='path to the output HTML file')
args = parser.parse_args()
# read the HTML file
@brandonhimpfen
brandonhimpfen / calculate-flight-time-two-cities-python.py
Created April 24, 2026 03:21
Python script to calculate the flight time between two cities.
from geopy.geocoders import Nominatim
from geopy.distance import great_circle
import math
def flight_time(origin, destination, speed=885):
# Get the latitude and longitude of the origin and destination cities
geolocator = Nominatim(user_agent="flight-time-calculator")
origin_location = geolocator.geocode(origin)
dest_location = geolocator.geocode(destination)
if not origin_location or not dest_location:
@brandonhimpfen
brandonhimpfen / block-pinterest-pinning-images.html
Created April 24, 2026 03:20
The following code snippet includes a meta tag specifically designed for Pinterest, indicating that the content should not be pinnable. Add between the <head> </head> tags.
<meta name="pinterest" content="nopin" />
@brandonhimpfen
brandonhimpfen / calculate-final-amount-monthly-savings-plan-python.py
Created April 24, 2026 03:17
Python script to determine the final amount of a monthly savings plan. You are able to set the principle amount, the monthly payment, the interest rate and the term. The script also has the ability to compound the interest monthly, quarterly or annually.
def calculate_final_amount(principal, monthly_deposit, annual_interest_rate, num_of_years, compounding_period):
# Convert interest rate to monthly rate
monthly_interest_rate = (annual_interest_rate / 100) / 12
# Calculate the number of months
num_of_months = num_of_years * 12
# Calculate the number of compounding periods
if compounding_period == "monthly":
num_of_compounding_periods = num_of_months
@brandonhimpfen
brandonhimpfen / .htaccess
Created April 24, 2026 02:44
Use the following .htaccess snippet to block the Semalt.com crawler from crawling your site.
## BLOCK SEMALT ##
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteCond %{HTTP_REFERER} ^(.*)\.semalt\.com [NC]
RewriteRule .* - [F]
## END BLOCK SEMALT ##
@brandonhimpfen
brandonhimpfen / material-design-color-palette-variables.scss
Created April 22, 2026 17:53
This SCSS code defines a comprehensive color palette based on the Material Design guidelines. It includes a wide range of colors, from red to blue-grey, as well as generic black and white, making it easy to apply consistent and visually appealing color schemes to web projects.
// Material Design Color Palette
// by Brandon Himpfen https://www.brandonhimpfen.com/
// Red
$md-red-50: #ffebee;
$md-red-100: #ffcdd2;
$md-red-200: #ef9a9a;
$md-red-300: #e57373;
$md-red-400: #ef5350;
$md-red-500: #f44336;