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 / iCalWeekGenerator.py
Created January 23, 2013 21:16
iCalWeekGenerator is a commandline based tool that could be used to generate recurring weekly events with an icon in iCal format. The goal is to have a small icon on every Monday (or other day) holding the week number. I use this to mark weeks in the academic calendar.
import argparse
from datetime import date
from datetime import datetime
from datetime import timedelta
"""
TODO: Add timezone support
"""
# Global Variables
@alghanmi
alghanmi / render-md.py
Created January 25, 2013 08:43
Render a Markdown document using the GitHub markdown API
import argparse
import requests
import simplejson
def gitHubPost(text, mode, context):
"""Send a POST request to GitHub via API """
payload = {'text': text, 'mode':mode}
if context != None:
payload['context'] = context
@alghanmi
alghanmi / git-submodule_commands.sh
Last active December 13, 2015 18:18
Commands for git submodules
##
## Initial Setup
##
#Add an external repository as a submodule
git submodule add $GIT_REPO1
git submodule add $GIT_REPO2
#Grab the submodules
git submodule init
@alghanmi
alghanmi / draw_graph.py
Last active December 14, 2015 08:29
Draw GML graph using graph-tool
from graph_tool.all import *
import argparse
""" Parse Commandline Arguments """
parser = argparse.ArgumentParser()
parser.add_argument("file", help="GML file name", type=argparse.FileType('r'))
args = parser.parse_args()
""" Draw Graph """
g = load_graph(args.file.name)
@alghanmi
alghanmi / git_log.sh
Last active December 14, 2015 11:38
Git Log Catalog
# SHA, Date, Name<email> in color
git log --format='%C(yellow)%H%C(reset) %C(red)%aD%C(reset) %C(blue)%aN <%aE>%C(reset)' --stat
# Submodules (starting with puzzle_), SHA, Date, Name<email>
for i in $(find . -maxdepth 1 -mindepth 1 -type d -name "puzzle_*" | tr "\n" " "); do cd $i; echo "$i $(git log -1 --format='%H %aD %aN <%aE>')"; cd ..; done
# Submodules (starting with puzzle_), SHA, Date, Name<email> -- colored
for i in $(find . -maxdepth 1 -mindepth 1 -type d -name "puzzle_*" | tr "\n" " "); do cd $i; echo "$i $(git log -1 --format='%C(yellow)%H%C(reset) %C(red)%aD%C(reset) %C(blue)%aN <%aE>%C(reset)')"; cd ..; done
# List SHA for all files/directories/submodules
@alghanmi
alghanmi / android_mount.sh
Last active December 15, 2015 14:49
Setup to mount Android devices on Linux box given the vendor. Listed devices are: + Nexus 7 + Galaxy Nexus (GSM)
#Install MTP Packages
sudo apt-get install mtp-tools mtpfs
#UDev entry for Nexus 7
echo 'SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"' | sudo tee -a /etc/udev/rules.d/99-android.rules
#UDev entry for Galaxy Nexus
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="685c", MODE="0666"' | sudo tee -a /etc/udev/rules.d/99-android.rules
#Restart UDev
@alghanmi
alghanmi / deluge-daemon_init.sh
Last active February 5, 2016 07:29
Deluge init script taken from the Deluge User Guide. Note that references to deluge web are removed. http://dev.deluge-torrent.org/wiki/UserGuide/InitScript/Ubuntu
#!/bin/sh
### BEGIN INIT INFO
# Provides: deluge-daemon
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemonized version of deluge and webui.
@alghanmi
alghanmi / html5.html
Created June 11, 2013 17:45
Sample valid HTML5 page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to DOMAIN</title>
</head>
<body>
<h1>Welcome to DOMAIN</h1>
<p>You have successfully arrived at your destination.</p>
</body>
@alghanmi
alghanmi / default-ssl.conf
Last active December 18, 2015 09:19
Nginx default configuration
server {
listen 80;
listen 443 default_server ssl spdy;
ssl_certificate SITE_HOME/ssl/DOMAIN.crt;
ssl_certificate_key SITE_HOME/ssl/DOMAIN.key;
#Perfect Forward Secrecy
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@alghanmi
alghanmi / google-authenticator.sh
Created July 28, 2013 12:53
Setup Google Authenticator on OpenVPN
sudo aptitude install libpam0g-dev
git clone https://code.google.com/p/google-authenticator/
cd google-authenticator/libpam/
make
sudo make install
google-authenticator
sudo cp /etc/pam.d/common-account /etc/pam.d/openvpn