Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Wondering what you are supposed to put as your GitHub status

Jake Vossen jakevossen5

💭
Wondering what you are supposed to put as your GitHub status
View GitHub Profile
@jakevossen5
jakevossen5 / percent-done.py
Created Oct 31, 2018
Percent done with hour/day/month
View percent-done.py
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3
# To be used with bit-bar, which shows the % you are done with the current hour, day, week, and year
from datetime import datetime
now = datetime.now()
digits = 3
seconds_since_hour = (now - now.replace(minute=0, second=0, microsecond=0)).total_seconds()
print(("h" + ('{0:.2f}'.format(round((seconds_since_hour / 3600), digits)))[1:]), end= ' ')
seconds_since_midnight = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds()
print("d" +('{0:.2f}'.format(round((seconds_since_midnight / 86400), digits)))[1:],end = ' ')
@jakevossen5
jakevossen5 / second-countdown.sh
Created Oct 31, 2018
Seconds left bash script
View second-countdown.sh
#!/bin/bash
# This is a simple bash script displays a countdown to a specific time in the menu bar (combined with an app like bit bar)
END=1683612000
CUR=$(date +%s)
num=$(echo $END - $CUR | bc)
echo $num
View instapaper-archive.py
import urllib.request
import csv
def create_articles(path):
temp = []
file = open(path, 'r')
for line in file:
arr = line.split(',')
#print(arr[0][-4:].lower())
if arr[0][-4:].lower() == '.pdf':
@jakevossen5
jakevossen5 / remann.hs
Created Feb 2, 2020
Haskell Riemann Sum implementation
View remann.hs
do_integral :: (Ord p, Num p, Fractional p) => (p -> p) -> p -> p -> p -> p
do_integral f start end dx
| end <= start = 0
| otherwise = (height * dx) + do_integral f (start + dx) end dx
where
height = f (start + (dx / 2))
@jakevossen5
jakevossen5 / bin-to-dec-1-liner.py
Created Feb 6, 2020
A one liner for a binary to decimal created to demonstrate bad code
View bin-to-dec-1-liner.py
while (n := ((print(c[1])) if not (c := ((True, "OUTPUT error ") if -1 in (n := [(lambda t: 2**int(t[0]) if t[1] == '1' else (-1 if t[1] not in ['0', '1'] else 0))(t) for t in enumerate(input('BINARY-STR> ')[::-1])]) else (True, "OUTPUT " + str(sum(n)))) if (input('OPTION> ') == '1') else (False, "OUTPUT goodbye!"))[0] else print(c[1]) or (True if 'y' in (lower_in := input('CONTINUE> ').lower()) else print('OUTPUT goodbye!')))): continue