Skip to content

Instantly share code, notes, and snippets.

View myusuf3's full-sized avatar
🏠
Working from home

Mahdi Yusuf myusuf3

🏠
Working from home
View GitHub Profile
@myusuf3
myusuf3 / global.py
Created March 12, 2011 01:53
Global variables in Python
globvar = 0
def set_globvar_to_one():
global globvar # Needed to modify global copy of globvar
globvar = 1
def print_globvar():
print globvar # No need for global declaration to read value of globvar
set_globvar_to_one()
@myusuf3
myusuf3 / models.py
Created March 13, 2011 04:03
currently what I have not completed all the way through
from django.db import models
from django.contrib.auth.models import User
class ProloggerUserManager(models.Manager):
def create_user(self, user):
pro = ProloggerUser(user = user)
pro.save()
class AchievementsManager(models.Manager):
pass
@myusuf3
myusuf3 / shift command
Created April 12, 2011 19:00
bashfu - shift command
#!/bin/bash
# This script can clean up files that were last accessed over 365 days ago.
USAGE="Usage: $0 dir1 dir2 dir3 ... dirN"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
@myusuf3
myusuf3 / uninstall.sh
Created April 21, 2011 03:06
how to cleanly uninstall python packages installed with python setup.py
# Next time you need to install something with python setup.py -- which should be never but things happen.
python setup.py install --record files.txt
# This will cause all the installed files to be printed to that directory.
# Then when you want to uninstall it simply run; be careful with the 'sudo'
cat files.txt | xargs sudo rm -rf

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@myusuf3
myusuf3 / bash.sh
Created May 7, 2011 19:34
installing easy_install
$ sudo apt-get install python-setuptools python-dev build-essential
@myusuf3
myusuf3 / bash.sh
Created May 7, 2011 19:44
creating a new virtualenv
$ virtualenv --no-site-packages django-mimo
@myusuf3
myusuf3 / bash.sh
Created May 7, 2011 19:49
using pip to install into virtual env
$ pip install -E django-mimo Django
@myusuf3
myusuf3 / bash.sh
Created May 7, 2011 20:00
freezing
# creating requirements file from a virtualenv setup
$ pip freeze -E django-mimo > requirements.txt
# installing from a requirements file
$ pip install -E django-mimo -r requirements.txt
@myusuf3
myusuf3 / bash.sh
Created May 7, 2011 20:00
freezing
# creating requirements file from a virtualenv setup
$ pip freeze -E django-mimo > requirements.txt
# installing from a requirements file
$ pip install -E django-mimo -r requirements.txt