Skip to content

Instantly share code, notes, and snippets.

@anuragpeshne
anuragpeshne / benchmark.sh
Created October 6, 2017 13:46
shell script to benchmark, can be generalized
#! /bin/bash
declare -a topologies=("full" "2D" "line" "imp2D")
for node_num in `seq 100 100 2000`; do
printf "$node_num, "
for topo in "${topologies[@]}"; do
result="$(./project2 $node_num $topo gossip)"
printf "$result, "
sleep 2
@anuragpeshne
anuragpeshne / chkJar.sh
Created April 21, 2017 14:55
COP5556sp17 jar checker
#!/bin/bash
expFiles="META-INF/\n\
META-INF/MANIFEST.MF\n\
cop5556sp17/AST/\n\
cop5556sp17/AST/AssignmentStatement.java\n\
cop5556sp17/AST/ASTNode.java\n\
cop5556sp17/AST/ASTVisitor.java\n\
cop5556sp17/AST/BinaryChain.java\n\
cop5556sp17/AST/BinaryExpression.java\n\
#!/usr/bin/env python
from RPLCD import CharLCD, cleared, cursor
import socket
import time, datetime
lcd = CharLCD()
# load IP address
import socket
@anuragpeshne
anuragpeshne / scrapydInstallation.sh
Last active March 15, 2016 14:27
script to install scrapyd (daemon) on ubuntu
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 627220E7
echo 'deb http://archive.scrapy.org/ubuntu scrapy main' | sudo tee /etc/apt/sources.list.d/scrapy.list
sudo apt-get update
sudo apt-get install scrapyd
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo apt-get install git
sudo pip install -e git+https://github.com/scrapy/scrapyd#egg=scrapyd
sudo pip install pyasn1 --upgrade
@anuragpeshne
anuragpeshne / wifiDance.sh
Last active December 14, 2015 10:17
bash script to
#!/bin/sh
let sleepTime="15*60";
while [ 1 ]
do
if [ $(( $RANDOM % 2)) == 0 ]
then
echo "switching to NTWRK1";
networksetup -setairportnetwork en1 {NTWRK_NAME} {NTWRK_PSWD}
else
@anuragpeshne
anuragpeshne / rmWhiteSpace.sh
Last active August 29, 2015 14:25
remove trailing whitespace,sed
#!/bin/bash
# inplace substitution which works on both OSX and Linux
if [ -z $1 ]
then
echo "Fatal: enter file name"
else
sed -E 's/[ \t]+$//g' "$1" > /tmp/t_rm_wp
cp /tmp/t_rm_wp "./$1"
fi
@anuragpeshne
anuragpeshne / shiro
Created April 9, 2015 06:24
bash to find up largest variable name in PHP and JavaScript
egrep -oshRI --include \*.php '(\$[a-zA-Z_0-9]+)' ./ | awk -F ':' '{ print length $1}' | sort -gr | head -n 1
#this will output largest PHP variable name
egrep -shIRo --include \*.js '(?:[\n\( ])([a-zA-Z_0-9]+) *=' ./ | awk '{ print length, $1}' | sort -gr | head -n 1
#this will output largest JavaScript variable name
@anuragpeshne
anuragpeshne / airLift.py
Last active August 29, 2015 14:17
download files based on a filter from any http server. Can be used to transfer files between computers and mobile.
import urllib
import urllib.request
import re
import os
from os import listdir
from os.path import expanduser
import sys
def lift(currentLocation):
req = urllib.request.Request(sourceLocation + currentLocation)