Skip to content

Instantly share code, notes, and snippets.

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

Hamid Zare hamidzr

🎯
[~/] # ...
View GitHub Profile
@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 / githubPlus.js
Last active November 14, 2017 17:42
github improvments. userscripts link: https://greasyfork.org/en/users/135513-hamidzr
// ==UserScript==
// @name GitHub PullRequests Plus
// @namespace http://tampermonkey.net/
// @version 0.3.0
// @updateURL https://gist.githubusercontent.com/hamidzr/3167e68addb1bf69eef425348ae35c90/raw
// @description Displays a bunch of usefull information next to the github pullrequests such as diff stats and latest comments
// @author Hamid Zare @hamidzr
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.2/axios.min.js
@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 / 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 / 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 / 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 / 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 / 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 / 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 / chefBobbyPrices.sh
Created August 14, 2019 22:55
fetch daily signature prices from https://mychefbobby.myshopify.com/ into csv
#!/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