Skip to main content

Posts

Chromecast audio: mirroring, streaming, authenticating

I was curious about what the Chromecast audio is and how it works - both in terms of hardware and software. After a lot of needless thrashing about, I realized that the wikipedia page has the specifications for the system on a chip, though the ifixit teardown is more detailed and also points out that the Chromecast and Chromecast audio basically have the same system-on-a-chip. Interestingly, the Synology NAS also has a Marvell Armada system. Exploitee.rs says that the system runs a modified Android system.

I was most curious about was how the software works: specifically, when I play music through the chromecast audio what is the flow of data? My web-search-fu failed me, and could not get any descriptions of this that went beyond user-level, google marketing speak. What I gather is that there are two modes of data transfer: mirroring and streaming.

Mirroring takes the audio data stream playing from a computer (laptop, smart phone, iPad) and redirects it to the Chromecast. Software on …
Recent posts

Ping spikes on Mac OS X

Problem: After (I think) an update my Mac began to show a strange pattern of network latency: A ping to my router would show a string of 1ms trip times punctuated periodically by a cluster of 400-1000ms latencies. I first realized something was wrong when I was playing counter strike and my ping would go crazy - on a server I frequent my typical ping used to be 20ms, but now it would register as 190ms, 400ms and so on. I could verify this was not a internet provider issue by pinging my router from a different computer and getting a steady string of 1ms latencies.

The solution was remarkably hard to find even though it seemed to be a common problem faced mostly by Mac users. A common response was to turn off anti-virus software, and I knew this was not the correct answer.

Solution: From the thread here (look for the answer by "eyepaq") it seems to be a bad setting or combination of settings in network preferences which can be reset by deleting the file "/Library/Prefere…

Recording terminal sessions

All coders have some use for screen casting a terminal session, usually to demo a command line tool. The old way I did this (when I migrated to a Mac) was to use Quicktime's screen recording feature, which really is superb. Then I learned of asciinema. Asciinema was very novel for me because it looked like a movie, when played through the slick player they have, but you can just go an select the text that is 'playing' and copy paste it into a terminal. Amazing!

Reading a little deeper into asciinema's docs we find that Linux actually has built in infrastructure for recording terminal sessions - with timestamps! - and also for then playing those sessions back. You use script to record the keystrokes and responses and scriptreplay to play them back! Magic!

But there is more. There is a Python package called TermRecord that packages these utilities and then dumps the output to a standalone html file! This is most convenient for sharing demos etc because everyone has acce…

gh-pages: .nojekyll

I had the devil of a time trying to get a custom website to show up on github pages. It was sphinx generated documentation and I had put it on the website under a directory called manual. It was all borked. Not only did the nice stylesheet not show up, none of the images showed up either. I tried a whole bunch of things, but finally, from a hint here, it turns out that you need to add an empty file named .nojeykll in the root directory, and that allows you to add your own custom projects.

Python - Click

Python excels at making it quick and simple to convert your one-off scripts (or so you thought) into easy to use command line driven programs. The package that made me fall in love with this process was docopt (my notes here, here and here).

A year after I started to use docopts a colleague (twocolleagues actually) introduced me to the Python click package. I was initially reluctant to migrate an existing code base to docopt, but I decided to give it a spin and have not looked back.

There was a recent post comparing argparse, docopt and click shared by another colleague, perhaps prompted by an internal debate about the merits of the different options available.

One thing that gets missed in these comparisons is more specific and complicated use cases. I just found a simple, specific use case where Click blows the other two away in terms of managing complexity and improving readability:

My application requires me to pass in key, value pairs in the command line that serve as metadata f…

Python: Getting position in a compressed file

Problem: Python's gzip module is awesome, but poses a problem when we wish to report reading progress along a compressed file: .tell() returns the total bytes read but we usually only have the compressed size of the total file available, e.g. via os.path.getsize.

Solution: One trick is probably to extract the original size of the gzipped file from the last 4 bytes in the file, but, there are interesting caveats to this. Another method, slightly more principled, is to use .raw.fileobj.tell which, interestingly, reports the position on the compressed file, rather than the uncompressed stream.

git config core.fileMode false

Problem: After moving data from a Time machine backup to a new Mac (EDIT) Actually, I copied the data to a NTFS drive and then back to a Mac, so the blame goes to NTFS, all files in a repository show up as changed files under git, even though a diff proves that their contents are unchanged.

Solution: From a tip here, it turns out that it's related to file mode (and other metadata) changes which may occur during such a restore operation (for example the UID of the user may change, I guess) the solution is to tell git to ignore the file mode


git config core.fileMode false