Skip to content

Instantly share code, notes, and snippets.

View vbresan's full-sized avatar

Viktor Brešan vbresan

View GitHub Profile
@vbresan
vbresan / list-archived.py
Created September 28, 2025 09:07
Prints which reddit threads, listed in an OPML file, are archived.
"""
Usage: python list-archived.py [filename]
Prints which reddit threads, listed in an OPML file, are archived.
"""
import requests
import sys
import xml.etree.ElementTree as ET
def get_request_url(url: str) -> str:
@vbresan
vbresan / maya-calendar-converter.py
Created June 21, 2025 05:16
Python function that converts a haab date to a tzolkin date (Mayan calendars).
def solve(haab_date: str) -> str:
"""
Converts a haab date to a tzolkin date. See:
https://en.wikipedia.org/wiki/History_of_calendars#Mesoamerica
https://en.wikipedia.org/wiki/Maya_calendar
"""
months = ["pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"]
parts = haab_date.split()
@vbresan
vbresan / prime-factorization.py
Created June 21, 2025 05:14
Python function that returns a list of prime factors. Works for negative numbers.
from typing import List
def solve(incoming: int) -> List[int]:
"""
Returns a list of prime factors. Works for negative numbers.
"""
if incoming >= -1 and incoming <= 1:
return [incoming]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 16sp base size, Major Second scale -->
<dimen name="textSize">16sp</dimen>
<dimen name="textSizeSmallest">12.64sp</dimen>
<dimen name="textSizeSmall">14.22sp</dimen>
<dimen name="textSizeH6">18sp</dimen>
<dimen name="textSizeH5">20.25sp</dimen>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 18sp base size, Major Second scale -->
<dimen name="textSize">18sp</dimen>
<dimen name="textSizeSmallest">14.22sp</dimen>
<dimen name="textSizeSmall">16sp</dimen>
<dimen name="textSizeH6">20.25sp</dimen>
<dimen name="textSizeH5">22.78sp</dimen>
@vbresan
vbresan / Code.gs
Created March 23, 2024 06:12 — forked from nizioleque/Code.gs
Google Calendar events bulk edit (with Google Apps Script)
function start() { main(); }
// CONFIGURE BELOW ------------------------------------------------
const Test = true;
const TestFn = events => {
const testEvent = events[0];
console.log(testEvent);
const response = updateEvent(testEvent);
@vbresan
vbresan / parseInputNumber.js
Created October 26, 2021 14:55
Simplifies string in currency format. Removes all thousands separators, keeps only decimal separator. Separators can be "," or ".".
function parseInputNumber(value) {
let last = Math.max(value.lastIndexOf(","), value.lastIndexOf("."));
if (last == -1) {
return value;
}
let parts = value.split(/[.,]/);
let parsed = parts.slice(0, -1).join("");
@vbresan
vbresan / countries.js
Created October 26, 2021 14:51 — forked from tmrk/countries.js
An array of all countries with ISO 3166-1 alpha-2, alpha-3 and numeric country codes, as well the numeric codes for sub-regions, regions and continents as specified by the United Nations Statistics Division at http://unstats.un.org/unsd/methods/m49/m49.htm (August 2016).
var countries = [
{ 'name' : 'Afghanistan', 'alpha2' : 'AF', 'alpha3' : 'AFG', 'num3' : '004', 'subregion' : '034', 'region' : '', 'continent' : '142' },
{ 'name' : 'Åland Islands', 'alpha2' : 'AX', 'alpha3' : 'ALA', 'num3' : '248', 'subregion' : '154', 'region' : '', 'continent' : '150' },
{ 'name' : 'Albania', 'alpha2' : 'AL', 'alpha3' : 'ALB', 'num3' : '008', 'subregion' : '039', 'region' : '', 'continent' : '150' },
{ 'name' : 'Algeria', 'alpha2' : 'DZ', 'alpha3' : 'DZA', 'num3' : '012', 'subregion' : '015', 'region' : '', 'continent' : '002' },
{ 'name' : 'American Samoa', 'alpha2' : 'AS', 'alpha3' : 'ASM', 'num3' : '016', 'subregion' : '061', 'region' : '', 'continent' : '009' },
{ 'name' : 'Andorra', 'alpha2' : 'AD', 'alpha3' : 'AND', 'num3' : '020', 'subregion' : '039', 'region' : '', 'continent' : '150' },
{ 'name' : 'Angola', 'alpha2' : 'AO', 'alpha3' : 'AGO', 'num3' : '024', 'subregion' : '017', 'region' : '', 'continent' : '002' },
{ 'name' : 'Anguilla', 'alpha2' : 'AI', 'alpha3' : 'AIA', 'num3' :
@vbresan
vbresan / gglCalEventsOnSpreadSheet.gs
Created October 4, 2021 18:52 — forked from paucoma/gglCalEventsOnSpreadSheet.gs
Script to read Google Calendar Events and Count total Hours
const gblFrom = {
year : 2020 ,
month : 3,
day : 29,
hour : 0
};
const gblTo = {
year : 2020 ,
month : 8,
day : 1,