notesToSelf 1.0

Things to keep handy

Retro NES Projector Console

trading stock option This post describes how to re-purpose a NES console into a self-contained console with integrated Projector and games using a Raspberry Pi.

go here

go site After seeing many very cool retro gaming ideas on Pinterest I decided to try and make one. Management wouldn’t approve a full size gaming cabinet as they had already approved a retro console in the yet-to-be-built breakfast bar. Instead, while I waited for the kitchen to become a reality, I forged ahead with a mini project using my favourite beloved childhood console the Nintendo Entertainment System. With the very cool NES30 controllers from 8BitDo I wondered whether a standalone NES could be integrated with a projector to play 8BIT on epic scales…

follow link  

  1. Source a broken NES
  2. Bleach it back to grey
  3. Parts and Tools
  4. Projector
  5. Power
  6. BUILD
  7. Final Touch – the happy red LED
  8. To-Do

buy Lyrica 300 mg online  

Sourcing a NES

come enter site hellendoorn gemeentehuis autohifi asennus lama dari biasanya. Tunggu saja sampai masuk tampilan SAMSUNG Galaxy Selamat…

Time to upgrade from Java2 to Java8


I’m using Storm at work (a bank, using An Apache 1.0 Project?). I like the sound of it because I can write python, but really why bother figuring out how to mix Java with python (the rest of the IT team when I can just learn Java?)… Well the hand-me-down book I originally learned Java from was Sams Teach yourself Java 2 in 21 days fourth edition, first printed 2004! Time for an upgrade…

This was a very enthusiastic and humourous presentation of the benefits of Java8, well worth a watch.

Down to Foyles tomorrow to Pick up something more current… Then get storm working.

An observation by a colleague, C++ by training but now knee deep in Java, said that Java code is always telling something else what to do. I agree, all I ever see are methods that call other methods. Luckily the Functional programming seems to get rid of (some of?) that and distills it down to the real meat.

Presently ploughing through Storm Applied from Manning.

Installing openCV for Python

Some smart chap has installed opencv on a mac and explained how to do it here

brew tap homebrew/science

Then for the information type:

brew info opencv

I used the options with-ffmpeg (because I want mpg4?) and without-numpy (I already have it)
brew install opencv --with-ffmpeg --without-numpy


10 minutes and 30seconds later. it was built…

As I’m using anaconda I navigated to my root packages…
cd /anaconda/anaconda/lib/python2.7/site-packages

made a new directory

mkdir opencv

enetered it:

cd opencv

then navigated to where my brew python libs should have been and checked they were there (they were)

cd /usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages/

then I got the full directory with


and pasted the below into the terminal window that was still in the /anaconda/anaconda/lib/python2.7/site-packages/opencv folder and ran:

ln -s /usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages/
ln -s /usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages/
TO-DO: Tell anaconda it’s there – (not showing in conda list)

Setting up python to process videos… FPV HUD stage1

So a micro-project is to generate HUDs for FPV Drone Racing… The coolest thing since sliced bread to uubergeeks

Truth is I honestly don’t know how i managed to get this working.. I had some pretty strange errors along the way but I’ve managed to do it so I wanted to note down how in case my laptop dies, is stolen or someone else wants to try.

What I want to do for phase 1:

Phase 1 was always going to be the hardest.

The first googling turned up this:


That’s great but nor very user-friendly.

next search was this:

More my level of skills (Thanks to the really bright people who can actually write libraries…), so this gives two options

  1. pylabs/imageio (imageio is the workhorse as pylabs was not referenced in the example)
  2. scikit-video

I’m using Anaconda for my python environment so i tried the usual
conda install imageio

But no luck, then I actually read the documentation (sorry!) and tried:
conda install -c pyzo imageio

That didn’t work, so i tried the PIP install method on the same page
pip install imageio

This should have done it but when I tried to restart the kernel in my ipython notebook and import it, it was not found in my packages…

Some faffing with my conda Environment (I had not set up an environment and was using root) gave more strange errors- even the example (conda create --name snowflakes biopython) would not work as a previously cocked up version of this command meant it kept looking for a package that did not exist (the name of my new environment videoedit)

Eventually after much faff I managed to make a new environment (not my exporting to txt as a lot of my packages were clashing (due to a recent numpy upgrade)
Richards-MBP:~ richardpeter$ conda create --name videoed --clone root
Source: /anaconda/anaconda
Destination: /anaconda/anaconda/envs/videoed
The following packages cannot be cloned out of the root environment:
- conda-4.1.6-py27_0
- conda-build-1.19.0-py27_0
Packages: 184
Files: 444
Linking packages ...
[ COMPLETE ]|###################################################| 100%
# To activate this environment, use:
# $ source activate videoed
# To deactivate this environment, use:
# $ source deactivate

Success! ?

Looking in my environment I could in fact see the imageio in there with <PIP> as the version… which meant it was in fact in my root so should have been in my jupyteer/ipython notebook all along! (!!!!?)

Anyway, I killed my current ipython session, did gts * iqoption NOT enter my videoed environment and just ran the below in the terminal:

ipython notebook

It worked….  I don’t know why but it did.


2: Convert to numpy array:

After trying to edit one of my own mp4 files to a manageable 30s without success I downloaded this small, low res 1mb file from here.

A few lines of python later I’d flattened the image to a greyscale and plotted it:


Screen Shot 2016-07-10 at 20.51.54


3) Laplace Filter

