Skip to content

Instantly share code, notes, and snippets.

View shrhawk-entertainer's full-sized avatar

Syed Hassan Raza shrhawk-entertainer

View GitHub Profile
#!/usr/bin/env python
import logging
import pymongo
import datetime
class MongoHandler(logging.Handler):
"""
A logging handler that will record messages to a (optionally capped)
MongoDB collection.
# Sort a list of dictionary objects by a key - case sensitive
from operator import itemgetter
mylist = sorted(mylist, key=itemgetter('name'))
# Sort a list of dictionary objects by a key - case insensitive
mylist = sorted(mylist, key=lambda k: k['name'].lower())
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@ashpool
ashpool / gevent_queue_example.py
Created April 13, 2012 12:42
Gevent Queue example
from gevent.queue import Queue
message_queue = Queue()
def receiver(n):
while not message_queue.empty():
message = message_queue.get()
print('Received %s message %s' % (n, message))
gevent.sleep(0)
@jch
jch / rabbitmq-install-osx.md
Created April 28, 2012 23:48
Troubleshooting RabbitMQ installation on OSX via homebrew

Troubleshooting RabbitMQ installation on OSX via homebrew

brew update
brew install rabbitmq

To see if rabbitmq is running after following the installation instructions:

launchctl list | grep rabbit
> 48303	-	homebrew.mxcl.rabbitmq
@23maverick23
23maverick23 / randPassGen.py
Last active June 9, 2019 11:27
Python: Random password generator
#!/usr/bin/env python
import string
import random
def password_generator(size=8, chars=string.ascii_letters + string.digits):
"""
Returns a string of random characters, useful in generating temporary
passwords for automated password resets.
@digitaljhelms
digitaljhelms / gist:4287848
Last active July 19, 2024 03:32
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@lanqy
lanqy / bytesToSize.js
Created March 19, 2013 03:05
JavaScript To Convert Bytes To MB, KB, Etc
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
@jimothyGator
jimothyGator / README.md
Last active April 25, 2024 18:00
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@tmiller
tmiller / README.md
Last active February 2, 2024 20:41
A very simple example of using a map of channels for pub/sub in go.