Skip to content

Instantly share code, notes, and snippets.

View alghanmi's full-sized avatar

Rami AlGhanmi alghanmi

  • University of Southern California
  • Los Angeles, CA
View GitHub Profile
@alghanmi
alghanmi / find_permissions.sh
Created July 9, 2012 21:30
Recursively find file/directory permissions
ls -lR | awk '{ print $1 }' | grep -v ^\./.* | grep -v ^$ | grep -v ^\.:$ | grep -v total | sort | uniq
@alghanmi
alghanmi / check_repos.sh
Created July 25, 2012 07:03
Recursively check status/pull/push Git Repositories
#!/bin/bash
REPO_LIST=$(find . -maxdepth 1 -type d | grep -v ^\.$ | cut -d/ -f2)
function action_prompt() {
is_done=0
while [ $is_done == 0 ]; do
read -p "Would you like to: (s)tatus, (p)ull, p(u)sh, (n)ext? (s/p/u/n)?" answer
case $answer in
"S" | "s" )
@alghanmi
alghanmi / mount_bind_example.sh
Created July 26, 2012 09:01
Move /var/log from the / partition to the /home partition
##
## Moving /var/log from SSD on / to regular HDD on /home/var_log
## http://backdrift.org/how-to-use-bind-mounts-in-linux
##
sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
sudo mkdir /home/var_log
sudo chown root:root /home/var_log/
sudo chmod 755 /home/var_log/
@alghanmi
alghanmi / app2unitypanel.sh
Created July 28, 2012 08:15
Add application to system tray white list a.k.a unity panel
#!/bin/bash
#Get list of already white listed applications (separated by space)
SYSTRAY_WHITELIST=$(gsettings get com.canonical.Unity.Panel systray-whitelist | tr -d \',[])
#Applications you wish to add (separated by space)
EXTRA_APPLICATIONS="Skype Shutter"
#Generate new white list
SYSTRAY_WHITELIST_NEW=$(echo "['$SYSTRAY_WHITELIST $EXTRA_APPLICATIONS']" | sed -e "s/\s/', '/g")
@alghanmi
alghanmi / HelloWorld.cpp
Created July 30, 2012 06:02
HelloWorld in C++
#include <iostream>
using namespace std;
int main () {
cout << "Hello World!" << endl;
return 0;
}
@alghanmi
alghanmi / canon-mx860_setup.sh
Created July 31, 2012 10:56
Canon PIXMA MX860 Setup on Ubuntu 12.04 Precise Pangolin
#Add Michael Gruz's Canon Driver Repository
echo "#Michael Gruz - Canon" | sudo tee /etc/apt/sources.list.d/cnijfilter.list
echo "deb http://ppa.launchpad.net/michael-gruz/canon/ubuntu quantal main" | sudo tee -a /etc/apt/sources.list.d/cnijfilter.list
echo "deb-src http://ppa.launchpad.net/michael-gruz/canon/ubuntu quantal main" | sudo tee -a /etc/apt/sources.list.d/cnijfilter.list
#Add Repository Keys
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3F7B4A1D #cnijfilter
#Update repositories and install driver
sudo apt-get update
@alghanmi
alghanmi / website_mirror.sh
Created October 16, 2012 14:17
Mirror a website using wget
#!/bin/bash
MIRROR_LOCATION=$HOME/public_html/mirror/
WEBSITE=""
# Mirror sir-lab & 585 Website
/usr/usc/bin/wget --mirror --no-parent --directory-prefix=$MIRROR_LOCATION --quiet $WEBSITE
# Fix permissions to make files available online
find $MIRROR_LOCATION -type f -exec chmod 644 {} \;
find $MIRROR_LOCATION -type d -exec chmod 755 {} \;
@alghanmi
alghanmi / import_git2git.sh
Last active January 6, 2020 06:48
Import an existing git repository (A) into another (B)
#!/bin/sh
##
## Import an existing git repository (A) into another (B)
##
## Reference: http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
##
REPO_A="<git repo A url>"
REPO_A_DIR="<directory 1>"
@alghanmi
alghanmi / python_setuptools_on_aludra.sh
Created November 27, 2012 06:22
Install Python Setup Tools on Solaris 10.5 on SPARC
#!/bin/bash
PREFIX="/path/to/home/dir"
mkdir ~/bin
mkdir ~/lib
source /usr/usc/python/new/setup.sh
source /usr/usc/git/default/setup.sh
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
@alghanmi
alghanmi / cs-course_vm.sh
Last active December 10, 2015 23:58
VM Configuration for CS course developed for Ubuntu 12.04 LTS (the latest LTS). This was last tested with 12.04.3 64-bit image
#!/bin/bash
## Force to run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
SCRIPT_USERNAME=$SUDO_USER
DESKTOP_SETUP=0