This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# <bitbar.title>538 Midterm Tracker</bitbar.title> | |
# <bitbar.version>v1.0</bitbar.version> | |
# <bitbar.author>Carleton Atwater</bitbar.author> | |
# <bitbar.author.github>pca2</bitbar.author.github> | |
# <bitbar.desc>Scrapes election odds from FiveThirtyEight's election tracker</bitbar.desc> | |
# <bitbar.image>https://imgur.com/bCF8fyg.png</bitbar.image> | |
# <bitbar.dependencies>ruby</bitbar.dependencies> | |
# This code is pretty hacky, but it was a fun 1 hour project to track something 20ish days away. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def datetime_to_cron(dt): | |
return f"{dt.minute} {dt.hour} {dt.day} {dt.month} *" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"PresetList" : [ | |
{ | |
"AlignAVStart" : true, | |
"AudioCopyMask" : [ | |
"copy:aac", | |
"copy:ac3" | |
], | |
"AudioEncoderFallback" : "ca_aac", | |
"AudioLanguageList" : [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder