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 / 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 / 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 / smiley_paran.py
Created September 26, 2013 03:26
Paran Matcher that accepts smileys
def paran_check(expression):
#print expression
index = 0
#calculate '(' ')' index
for c in expression:
if c == '(':
index = index + 1
elif c == ')':
index = index - 1
@alghanmi
alghanmi / HelloWorld.java
Created September 30, 2013 01:10
Bad Hello World Example
/*
Hello World example
*/
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hi World!");
}
@alghanmi
alghanmi / bashrc_additions.sh
Last active December 26, 2015 04:39
VPS Basic Account Setup
##
## User Modifications
##
#Set Default Editor
EDITOR=vim
##XTERM modifications (in case needed)
#export TERM="xterm-256color"