Skip to content

Instantly share code, notes, and snippets.

View brianz's full-sized avatar

Brian Zambrano brianz

View GitHub Profile
@narfdotpl
narfdotpl / mysqldb.markdown
Created December 4, 2010 16:01
MySQLdb, Python 2.5 and OS X 10.6

MySQLdb, Python 2.5 and OS X 10.6

I wasted too much time trying to make MySQLdb work with Python 2.5 (mysteriously it worked fine with 2.7). I thought I'll share my experience.

I installed MySQLdb normally with pip install MySQL-python (yeah, ingenious name) and there were no problems. But every time I imported it, I got following error:

@dmpayton
dmpayton / mongoengine_middleware.py
Created January 18, 2011 04:37
Django middleware to ensure that a separate mongoengine connection is made per thread.
import mongoengine
from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed
class MongoEngineConnectionMiddleware(object):
''' Ensure that a separate mongoengine connection is made per thread.
See: http://groups.google.com/group/mongoengine-users/browse_thread/thread/1aa3f9d65627c04
Assumes the following is your Django settings. Tweak as needed.
MONGODB = {
@cwestin
cwestin / aggregate.js
Created May 26, 2011 18:34
Mongo shell script and sample documents used for my aggregation talk at MongoSF
/* sample aggregate command queries */
// make sure we're using the right db; this is the same as "use mydb;" in shell
db = db.getSisterDB("aggdb");
// just passing through fields
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
@afternoon
afternoon / git-slim.py
Created December 5, 2011 14:42
Remove large objects from a git repository
#!/usr/bin/python
#
# git-slim
#
# Remove big files from git repo history.
#
# Requires GitPython (https://github.com/gitpython-developers/GitPython)
#
# References:
# - http://help.github.com/remove-sensitive-data/
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active March 31, 2024 18:45 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@Mins
Mins / mysql_secure.sh
Last active February 16, 2024 00:03
Automating mysql_secure_installation
#!/bin/bash
aptitude -y install expect
// Not required in actual script
MYSQL_ROOT_PASSWORD=abcd1234
SECURE_MYSQL=$(expect -c "
set timeout 10
@SEJeff
SEJeff / gist:5257789
Created March 27, 2013 20:36
Example salt config for preferencing dev but falling back to prod
# This would go in /etc/salt/master
file_roots:
base:
- /srv/salt/base
dev:
- /srv/salt/dev
- /srv/salt/qa
- /srv/salt/base
qa:
@tito
tito / bluetooth.py
Created November 12, 2013 15:28
Bluetooth example on Android using Python / Pyjnius
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
Connect your device to your phone, via the bluetooth menu. After the
pairing is done, you'll be able to use it in the app.
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)