Skip to content

Instantly share code, notes, and snippets.

View Ausjorg's full-sized avatar

Austin Jorgensen Ausjorg

  • USA
View GitHub Profile
@Ausjorg
Ausjorg / time_total.py
Created January 24, 2024 23:07
This Python code defines a function add_times that takes a list of time strings in "hours:minutes:seconds" format, calculates the total time by converting each time string to seconds and summing them up, and then converts the total time back into the same "hours:minutes:seconds" format.
def add_times(time_array):
total_seconds = sum(
sum(map(lambda x, y: int(x) * y, time_str.split(':'), [3600, 60, 1]))
for time_str in time_array
)
hours, remainder = divmod(total_seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return f"{hours}:{minutes:02d}:{seconds:02d}"
@Ausjorg
Ausjorg / commentsParseURL.js
Created November 25, 2019 19:47
Same as parseURL.js but with comments
function parsePort(url) {
// if able to grab item in port array position return it
try { return parseInt(url.split(':')[2].split('/')[0]) }
// else when fails return null
catch { return null }
}
function parsePath(url) {
let tmp = null;
// checks to see if on base path. if not returns home (base) path
@Ausjorg
Ausjorg / parseURL.js
Created November 25, 2019 19:34
returns obj with URL information
function parsePort(url) {
try { return parseInt(url.split(':')[2].split('/')[0]) }
catch { return null }
}
function parsePath(url) {
let tmp = null;
if (url.split('/')[3] == undefined) return '/';
(url.includes('?')) ? tmp = `/${url.split('/')[3].split('?')[0]}` : tmp = `/${url.split('/')[3]}`;
return tmp
@Ausjorg
Ausjorg / code.js
Last active September 10, 2019 19:52
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A) {
A = new Set(A)
A = [...A]
A = A.sort(function(a,b){return a-b})
var check = true
if (A.length == 1 && A[0] != 1) return 1
@Ausjorg
Ausjorg / helpers.js
Last active September 27, 2019 16:00
How to sort and Array of Integers with JavaScript.
A = [5,6,3,3,1,2,4]
// Remove Duplicates
A = new Set(A)
A = [...A]
// Ascending Order 1 first
A = A.sort(function(a, b){return a-b});
// Descending Order 1 last
@Ausjorg
Ausjorg / resize_image.py
Created December 14, 2018 22:28
Batch resize images to a smaller size by the width you set. Keeps aspect ratio. Python.
# Python 3.6.7
# OS: Ubuntu 18.04
# Date: 12-14-2018
# Author: Austin Jorgensen
# This batch resizes images to the width you set and keeps aspect ratio.
import os
import PIL # pip install Pillow
from PIL import Image