Possible futures, and nodebotting

You might remember that I was sorting out my music collection. This involves having to use iTunes for adding cover art and editing metadata and blah blah because I’m using a Mac and it seems that everyone has given up on making anything (anything!) better than iTunes.

So iTunes is this big huge mass of software that attempts to do everything at the same time and does nothing particularly well, and we’re all using it because there’s not much more else available. Talk about user choice, wooops.

Yesterday I was realising this horrible situation and started a parade of tweets:

  • I never know whether to cry at the immense UI failure that iTunes is or just laugh at it so ironically being the flagship product at Apple
  • When using iTunes I’m afraid to click on buttons because I do not know what havoc will that unravel. Things move around without explanation
  • There are buttons that turn into something else, something elses that act like buttons, data losses, weirdnesses, ugh
  • The worst is: there doesn’t seem to be anything better in Mac? (!?) 😭PLEASE PROVE ME WRONG, I BEG YOU 😭

Someone suggested Vox, which I haven’t tried yet. But seriously–only one suggestion! is that all that there is? I ended up thinking again about writing my own “player”. Except it would not be a player, or at least, not just a player, but I was thinking more about a sort of jukebox with sync. Of course I have other things to do right now so that’s probably not going to happen unless I win the lottery I don’t play.

I was in a good mood this morning so I decided to pretend I was funny and laugh at this whole mess with another tweet parade:

  • the year is 2030.
    you can do grocery shopping, pay council tax, vote for your fav eurovision artist and resolve git conflicts with iTunes
  • in 2045 iTunes finally gains sentience and writes the code for you. all commit messages mention titles of U2 songs
  • 2525 it is revealed that iTunes has acquired Skynet (to the tune of Visage’s In the Year 2525 but poignantly sung by Bono)
  • 3001: Frank Poole begs to be killed again by HAL 9000 when he sees iSkynet in action

And instead of sitting back and maliciously grin at the idea of this actually happening and how 2030 is in fact quite close in time and I could be saying “I told you so” in only 15 years, I grabbed my bike to go to Tableflip, the home of Nodebots in London, for a lighterweight NodeBots day.

Good things: it was a gorgeous day (specially compared to yesterday’s where it poured with rain for about 90% of the time), and I got lost in Dulwich which is a beautiful, albeit very adhoc and non-grid at all area, so it’s even a pleasure to get lost and wander around those streets.

Bad things: there was nothing bad about getting lost because there was absolutely no rush at any point during the day.

Oli was a fantastic host and he made us bacon sarnies and coffee. Their space is a-ma-zing. It’s full of tools old and new, and equipment and things and dust from sawing and weird mechanical and chemical smells, and flying things in various sizes and shapes, and there’s some other business where someone is building bikes. BIKES!!! It’s all super cool and I came back very excited about making stuff, even if I just managed to sort of use Johnny Five to control a servo:

Meanwhile, Tom was hacking on his Maschina and making it emit various sounds with JavaScript, Alex was transferring PCB positives onto another surface using an electric iron and two other guys were doing fantastic hacky stuff as well. I also got to hear about Fritzing and it looks really good.

I’m glad I got to use part of the equipment in the Spark core kit I got at JSConf.US 2014 which I still hadn’t had time to use. I’m sad I didn’t get to use the Spark core itself because the nodeschool nodebots workshop is designed for Arduinos and I wanted to see something happen physically and not just emulated, but I am certain I’ll be able to research this before iTunes can also talk to Spark devices via iPay or whatever.

Playing with hardware is fun. I am an almost total newbie in this field. I keep forgetting which pin is the N pin for LEDs (it’s the short one, I just looked it up today). I keep forgetting how to read resistors and how to connect things together. It’s all fine: it’s on the internets, somewhere, or alternatively it comes back to me once I get started. I have absolutely no expectations for what I’ll do and so I can’t let myself down if I forget everything from the last time I played with hardware. It’s OK. It’s a game. It’s fine to forget the rules, you can always re-read them.

And if you haven’t had enough future scenarios, here’s also this very funny article: A horror story that starts with Twitter.

A three.js npm template

rotating demo cube

I can’t imagine dropping a series of <script> tags on a page to build a minimally complex website anymore. I’ve got used to browserify and so I can’t go back to building my fancy 3D thingies like it was 2012 all over again.

So I made this minimal template that sets the bare minimum you might need to build a three.js powered site using browserify via gulp. That lets you use any other npm-based modules and libraries you want! So your code should not be messy and/or a tremendously big file with everything tucked on it.

There’s also some extra help like a file watcher… and not much more, really.

Do let me know if you use it for something cool… or if you can/want to help on this issue! 😀

Organising my music collection with find and ffmpeg

Since I bought a Synology NAS I’ve been spending time sorting out my music library. Let’s say it’s been a very relaxing hobby as I get to listen to music I hadn’t listened to in years, and it brings back great memories and also brings me to research about “what happened to that indie artist whose protected demos I downloaded from MySpace using Firebug in 2007″ and I end up in a YouTube hole looking for remixes and live versions of my favourite tracks, so that’s fun.

People always ask me why do I bother keeping an MP3 collection, when “I could just use a service like Spotify”. The answer is: I like indie music and obscure music and bootlegs and all sorts of things that the record label won’t put on Spotify, mostly because often the record label has either disappeared or there isn’t even a record label to start with (as is the case with unsigned artists). So curating this sort of collection is a very interesting hobby–sometimes I feel like I own the last copies of the music of some artists as their myspace pages have disappeared, etc.

But there are things I do not really enjoy doing, namely repetitive stuff.

So whenever I can automate something I will do. The terminal is really great for that–and this is a bit of an exercise to improve my bash skills too! 😎

