Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
[~/] # ...

Hamid Zare hamidzr

🎯
[~/] # ...
View GitHub Profile
@hamidzr
hamidzr / car-cost.py
Created October 11, 2022 04:26
car cost calculator. Why you neeeed that sweet new ride, numbers edition.
View car-cost.py
#!/usr/bin/env python3
import numpy_financial as npf
import numpy as np
import typing as t
import json
"""
TODO:
- opportunity cost calc
"""
@hamidzr
hamidzr / wacom.py
Last active October 3, 2022 16:59
Python APIs to configure Wacom tablets, stylus, and pen on Linux. Set ratios and rotations based on a selected area of screen and more.
View wacom.py
#!/usr/bin/env python3
from typing import Literal, Union
from py_utils.v1.bash import get_output, run
import dataclasses
import functools
"""
from Arch Linux wiki:
@hamidzr
hamidzr / personal-capital.js
Created September 2, 2021 04:46
export Personal Capital portfolio holdings to CSV
View personal-capital.js
hmd = hmd || {};
if (hmd.download === undefined) {
hmd.download = (filename, text) => {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
@hamidzr
hamidzr / chromecast-volume.py
Created September 2, 2021 04:44
set volume on all chromecast devices in your network
View chromecast-volume.py
#!/usr/bin/env prun
import pychromecast
import sys
import itertools
from typing import List, Dict
services, browser = pychromecast.discovery.discover_chromecasts()
@hamidzr
hamidzr / workrave-parser.py
Last active May 7, 2021 04:21
Parse, merge, and output multiple workrave history usages. https://workrave.org/
View workrave-parser.py
#!/usr/bin/env python3
from typing import Any, Dict, List, Union, Optional, cast
import datetime
import os.path
"""
Parse, merge, and output multiple workrave history usages. https://workrave.org/
history file format:
@hamidzr
hamidzr / sof-audio-setup-carbonx1.sh
Last active March 17, 2023 09:51
Lenovo Carbon X1 Gen 7 - Audio and microphone fix - https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_7) might be all you need.
View sof-audio-setup-carbonx1.sh
#!/bin/bash
# README You probablyl don't need this script anymore. Please read the comments below to catch up.
## Description
# Lenovo Carbon X1 Gen 7 - Audio and microphone fix - kernel 5.3+ required.
# The script has only been tested for Arch and OpenSuse,
# Original thread: https://forums.lenovo.com/t5/Ubuntu/Guide-X1-Carbon-7th-Generation-Ubuntu-compatability/td-p/4489823
# Prereq: Install Linux 5.3 or newer
@hamidzr
hamidzr / chefBobbyPrices.sh
Created August 14, 2019 22:55
fetch daily signature prices from https://mychefbobby.myshopify.com/ into csv
View chefBobbyPrices.sh
#!/bin/bash
# fetch daily signature prices from https://mychefbobby.myshopify.com/ into csv
type pup > /dev/null
if [ $? != 0 ]; then
echo "pup" is required for this script to work
exit 1
fi
@hamidzr
hamidzr / publishAndroid.sh
Last active March 11, 2019 20:27
a utility script to help create signed and aligned APKs ready for publishing on app stores.
View publishAndroid.sh
#!/bin/bash
# usage: scriptname keystore_path key_alias
keystore=$1
alias=$2
version=$(cat config.xml| grep widget | grep -Eo 'version="(.{2,6})"' | grep -Eo '".*"' | sed 's/"//g')
app_name=roboscape
apk_dir=platforms/android/app/build/outputs/apk/release
final_name="$app_name-release-$version.apk"
@hamidzr
hamidzr / distribute.sh
Last active January 8, 2019 19:14
distribute files in a directory to multiple subdirectories (sortof a simple dht)
View distribute.sh
#!/bin/bash
# migrates a single file to a proper sub directory. "parallel" safe.
# run it in the target directory using parallel: `ls . | parallel PATH_TO_THIS_SCRIPT`
fname=$1
# hashes the project name and retuns the first n chars
# each char 36 diff values => divides to 16^n sub directories
function dirName()
@hamidzr
hamidzr / wgetVCurl.sh
Created January 8, 2019 17:14
wget vs curl for simple get operations
View wgetVCurl.sh
#!/bin/bash
filename=abc.tmp
url=https://projects.scratch.mit.edu/internalapi/project/99999926/get
iters=30
rm $filename > /dev/null 2>&1
echo timing curl for $iters iterations
time for iter in `seq 1 $iters`; do