Category Archives: Coding

Mathematica for Physicists

I’ve just finished writing a lecture course for SEPnet, a consortium of leading research universities in the South East of Britain. The course comprises a series of webcasts introducing Mathematica – check it out here!

Although the course starts from the basics, I hope it’ll be useful to researchers at all levels of academia. Rather than focussing on computations, I relay the philosophy of Mathematica. This uncovers some tips, tricks and style maxims which even experienced users might not have encountered.

I ought to particularly thank the Mathematica Summer School for inspiring this project, and demonstrating that Mathematica is so much more than just another programming language. If you’re a theorist who uses computer algebra on a daily basis, I thoroughly recommend you come along to the next edition of the school in September.

Advertisements

Javascript Namespaces in Meteor

I’ve just been watching this excellent EventedMind presentation to get my head around routing for Meteor. I’ve realized that a better way to manage my code (particularly for subscriptions) is to harness the power of javascript namespaces. For example

Subscriptions = {
posts: Meteor.subscribe('posts')
};

Just keeps everything much cleaner, and prevents quite likely name conflicts. I think I’ll be using this from now on in the ongoing Fixer’s Dream development!

Meteor App Liveblog (Entry 6)

Ba-da-boom! And that’s my time up. I think I’m going to give myself a little bonus time later this evening, so watch out for a final round-up then.

Where do we stand? I’ve integrated the bootstrap popover and remove functionalities, which was pleasingly simple. Next up is the accounts feature. I’ve hit one of the hazards of working with a beta technology, namely that some packages mysteriously don’t work. A workaround is to temporarily downgrade using meteor update --release.

To summarize: there’s a bit of a learning curve with Meteor at the start, particularly if you aren’t familiar with Mongo and Handlebars. But once you’ve entered into the right spirit, it’s really good fun! I’ll see over the coming days how it stands up to more complex tasks. I still reckon MEAN is the way to go for massive scalability. But Meteor is great for smaller projects, and I daresay more enjoyable!

Meteor App Liveblog (Entry 5)

So we’re into the last few hours and sadly haven’t quite got as far as I hoped. But… we have got a very simple prototype up, allowing you to add people to the database. The next couple of hours will probably involve

  • providing full info in popovers
  • including a delete functionality
  • implementing a login (and proper security)
  • adding the “concerts” page

What have I learnt in the last few hours? Here are the highlights

  • Stylus is awesome. Use it.
  • Don’t try to use form tags. It’s not worth the trouble.
  • You can (and should) split up your client, server and public files into so-named directories. See the parties example. Goodness knows why this isn’t the default directory structure!
  • The hr tag is useful for splitting up sections

Hope some of that’s useful! If you want to check out the prototype as it develops, bookmark http://fixersdream.meteor.com/.

Meteor App Liveblog (Entry 4)

Oh dear! We really aren’t going very fast. I blame the need to get familiar with MongoDB. I’ve taken a bit of time to find a decent GUI to visualize what’s going on. Okay – I know this isn’t strictly necessary. But for a first time Meteor user like me it’s quite nice. Here’s my recommendations

  • Grab a copy of GenghisApp. It seems to start natively at IP address 0.0.0.0:5678.
  • Add the mongo database. You can find the correct URI by typing meteor mongo in your app directory
  • Tada! You’ll now be able to navigate around (and add/change) your collections.

Time to get some logic going, and basic Bootstrap styling. Once that’s in place I’ll put the current progress onto the .meteor.com servers so you can follow along.

Meteor App Liveblog (Entry 2)

So I’ve got meteor installed and the app created. But it wasn’t quite as plain sailing as the docs make it seem. Here’s some tips

  • you might need to add/usr/local/bin to your $PATH if it isn’t there already
  • the simplest way of shoehorning in Coffeescript seems to be adding the package with meteor add then changing the js file to a .coffee one and altering the syntax.
  • It annoys me that meteor doesn’t timestamp things in bash. So use this instead
    meteor | gawk '{ print strftime("%H:%M:%S"), $0; fflush(); }'

Also Bootstrap is installed nicely. Though it seems I might need a custom package for more control over which JS files get included. I’ll probably get to play around with the unofficial Meteorite package manager later.

So. On with the coding!

Meteor App Liveblog (Entry 1)

Today I’ve got something a little different. I’ll be creating a Meteor app in 12 hours. The aim is to produce an “Orchestral Fixer’s Dream”. What’s that exactly? Well it comprises

  • a database of musicians
  • functionality for adding/changing musicians
  • a database of concerts
  • functionality for adding/changing concerts
  • mailing feature to automatically email appropriate musicians

I’m planning to use Twitter Bootstrap to ensure mobile device compatibility, and possibly some Angular if that’s necessary. For flexibility, I could have chosen the MEAN stack with Breeze instead of Meteor. But I reckon the config would have made my timescale impossible!

Wish me luck if you are following along!