Task 1: remove unneeded files from a folder and its subdirectories

Sometimes you download a bunch of music files and they’re organised in directories. And maybe there’s a lot of .url or .rtf or .txt files you don’t care about. You could go and delete them manually, or you could just use find to remove them in just one command:

For example, to delete all .m3u playlists in a folder and its subdirectories:

find . -iname *.m3u -delete

You could just run it without the -delete switch to make sure you’re not deleting too much (there is NO going back with this! no recycle bin!)

find . -iname *.m3u

Task 2: Rename cover [whatever].jpg to folder.jpg

Apparently these Synology devices will use folder.jpg to display the cover art of each album, assuming each album is “a folder” and there is such a named imaged file in the folder. But these files are sometimes not named like that; they might be cover.jpg or random-string-of-letters-and-numbers.jpg. Again, you could rename them manually, or you press the turbo pedal and go megafaster with this:

find . -iname *.jpg -execdir mv {} folder.jpg \;

Warning: this is somehow a bit too “fire and forget”, and might fail if there are already existing folder.jpg files or just more than one file in the directory. I haven’t tested those scenarios, but what you can do before running the actual renamer is to use find to list the files that match the .jpg pattern. If you find one per folder, then you’re good to go:

find -iname *.jpg

Probably an over-the-top improvement would use ImageMagick‘s convert to list the size of the files and just rename to folder.jpg the largest one, or whatever, but I am not so obsessed with perfection, and besides I’m only running this on one artist’s folder. Also: maybe if you’re having so much logic, perhaps it’s better if you write that logic in an intelligible sort of script such as Python or Node.js. Your future self will thank you forever, unlike if you write Bash code full of back ticks and other mysterious powertricks you find in Stack Overflow and painfully assemble together, only to forget immediately.

Task 3: convert the files to a format you actually like

I’ve also got music files in formats I don’t like. I’m a bit of a savage and don’t care so much about FLAC or sound purity (here, I said that), because I don’t actually listen to music in high end equipment, and besides I used to listen to music in tapes that had been used and reused so many times you could still listen to the previous three or four recordings, so even the crappiest digital encoding is often like super state of the art for my ears.

I tend to just convert FLAC stuff to 320k MP3, but this also works for converting those horrid M4A files to MP3, and OGG to MP3, or WAV to MP3 (yeah, some artists think that WAV is a good distribution format!).

For example, this will convert all *.wav files in a directory to 320K MP3 while keeping the metadata. You’ll need ffmpeg installed (you can install it on a Mac with brew install ffmpeg).

(for FILE in *.wav; do ffmpeg -i "$FILE" -f mp3 -ab 320000 -map_metadata 0 -id3v2_version 3 "`basename "$FILE" .wav`.mp3" || break; done)

Replace .wav with the extension you hate the most: e.g. .m4a, and for grittiest results and even more savage souls than mine, you can drop the file size by reducing the bit rate to 128000 or even worse–use 64000 for a very convincing “Using an MP3 player from the 90s with 64 Megs of RAM with very shitty earphones” feeling.

It just occurred to me that maybe you could also use this one to convert a bunch of videos from talks into “podcasts” (by stripping out the video and just keeping the audio), but I haven’t tried that.

If you have cool music power tricks to process audio files do send them my way on the comments section–I’d love to add them to my arsenal :-)

Today’s accidental success, or how I scared this random caller away without even realising it

I am the worst for phone calls. If you want to speak to me, you have to make a serious effort and let me know that you’re going to call me by any other means, so I am aware of that and pay attention to the little device.

Today was one of those very rare days in which I was expecting a call, so I took the phone out of “silent, no interruptions whatsoever” mode, and went on with my deeply mental and brainy work.

Out of a sudden the phone rings and I’m pleasantly surprised because I realised I had remembered to take it out of silent mode, and also because I had noticed it was ringing–sometimes I don’t even realise it is, much to the dismay of whoever is trying to call me.

So I pick the call and all I hear is blablablablabla bla bla (something that might sound like my name) blablabla bla calling from blablablabla.

But even if I had noticed the phone call, my brain was still engaged on my previous task. It just didn’t process what the “parrot” on the other side of the line was blabbing. So I ask her to repeat it again.

And again.

“Sorry, I still don’t know what are you talking about. You are calling me from where?”

She repeats it again.

I still don’t understand what she’s saying. The place she says she’s calling me from sounds like something similar to somewhere else that only has a tenuous relationship to me, but no actual reason to call me whatsoever, so I am very confused. I genuinely want to understand what she’s saying, so I please ask her to repeat the question again.

She’s furious.

“NEVER MIND. Maybe I will call some other time!”

And she, to my surprise, terminated the call!

Some seconds after, I keep trying to process where was she calling me from, and it finally comes to me.

“Aaaah, that was it!”

But it was too late… and she had accidentally revealed to me the secret to get rid of callers! MWHAHAHAHA 😈

npmoffline: installing npm packages from the cache

npm has a feature where you can ask it to install packages from the cache, where cache-min forces npm to avoid installing packages younger than that value:

npm --cache-min 9999999 install <package-name>

This works, but I’m never going to remember that syntax, so I added an alias to my .bashrc file:

alias npmoffline="npm --cache-min 9999999 "

So now when I’m offline on a plane and want to install a package that I’ve already installed in the past (and so I know is in the cache), I can write this:

npmoffline install <package-I-already-installed>

and it will pull the contents from my cache.

Yayyy 🎉

If it doesn’t work you can also list the contents of the cache with

npm cache ls

and see what packages and versions have been cached. Perhaps you can also grep it, to discard the packages you’re not interested in, e.g. the following will only list entries related to node-firefox:

npm cache ls | grep node-firefox