Skip to content

Instantly share code, notes, and snippets.

View hamidzr's full-sized avatar
🎯
[~/] # ...

Hamid Zare hamidzr

🎯
[~/] # ...
View GitHub Profile
@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.
#!/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)
#!/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
#!/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 November 22, 2018 22:40
Raspbian stretch headless ssh and wifi setup

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 November 17, 2018 02:37
simple sendmail alternative to catch cron logs
#!/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
@hamidzr
hamidzr / ionic-clean-permissions.js
Created June 25, 2018 16:30
This is an Ionic development hook to dynamically remove unnecessary permissions requested by plugins.
#!/usr/bin/env node
'use strict';
//
// This hook removes specific permissions from the AndroidManifest.xml
// The AndroidManifest is re-generated during the prepare stage,
// so this must be run on the "after_prepare" hook.
//
// Configure the permissions to be forcefully removed.
@hamidzr
hamidzr / setupFeatures.sh
Last active January 30, 2018 22:22
integrating feature branches for testing.
#!/bin/bash
# 1. update nb/netsblox/b:master
# branch out to master-beta (delete if existing)
# pull in list of feature branches (merge conflict?)
# 2. update nb/browser/b:nb
# branch out to netsblox-beta (delete if existing)
# pull in list of feature branches (merge conflict?)
# commit and push
# 3. move to nb/netsblox
@hamidzr
hamidzr / pre-commit-eslint
Last active October 27, 2017 20:27 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
# def colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
@hamidzr
hamidzr / pacaur_install.sh
Created October 25, 2017 18:00 — forked from tadly/pacaur_install.sh
A simple shell script to quickly / easily install "pacaur" on archlinux
#!/bin/sh
# If you are new to arch, I encourage you to at least read and understand what
# this script does befor blindley running it.
# That's why I didn't make a one-liner out of it so you have an easier time
# reading and understanding it :)
#
# This scripts purpose is purly to save you a few seconds on your new installation.
#
# Enjoy your time on an awesome system. Arch FTW!
/**
* @author Hamid Zare
* @email hamid.zare@vanderbilt.edu
*/
// the program would have been much faster and easier to write if the
// pagination was predictabe, meaning that I could grab the nth page directly
// in that case it would have been possible to fire all the request concurrently
// (after gettig the first response)