Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
[~/] # ...

Hamid Zare hamidzr

🎯
[~/] # ...
View GitHub Profile
@hamidzr
hamidzr / personal-capital.js
Created Sep 2, 2021
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 Sep 2, 2021
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
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 Sep 16, 2022
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 Aug 14, 2019
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 Mar 11, 2019
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 Jan 8, 2019
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 Jan 8, 2019
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
@hamidzr
hamidzr / raspianSetup.md
Last active Nov 22, 2018
Raspbian stretch headless ssh and wifi setup
View raspianSetup.md

Raspbian Strech headless setup

  1. mount the boot partition and not the /boot directory.
  2. cd and create the following two files in the root of that boot partition.
  3. touch ssh creates an empty file to enable ssh
  4. vim wpa_supplicant.conf to configure wifi and put following in it
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
@hamidzr
hamidzr / sendmail
Last active Nov 17, 2018
simple sendmail alternative to catch cron logs
View sendmail
#!/bin/bash
# simple sendmail
date_str=`date +%y-%m-%d--%H-%M-%S`
rand=$((RANDOM % 1000))
hostname=$(hostname | tr '/:' '\057\072')
fname=$date_str.$rand.$hostname
target_dir=SET_DESIRED_DIR