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 python3.12 | |
import random | |
from dataclasses import dataclass | |
from subprocess import PIPE, Popen | |
WALLPAPERS_PATH = "~/nas/Wallpapers" | |
@dataclass | |
class Response: |
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 python3.12 | |
import json | |
from dataclasses import dataclass | |
from subprocess import PIPE, Popen | |
SUPER = 64 | |
ALT = 8 | |
CTRL = 4 | |
SHIFT = 1 |
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 itertools | |
def crosstab(rows, columns, col_idx_for_columns, lst_col_idx_for_rows, value_col_idx, fill_val, format_func=None): | |
"""Take col_idx_to_cross_tab and make its unique values be new columns at the end filled with | |
value_col_idx values. col idx arguments are 0 based. | |
This is basically a simplified pivot table creator with the limitations that you can only have one field in the columns | |
and there is no aggregation. | |
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
//with JQuery | |
function clickOutsideClose(element, callback) { | |
$(document).mouseup(function(e) { | |
let container = $(element) | |
if (!container.is(e.target) && container.has(e.target).length === 0) { | |
container.hide() | |
if (typeof callback === 'function') { | |
callback() | |
} | |
} |
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
function _create_html(inner_html, attributes = {}, data_attr = {}, self_closing = false, tag = null) { | |
let html = '<' + tag | |
if (!is_array(inner_html) && is_object(inner_html)) { | |
attributes = inner_html | |
inner_html = null | |
} | |
for (let key in attributes) { | |
html = html + ' ' + key + '="' + attributes[key] + '"' | |
} | |
for (let key in data_attr) { |
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 decimal import Decimal | |
from datetime import timedelta | |
def duration(duration_string): #example: '5d3h2m1s' | |
duration_string = duration_string.lower() | |
total_seconds = Decimal('0') | |
prev_num = [] | |
for character in duration_string: | |
if character.isalpha(): |