Ansible ec2_eni error solution

If you’re using Ansible with the AWS EC2 plugin ec2_eni and getting this error:

AttributeError: 'NetworkInterface' object has no attribute 'attach'

The problem is that the boto NetworkInterface object indeed does not have anything called “attach” — you’re probably using an old version of boto; “attach” was added somewhere between 2.20 and 2.38. So, upgrading your boto version should fix it.

First, check that you don’t have boto installed via your package manager; I opened Ubuntu’s Software Sources and searched for boto, sure enough had to uninstall it.

Then, install the latest version with “sudo pip install boto”. Should work now!

Advertisements

Cable for connecting APRSdroid to a Baofeng UV-82 Radio (APRS via RF)

aprs cable

This cable follows the below diagram precisely; note the color-coded heat shrink, and note that the TRRS plug’s internal wiring is such that the Tip is wired to the furthest-left solder point, followed by R1 and R2, and finally the Sleeve solder point is actually also the strain relief and threaded housing. So you’ve gotta think a bit backwards (and/or use an ohmmeter to check your wiring.)

Sources:

Warning, this alternative *may* be more reliable than mine: https://github.com/johnboiles/BaofengUV5R-TRRS

And this article has a lot of helpful hints: http://www.wcares.org/?page_id=2677

And of course, using a Bluetooth TNC, etc, is going to be much more reliable than this hack. I don’t use this on a regular basis.

Finally, this cable seems to work well on my Samsung Galaxy Nexus, but is not detected as an output by my Nexus 5x when plugged into the radio so it might need different resistor values or connections depending on your devices.

I harvested a cheap Baofeng handheld speaker/microphone for its cable (although you can buy them here — the Kenwood type) and bought a 3.5mm TRRS plug from Digi-key. It’s a bit tight to solder the resistors inside the plug housing, but it is possible (just remember to put the plug housing on the cable BEFORE soldering, otherwise you’ll be unable to put it on later… a mistake I made about three times.)

Here are the diagrams:  Continue reading

Fixing: Cannot set session ID after the session has started in PHPUnit

I got this error after adding an onKernelRequest listener to my Symfony project and trying to pass Twig_Environment to it as an argument. It worked via the web browser, but not in any PHPUnit tests hitting multiple pages.

After much head scratching and reading of the Symfony source code, I ended up making an onKernelException listener instead. Magically, rendering a twig template from it (passing a TwigEngine argument) worked.

So, here’s how I handle custom exceptions in a custom way. Notice I’m testing for Twig_Error_Runtime because my specific error is coming via Twig; you may be able to just test for regular Symfony exceptions instead:

https://gist.github.com/zyphlar/e1089be4c0f0499ab08b

Two Unrelated (No association) Entities in One Form in Symfony2

A lot of tutorials are showing you how to create embedded forms with associations/relations — what about unrelated entities?

I figured out you can pass the second entity as a parameter to the parent form, pass it normally to the embedded form via the ‘data’ parameter, which will let the embedded form update the object. Then just persist() the object back in the controller like normal. No crazy data/request wrangling necessary! Continue reading

Logging NAT/Firewall/state entries in Pfsense

Sometimes you really need to know what computers on your network were doing yesterday at noon, because you get a nastygram from the MPAA about bittorrent demanding that you do something — but bittorrent is notoriously hard to block.

You can try installing BandwidthD on your Pfsense router, to see who’s using a bunch of bandwidth at that time, and you can look back through DHCP or WiFi logs to see who was connected at the time, but the complaint letter tells you the exact time and port number used. Wouldn’t it be cool if you could log that?

Here’s what I came up with. Download the Cron package for Pfsense, and add a new Cron job:

Minute: 1
Hour/etc: *
Who: root
Command: pfctl -ss | egrep '(>.*>|<.*<)' | logger

The firewall states (who is connected to what) will now dump to your system log every hour — kinda noisy, but also kinda effective for tracking long downloads on random ports.