Skip to content

Instantly share code, notes, and snippets.

View AlextheYounga's full-sized avatar

Alex Younger AlextheYounga

View GitHub Profile
@AlextheYounga
AlextheYounga / phps.sh
Created December 6, 2024 17:07
Switch PHP versions using Homebrew
#!/bin/bash
# Switch PHP versions using Homebrew
# Example usage: `phps 8.1`
# Add to profile with `source phps.sh`
function phps() {
local new_version=$1
local php_output=$(php -v)
local current_version=$(echo "$php_output" | awk '/^PHP/ {print $2}' | cut -d. -f1,2)
echo "Switching PHP version from $current_version to $new_version"
@AlextheYounga
AlextheYounga / derivative.ipynb
Last active October 1, 2024 23:04
Derivatives in Plain English (It's just a tiny slope)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlextheYounga
AlextheYounga / parse_tqdm.py
Created April 12, 2024 22:38
Regex Parse tqdm Output
import re
def parse_tqdm(tqdm_output):
# Regex pattern to match different components of the tqdm output, with an optional message
pattern = r"""
(.*?:)?\s* # Optionally match any leading message ending with a colon (non-capturing)
(\d+)%\| # Match the progress percentage
[\s\S]*\| # Match the bar separator
\s*(\d+)/(\d+) # Match the current and total iterations
@AlextheYounga
AlextheYounga / attempt_repair_yaml_content.py
Last active January 17, 2024 05:42
Corrects misplaced colons from ChatGPT Yaml responses
import yaml
import re
"""
ChatGPT has a tendency to return Yaml content with misplaced colons.
Example:
```yaml
- title: The Great Poopening: Poop Harder
```
@AlextheYounga
AlextheYounga / tax_burden_by_country.ipynb
Created January 2, 2023 06:48
Tax Burden Per Capita By Country (US, Denmark, France, Australia)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlextheYounga
AlextheYounga / post-checkout.sh
Created November 23, 2022 19:08
Husky Git Hook Force Delete Branches Created From Staging
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
getBranchName()
{
echo $(git rev-parse --abbrev-ref HEAD)
}
getMergedBranches()
{
# Linked list Concepts
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
# Function to initialize head
def __init__(self):
@AlextheYounga
AlextheYounga / create_github_languages.rb
Last active April 24, 2021 20:57
Rails Github Language Statistics Chart
# db/migrate/create_github_languages.rb
# migrations file for github languages table
class CreateGithubLanguages < ActiveRecord::Migration[5.2]
def change
create_table :github_languages do |t|
t.string :language
t.float :value
t.timestamps
end
end
@AlextheYounga
AlextheYounga / news_stock_scraper.py
Created January 15, 2021 22:32
news_stock_scraper
import requests
from bs4 import BeautifulSoup
import sys
import json
import os
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'}
try:
@AlextheYounga
AlextheYounga / MEDIUM-API
Last active March 6, 2018 08:37
Simple Medium.com Ruby API for grabbing blog posts and displaying them on your website.
##NOTHING HERE, JUST FOR GIST TITLE PURPOSES