Following the documentation  here a few more lines of python code give us a Laplace Filter:

from scipy.ndimage import correlate1d
from scipy.ndimage import generic_laplace

def d2(input, axis, output, mode, cval):
return correlate1d(input, [1, -2, 1], axis, output, mode, cval, 0)

a = np.zeros((3, 3))
a[1, 1] = 1
lf = generic_laplace(a, d2)

array([[ 0., 1., 0.],
[ 1., -4., 1.],
[ 0., 1., 0.]])
Cool. And we can apply this to our image with a few more lines of python:

from scipy.ndimage import correlate
plt.imshow(correlate(img_grey, lf),cmap=’Greys_r’)

Screen Shot 2016-07-10 at 22.23.36

Somewhere in here you can vaguely see the outline of the scene.. but not quite what I was after… Perhaps a Sobel Filter instead? (And looking at the docs prewitt while we;re at it…)

from scipy.ndimage.filters import sobel, prewitt

Screen Shot 2016-07-10 at 22.33.18


Screen Shot 2016-07-10 at 22.33.58

Hurrah! … But still not enough to be able to spot a competing drone…

Let’s try to make it more black/white… I wonder…

sob = sobel(img_grey)

sob.min(), sob.max()

(-560.66666666666663, 480.66666666666669)


To Dosob[sob>0] = sob[sob>0]*-1

Screen Shot 2016-07-10 at 22.41.47

Better… but perhaps still not enough to identify a drone..

Googling edge detection in Python – looks like someone has been here before:

And what I want is likely in openCV…

Tomorrow’s work…


Calculating the percentage of intersection between two shapefiles: ZIPCODES and Community Areas

iPython note:



This was a favour for the lovely missus – She needed to look at census data , provided by ZIP code, but was working with an organisation that was interested in community areas.

Census data can be obtained in the form of Population/unemployment/Ethnic minority in each zipcode.

To translate this to Community area, we can make an approximation by weighting each zipcode by the portion of it’s Area in each Community area.

This is not a perfect mapping, for example, in zipcode 60101 there may be a part that overlaps Community Area ‘LOOP’.   in this case nobody from 60101 would live in the LOOP, but you would assign some of the unemployed population to that Community area.

Anyway, it’s a first approximation and that’s all we need for now.

Shapefiles for Community Areas are here:

Shapefiles for ZIPs are here:


Code Highlights osgeo package and Pandas (of course)
from osgeo import ogr
import os
import pandas as pd #My favourite Package!


Import a shapefile downloaded from the

driver = ogr.GetDriverByName('ESRI Shapefile')
daShapefile = r"yourCommunitiesFile1.shp"
Communities = driver.Open(daShapefile, 0)
# 0 means read-only. 1 means writeable.

# Check to see if shapefile is found.
if Communities is None:
print 'Could not open %s' % (daShapefile)
print 'Opened %s' % (daShapefile)
com_layer = Communities.GetLayer()
featureCount = com_layer.GetFeatureCount()
print "Number of features in %s: %d" % (os.path.basename(daShapefile),featureCount)

daShapefile2 = r"yourZIPShapeFile1.shp"
ZIP = driver.Open(daShapefile2, 0)
# 0 means read-only. 1 means writeable.
if ZIP is None:
print 'Could not open %s' % (daShapefile2)
print 'Opened %s' % (daShapefile2)
z_layer = ZIP.GetLayer()
featureCount = z_layer.GetFeatureCount()
print "Number of features in %s: %d" % (os.path.basename(daShapefile2),featureCount)

z_layer = ZIP.GetLayer()
c_layer = Communities.GetLayer()

Create a dictionary:

wt = {}
for z_lyr in [z_layer.GetFeature(i) for i in range(z_layer.GetFeatureCount())]:
z =
zg = z_lyr.geometry()
    for c_lyr in [c_layer.GetFeature(j) for j in range(c_layer.GetFeatureCount())]:
cg = c_lyr.geometry()
intersection = cg.Intersection(zg)

Create a list of the communities:

communities = []
for c_lyr in [c_layer.GetFeature(j) for j in range(c_layer.GetFeatureCount())]:


Create a pandas DataFrame and export to excel:

tbl = pd.DataFrame(wt).T
tbl.to_excel('zip-community weights.xls')

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

© 2018 notesToSelf 1.0

Theme by Anders NorenUp ↑