This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
API= | |
# Set URL for fetching weather information and an Error Msg for invalid input | |
URL=http://api.wunderground.com/api/$API/geolookup/conditions/q/CA/Stanford.xml | |
ERR="Error: Arguments expected in form [City] [State]. Ex: weather Palo_Alto CA" | |
# handles arguments for location / default is Stanford CA | |
# well-formed argument example: "weather Memphis TN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# free is a utility which provides statistics about memory in use | |
# -m flag provides memory in Mb | |
# awk takes all the arguments from grep and can print them | |
USED=`free -m | grep cache: | awk '{print $3}'` | |
TOTAL=`free -m | grep Mem: | awk '{print $2}'` | |
# bc is a linux calculator which can print floating point | |
# scale determines number of decimals (ex: 0.00) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(undecorate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#utility to play a youtube video after the url has been cut using ctrl-x | |
youtube-dl -o "/home/farhan/Downloads/frmyoutube.%(ext)s" "$(xclip -o)" | tee /home/farhan/bin/play.log | |
#make sure we don't have any errors | |
if [ $(grep -i "error" ~/bin/play.log) ]; then | |
echo "Error downloading video. Try again :(" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as etree | |
tree = etree.parse('/home/farhan/bin/email.xml') | |
root = tree.getroot() | |
for entry in root.iter('{http://purl.org/atom/ns#}entry'): | |
for title in entry.findall('{http://purl.org/atom/ns#}title'): | |
print ('TITLE: ', title.text) | |
for author in entry.findall('{http://purl.org/atom/ns#}author'): | |
for email in author.findall('{http://purl.org/atom/ns#}email'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reads out 5 random lines from a file and erases them | |
import os.path | |
import random | |
dictionary = open("/home/farhan/bin/words", "r") | |
words = set() | |
last_pos = dictionary.tell() | |
rand_words = list(dictionary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import inspect | |
import os | |
import sys | |
def get_script_dir(follow_symlinks=True): | |
if getattr(sys, 'frozen', False): # py2exe, PyInstaller, cx_Freeze | |
path = os.path.abspath(sys.executable) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
( echo "PACKAGE SIZE(K)"; | |
for A in /var/lib/pacman/local/*/desc; do | |
egrep -A1 '%(NAME|SIZE)' $A \ | |
| gawk '/^[a-z]/ { printf "%s ", $1 }; /^[0-9]/ { printf "%.0f\n", $1/1024 }' | |
done | sort -nrk2 ) | column -t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
x="zzzzz" | |
copies=() | |
CLEAN_DIR="/var/cache/pacman/pkg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . | grep -E '\.(c|h)$' | zip six.zip -@ |
OlderNewer