Tag Archives: node.js

And the NodeBots from London assembled

I attended today’s NodeBots London event. The theme (?) was “NodeBots of London… Assemble!” and so we did. Compared to the last event I went to in July, which was way more informal, this was considerably bigger (within the venue allowances, of course) with more people and more things to look at and talk about!

First Oli made an introduction to NodeBots (essentially a place where people program hardware using JavaScript, but everything is allowed if you want to), what Johnny Five is and its relationship to node-serial, same for Firmata, and then some interesting tips for software people turned amateur hardware people I hadn’t heard of before, such as:

the case of the generous motor, in which you can fry Arduinos connected to motors without diodes, when the motor keeps spinning even after you stop applying input voltage, and so it becomes a dynamo which feeds current back into the circuit and so… bye bye Arduino which didn’t have any protection
the flappy servo, when you sequence value changes too fast and that results in just some feeble erratic movements instead of the dramatic ones you expected

Then Alex made an introduction to electricity, in general, which was a good refresher for people like me who studied some electrical engineering at uni/school but haven’t used it for reals since then. He explained the basics (V = IxR) and also insisted again on the importance of putting the right resistors in the right place to prevent things getting fried. He used this online circuit.js utility to depict circuits and the flow of current, the voltages at each point of the circuit (in the subcircuits perhaps?)–super useful and I so wish I had had this when I was taking these subjects. Makes things way more intuitive!

And with that—we hacked a bit! Jerome Loï (who had travelled all the way from Paris!) tried to resuscitate my pseudo fried Duemilanove with a shield and a thingy to mount the ATMega168 only, but turns out that it’s such an old board/chip combination that the bootloader firmware is not distributed anymore! So I left it aside and focused on my next task for the day: find out what the components in the kits I have are! With Jerome’s and Alex’s help, and some image searching, all the components were identified in a matter of minutes. Yay!

Then I was not sure of what I wanted to do—I didn’t really want to start a new project although I have a practical idea, and I was also hungry and Oli’s marvelous cooking skills didn’t help to stop making my stomach rumble. Whenever I tried to focus on hardware or research for my idea, a new wave of delicious slow-cooked stew would reach my nose. Ahhh!

Fortunately Charles made a lightning talk describing how he goes from thought to execution using a sketchbook and Autocad instead of thinking by executing as it’s advised in many environments (something like “you don’t want to waste time and effort on build something expensive that might not work, it’s better to think on a sketchbook first”).

Also someone (whose name totally escaped me, ahh, sorry) gave a little intro about a somewhat related event about which I heard about aeons ago but which seemed to have faded out, Dorkbot. It’s been revived, but I’m sad it is held in a) a quite remote location b) at a time I can’t go, because it sounds like the kind of thing I’d like to attend. SAD FACE.

And then it was finally time for lunch. As expected by the opening flavour, it was so yummy! It gave the day a sort of lovely family reunion for Sunday lunch, except we didn’t argue about silly things, but just used the time to catch up on what we had been up to since the last time I visited their maker space, or talk about what we were building today.

After lunch, I spoke to various people such as Andrew Nesbitt of manythings-fame, and learnt new cool things. Such as:

  • Platform.io which is an IDE for “things”, built on Electron… which can work with Arduino and also has code completion! so if you don’t like the Arduino IDE you can use this instead
  • The Arduino board clones such as the Funduino are interesting not only because they might be cheaper than the originals, but also because sometimes they offer cool features such as additional pins for +5 or +GND, which sometimes can make it easier to build something by connecting the wires directly to the board instead of using a breadboard to ‘multiply’ the pins. Or has a toggle to switch between 3.3 and 5V, etc. This very interesting tip came from Jerome, who also told me about this French shop called HackSpark which not only have a lot of those Arduino compatible boards on stock, but also might seem convenient for folks in the UK. And also have a physical shop in Paris! Wow!
  • The Espruino is small. Like… really small! It also transpiles JavaScript to Lua (if I understood this correctly). You write JavaScript instead of Arduino C flavour, and you can get really quick feedback. Sounds like a cool idea for prototyping without having to tether as with Johnny Five—most useful for wearables!

But my super favourite thing I learnt about today is that pencil lead is a conductor! Jerome built a quick and fun pencil based resistor which controlled the speed of a 555 timer connected to a speaker. So effectively he was changing the frequency of an oscillator, and changed the pitch of the sound as he moved the pencil tip closer or further away from the banana connector clipped to the paper. The other end of the pencil had a drawing pin inserted on it and a wire too, effectively closing the circuit! You can see all this in action in this little vine:

We also talked about how I should use an accelerometer and not tilt sensors for my idea (to avoid false positives), and ways to use Web Audio with hardware stuff, and ways to make things that made noise, even how to make a leslie / hammond! So many things that we can make! So exciting!

And there were many other things I learnt but I can’t recall now (hopefully my brain will retain them). Do join one of these NodeBots groups if you can—great things to learn and a very welcoming environment!

It was also cool to devirtualize people I apparently had met already but totally didn’t remember (hi Jerome… sorry), and meet new people! Hopefully next time I will remember 😀

Oh and Jerome, who was one of the main instigators of the NodeBots cat mesmerizer workshop at LXJS 2014, happened to still have a workshop kit in his travelling suitcase and gave it to me… which means I have a laser in my possession!

PEW PEW PEW LASERSSSSS!!!!!!

From very annoying thing to slightly less annoying thing (and serial, and temperature sensors, and…)

You might recall the annoying thing I built with the Duemilanove before I left it in an unusable state. It was essentially the usual blinking example but with a buzzer connected instead of an LED.

