Skip to content

Instantly share code, notes, and snippets.

@pca2
pca2 / Mana.svg
Created February 19, 2024 20:50
mtg mana symbols as svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pca2
pca2 / moxfield_to_csv.py
Created February 2, 2024 03:43
Export Moxfield Deck to CSV
import requests
import csv
import sys
def download_mtg_deck(url):
# Headers to mimic a Linux Firefox browser
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0'
}
@pca2
pca2 / hash_diff.rb
Created January 23, 2024 20:30
Compare two Ruby hashes and return that doesn't match
def hash_diff(hash1, hash2)
diff = {}
# Check for keys and values present in hash1 but not in hash2
hash1.each do |key, value|
diff[key] = [value, hash2[key]] unless hash2[key] == value
end
# Check for keys and values present in hash2 but not in hash1
hash2.each do |key, value|
@pca2
pca2 / xbar_monitor.sh
Last active January 4, 2024 15:43
XBar/BitBar Monitor
#!/bin/bash
# xbar seems to freeze when computer goes to sleep. this monitors that and restarts it if detected
# Parameters
log_file="/tmp/xbar.log"
command_to_run="/Applications/xbar.app/Contents/MacOS/xbar"
# Check if log file exists
if [ ! -f "$log_file" ]; then
touch "$log_file"
fi
@pca2
pca2 / datetime_to_cron.py
Last active March 23, 2022 15:07 — forked from kathawala/datetime_to_cron.py
Converts a python datetime to a crontab expression which fires once (at the date+time specified in the python datetime object)
from datetime import datetime
def datetime_to_cron(dt):
return f"{dt.minute} {dt.hour} {dt.day} {dt.month} *"
@pca2
pca2 / time.sh
Created January 9, 2022 21:08
Generic Monitor datetime display for xfce
#! /bin/bash
# if it's before 7 only display the minute
# full time always available in tooltip
hour=$(date +%H)
day=$(date "+%a %m/%d |" )
shorttime=$(date +%M)
fulltime=$(date +%I:%M)
if [ $hour -le 6 ]; then
txt="$day $shorttime"
else
@pca2
pca2 / ymltocsv.rb
Created September 2, 2020 21:23
Convert YML file to CSV
require 'yaml'
require 'csv'
yaml_file_path = ARGV[0] || nil
csv_file_path = ARGV[1] || nil
if yaml_file_path.nil? or csv_file_path.nil?
puts "USAGE: ruby ymltocsv.rb <input_path> <output_path>"
exit 1
end
{
"PresetList" : [
{
"AlignAVStart" : true,
"AudioCopyMask" : [
"copy:aac",
"copy:ac3"
],
"AudioEncoderFallback" : "ca_aac",
"AudioLanguageList" : [
@pca2
pca2 / 2020_538.1h.py
Created August 14, 2020 00:42
538 2020 Presidential election model BitBar plugin
#!/usr/local/bin/python3
#Your shebang may need to be updated
'''
Todo:
1. check previous result and add up or down arrow result based on delta
2. include popular vote, other interesting fields
3. Senate(when it's available)
'''
import pandas as pd
@pca2
pca2 / Animal.py
Last active July 3, 2019 18:04
Basic Animal class example
class Animal:
class_var = 'foo'
def __init__(self, name, age=11):
self.name = name
self.age = age
def greet(self):
print(f"Hello, I'm {self.name}")