Skip to content

Instantly share code, notes, and snippets.

View muhammad-ammar's full-sized avatar

Muhammad Ammar muhammad-ammar

View GitHub Profile
# -*- coding: utf-8 -*-
import os
import StringIO
import hashlib
try:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
raise ImproperlyConfigured, "Could not load Boto's S3 bindings."
@muhammad-ammar
muhammad-ammar / pedantically_commented_playbook.yml
Last active August 29, 2015 14:25 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@muhammad-ammar
muhammad-ammar / gist:4104b3a436dfa3007dc773a3e31e7954
Created August 22, 2016 10:37 — forked from carlosmcevilly/gist:2221249
fix git commit with wrong email address in git config, before pushing
If:
- you add and commit with the wrong email address in git, and
- your remote has a hook set up to prevent you from pushing with the bad address
Then you need to amend the author of your commit before push can succeed:
1. fix your email address in git config:
$ git config user.name "Your Name"
@muhammad-ammar
muhammad-ammar / README.md
Created October 1, 2016 21:15 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@muhammad-ammar
muhammad-ammar / notify.py
Created June 6, 2017 10:00 — forked from lukaszb/notify.py
Simple Python script to send notification to the OSX Notifications Center (requires OS X 10.8+). Tested with pyobjc 2.5.1
#!/usr/bin/env python
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
from optparse import OptionParser
def main():
parser = OptionParser(usage='%prog -t TITLE -m MESSAGE')

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});

When you modify a file in your repository, the change is initially unstaged. In order to commit it, you must stage it—that is, add it to the index—using git add. When you make a commit, the changes that are committed are those that have been added to the index.

git reset changes, at minimum, where your current branch is pointing. The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits:

- A - B - C (master)

HEADpoints to C and the index matches C.

--soft

@muhammad-ammar
muhammad-ammar / __init__.py
Created March 4, 2020 22:18 — forked from aubricus/__init__.py
Using Fabric to connect to the remote server via an ssh config.
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
}
@muhammad-ammar
muhammad-ammar / log_db_queries.py
Created June 1, 2020 09:03 — forked from bak1an/log_db_queries.py
django decorator for logging db queries
# simple decorator for logging out django db queries
# just put it along with other decorators before view or
# db-loading stuff. than go to your console and see whats going on.
# example:
#
# @log_db_queries
# @login_required
# def your_view(request, args...):
# your stuff
def log_db_queries(f):