But that wasn’t very musical. So I investigated a bit further. First I connected this huge chunky potentiometer to the board and learnt how to read its values. My idea was to change the voltage of what we wrote to the pin, depending on what the potentiometer said. A cheap way to experiment with how would different values sound in the buzzer, without having to recompile each time—interactive inputs are always so much better!

Analog reads give values in a 0..1023 range, and analog writes can only be in the 0..255 range. So to scale it I divided it by 4.


Continue reading From very annoying thing to slightly less annoying thing (and serial, and temperature sensors, and…)

Nodevember 2015: my keynote, and a novel in four chapters

I keynoted at Nodevember 2015, last November in Nashville, Tennessee. There were some technical issues with the audio and video not being very much in sync I think, and that’s why the video has taken some time to be published. Thanks to the organisers for recording it! It has been made available just today :-)

What you might not know is that I almost didn’t make it to the conference. And I also had written a sort of novel detailing what happened before, during, and a bit of after. So, without further ado, here it goes:

Continue reading Nodevember 2015: my keynote, and a novel in four chapters

tween.js mega changes

Yesterday I had my every-two-months lucky day in which I could sit down and work on tween.js, and DID I GET THINGS DONE!!!

The first thing I did was to get rid of the minified version. Since the build process wasn’t fully automated, I often forgot to produce and check-in that minified version, and people who used it would get all sorts of weird errors that I didn’t see (specially in Safari and iOS, as the polyfills we added would be in the uncompressed version, but not on the minified, sigh!).

Then I started using semantic-release as my invaluable helper for producing releases. Each time a push to the git repository happens, another service (Travis) runs a battery of tests to make sure nothing is broken. If the tests pass, semantic-release will get in action and (probably not in this order):

  • determine what’s the next “semver” for the package. This is a function of the type of commit you made (a bug fix, a new feature, docs, chore…). Important / breaking commits will cause bumps in the first digit, etc. (I suggest you read more on semver if you’re interested). The type of commit is specified by having the commit message follow a certain syntax. E.g. a feature will be feat: implement feature A
  • tag the commit with the version. E.g. v16.0.1. I believe this is what bower people use and desperately need, and I never provided because I don’t use bower and so didn’t notice.
  • create a github release changelog thingie in github. These go to the releases page in github
  • publish the new version of the package to npm

I think semantic-release can do so much more than this, but just having all these steps performed for me is A W E S O M E. So once I established this “infrastructure” I could go on and fix many other long-standing issues and also merge PRs and address questions.

Since we don’t have to produce a minified version, I got rid of gulp which is what I was using it for. Installing tween.js with npm is now very very lean because I also added an .npmignore and so it just essentially installs the code of the library only. Your trees will not include the examples anymore. Not that it was incredibly big but every byte counts to some people, it seems 😛

I also added jshint (for code correctness) and jscs (for code style) verification as part of the test suite. This was something that would put me off reviewing PRs… and specially explaining to people that it was not OK to change the whole whitespace in the file, or that they should respect the existing guidelines (even if it’s in the contributing file that very few read). So the rules are now there, and everyone has to abide to them, or the tests don’t pass and so the PRs are not accepted.

Interestingly, I added these steps using the advice in Kate Hudson’s talk from Nordic.js front-end automation with npm scripts, where she showed how you don’t actually need a task runner–I recommend you to watch it! Or check out her reading list on the topic.

Next up was dealing with a ton of sorta old and sometimes outdated PRs that had been lying in the guts of github for months. As I explained in my previous tween.js post, something had happened and I hadn’t even seen the notifications for these.

I prioritised FIXES first. Many people are coming up with some novel ideas and features, and I’m grateful for that, but I decided to focus on accuracy and robustness for now. Some aspects of the code are a bit obscure and I am not sure I understand them well, mostly because I just merged them in when someone proposed them, and now I’m paying the price when strange edge case errors are reported.

Of course, I’m still not done by any means, because there was a massive backlog and the day only has so many hours, and I’d like to do human things such as sleeping, etc.

This is brings us to this interesting paradox: many people use tween.js, including big agencies who charge a bunch for their projects, but only a very few submit code or respond to my pleas for help. Maintaining a JS library has become way more demanding over the years. Back in 2011 people didn’t care about npm, bower, tags and releases and what not, so working on tween.js was way more simple and less time consuming. I could have just put a zip file on a website, and people would be happy with that, for all that is worth.

But since I changed roles at Mozilla I am travelling a lot more, and it literally devours your time. I am not complaining about that, but I need quiet time to sit and get heads down on code, and I’m not having much of that lately. Mozilla supports me working on tween.js but I do have my own work duties which take priority. All my coding time is happening during working hours, and when I’m off work I like to enjoy my free time doing things such as being outdoors or just talking to people face to face, not via a bug tracker. Or despair about the list of issues and PRs growing and me not having time to even acknowledge them 😩

But before totally blaming open source for its toxicness, I decided to own this a little bit myself, and totally revamped the README file to make it a bit more welcoming and clear (I took heavy inspiration from Express). I have also filed some bugs and tagged them as help needed or good first bug respectively. If you enjoyed tween.js and want to give back by contributing to these bugs, you’d gain extra points of awesomeness.

People like roadmaps, so this is what I’d like to see next:

  • Review all pending bugs and PRs and resolve or close them.
  • Fix the things that have to be fixed and ensure all code is tested and clear before adding new features, because it is getting to a point where it is unwieldy and scary to even look at a diff (what even does this thing do!?). Hopefully the new automation will help here, and we can focus on logic and not on chores!
  • Divert all new feature ideas to the future ES6/ES2015/ESWHATEVER version of tween where everything will be super modular and you should be able to use parts of it as you need and hack other types of tweening engines as you see fit.

This is it for now. Thanks for reading, and happy tweening!

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.