cat count.txt | awk '{sum+=$1} END {print sum}'
linux: netstat -lnptu
mac: netstat -a -p tcp
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 = { |
# This would go in /etc/salt/master | |
file_roots: | |
base: | |
- /srv/salt/base | |
dev: | |
- /srv/salt/dev | |
- /srv/salt/qa | |
- /srv/salt/base | |
qa: |
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:
/* 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 |
#!/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/ |
''' | |
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. |
/* | |
This example was built using standard create-react-app out of the box with no modifications or ejections | |
to the underlying scripts. | |
In this example, i'm using Google as a social provider configured within the Cognito User Pool. | |
Each step also represents a file, so you can see how I've chosen to organize stuff...you can do it however | |
you'd like so long as you follow the basic flow (which may or may not be the official way....but its what I found that works. | |
The docs are pretty horrible) | |
#!/bin/bash | |
aptitude -y install expect | |
// Not required in actual script | |
MYSQL_ROOT_PASSWORD=abcd1234 | |
SECURE_MYSQL=$(expect -c " | |
set timeout 10 |