Skip to content

Instantly share code, notes, and snippets.

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

Hamid Zare hamidzr

🎯
[~/] # ...
View GitHub Profile
@hamidzr
hamidzr / weatherStations.py
Last active August 8, 2017 16:05
helper script to normalize and upload sensor readings from an arduino to thingspeak's MQTT broker
#!/usr/bin/python2.7
# normalize and publish weather sensor readings to thingspeak
from time import sleep
import datetime
import serial # install pySerial
import paho.mqtt.client as mqtt
import sys
SERIAL_PORT = sys.argv[2] if len(sys.argv) > 2 else '/dev/ttyUSB1'
/**
* @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)
@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!
@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 / 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()