Python ipcam library for Foscam and other ip web cameras

Here is a very helpful, easy to use, python library for Foscam and other ip web cams. I have been using it with a Raspberry Pi.

IPCam Python Library

Here’s an example of how it works:

Instantiate a camera connection.

from ipcam import IPCam

cam = IPCam(host='',

Get a snapshot from the camera.

snapshot = cam.get_snapshot()

Save the snapshot to a file.

from datetime import datetime

file_name_suffix ="%Y%m%d_%H%M%S")
file_name = 'snapshot_{}.jpg'.format(file_name_suffix)
f = open(file_name, 'wb')

Additionally, you can set camera parameters easily as well, they’re all by name, and right on the connection object.


Installing Psycopg2 on Mac OS X – pg_config missing – libssl not loaded


Psycopg2 installation not finding pg_config from Postgresql. Also, upon using psycopg2, it fails with Library not loaded: libssl.1.0.0.dylib.


  • Mac OS X Mavericks
  • Postgresql from Mac OS X Installer on (Using 9.3 in this case)
  • Python 2 or Python 3


  • Missing pg_config
  • Library not loaded: libssl.1.0.0.dylib


There is no need to add postgresql via homebrew just to get libraries. The application installer already installs them.

Additionally, you do not want to redefine DYLD_LIBRARY_PATH. This will break other dynamic links even though the default value is empty.

You simply need to add 1 environment variable to resolve the missing pg_config on installing psycopg2.

Then add 2 symbolic links to resolve the location of libssl.1.0.0.dylib and libcrypto.1.0.0.dylib when using psycopg2.

export PATH=/Library/PostgreSQL/9.3/bin:$PATH

ln -s /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib
ln -s /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib

Python 3 Lines of Code Counter

Based on the python 2 lines of code counter here, this version works with Python 3, and separates blank lines, comments and, properly, doesn’t count a single line broken with backslashes as separate ‘lines of code.’ Additionally, it breaks out the TODOs in the comments.

The final report’s “Lines of code” is as close to REAL functional, individual lines of code as any LOC counter we’ve seen.

By default, it will count recursively from the path it is run from, however, optionally, you may pass a single argument with a starting path and it will recursively check all files from the path specified.

Example usage:

./ myproject

Here it is:

import os, sys

exts = ['.py']

if len(sys.argv) > 0:
    use_path = os.path.basename(sys.argv[1])
    use_path = os.path.dirname(sys.argv[0])

here = os.path.abspath(use_path)

def read_line_count(fname):
    line_cnt = 0
    blank = 0
    comment = 0
    todo = 0
    for line in open(fname).readlines():
        if len(line.strip()) > 0:
            if line.strip()[0] is not '#':
                if line[-2] is not '\\':
                    line_cnt += 1
                comment += 1
                if line.find('TODO') > -1:
                    todo += 1
            blank += 1

    return {'line':line_cnt,'comment':comment,'todo':todo,'blank':blank}

if __name__ == '__main__':
    line_count = 0
    comment_count = 0
    todo_count = 0
    blank_count = 0
    file_count = 0
    for base, dirs, files in os.walk(here):
        for file in files:
            # Check the sub directorys            
            if file.find('.') < 0:
            ext = (file[file.rindex('.'):]).lower()
                if exts.index(ext) >= 0:
                    file_count += 1
                    path = (base + '/'+ file)
                    c = read_line_count(path)
                    print(path[len(here):]+" : "+str(c['line']))
                    line_count += c['line']
                    comment_count += c['comment']
                    todo_count += c['todo']
                    blank_count += c['blank']

    print('Files            : '+str(file_count))
    print('Lines of code    : '+str(line_count))
    print('Comments (TODOs) : '+str(comment_count)+' ('+str(todo_count)+')')
    print('Empty lines      : '+str(blank_count))
    print('Total lines      : '+str(line_count + comment_count + blank_count))

Time Warner & CBS Blackout : Again Consumers Hurt by Cable Company aka Middle Man

Time Warner Cable has recently blacked out the CBS network in some of its Cable TV markets. CBS, in turn, blocks streaming videos of blacked out TV shows for Time Warner Cable Internet subscribers. Time Warner continues to collect full, monthly fees from its subscribers while the channel lineup is now hobbled. While CBS continues to collect full advertising revenue. So who gets hurt? The consumer. Paying full price and getting less and less.

What’s happening? This doesn’t seem right.

In the day of high speed internet and digital home theater systems with Internet enabled TVs, set top boxes and game consoles, why can’t we get on demand, a la cart content? Because your local cable provider has the content providers (networks such as NBC, CBS, HBO, CNN, etc) wrapped up in non-compete deals, even if just implicit. Leaving the consumers with little choice but to buy “channel packages” from the Cable Providers. Hundreds of worthless channels simply because you want the local stations, History Channel and HBO (like me).

What can we do about it? DROP YOUR CABLE SUBSCRIPTIONS.

Recently, the CEO of HBO ‘publicly considered’ offering HBO as a standalone subscription service. YAY! This sounds great. I’d pay $10-$15 per month for this. Unfortunately, he decided not to. Maybe it doesn’t make good business sense to give more customers what they want.

Thankfully, more and more consumers are becoming “cord cutters” and getting rid of cable. Hopefully, we can get even more consumers to follow until all your cable company provides is a nice, fast, reliable Internet connection. On top of which you watch TV and make/recieve phone calls.

This technology has been available for years. The content distribution networks are in place. Now, it’s up to the consumers to stop paying the “middle man.”

By the way, CBS is not innocent in all of this. They’re equally greedy. By the way, why does Time Warner have to pay CBS when you can get an antenna and watch it for free? Because when there’s a middle man everyone wants to make money from their business model…that is now antiquated and getting in the way of progress.

Apple Has Crossed The Line

Apple’s release of Mountain Lion this week was exciting. Up until I found out my perfectly capable, late 2006, 64-bit, MacBook Pro upgraded to 4GB RAM, and a 500GB Hard Drive was intentionally blocked from running Mac OS X version 10.8 (aka Mountain Lion).

I’m quite sure I don’t have another $2000 to replace a laptop that actually is still running fast and working perfectly. One of my favorite ‘evangelistic’ selling points to non-Mac potential converts is that I had a 6 year old MacBook Pro working perfectly and running the latest software.

For no real technical reason, I can’t say that anymore. I don’t like Windows, and at some point I will need a new computer. But I don’t want to buy Apple anymore. Since 1989, when I used the my first Mac, this is the first time my heart was broken by Apple. Now what do I do?

Until they rethink this…I say BOYCOTT APPLE!