A responsive html template for drawing on a canvas

I recently built a handwriting recognition system that works in the browser. As you might imagine, the main component of the page, beside the machine learning model in the background, is the ability to draw a character in the browser.

In order to do that, you need to use the <canvas> element in html. Long story short, I created a template that you can freely use and adapt to your needs.

Some tricks and hacks with Sphinx

This is a (hopefully!) growing collection of tricks and hacks that I have come across working with RST documents, Sphinx and Read the Docs.

Vim and RST

I love Vim (actually, MacVim), and as soon as I started working with RST documents for the first time, I hoped to find a nice plug-in to speed up my editing.

Riv is a great plug-in, with many shortcuts to make your life easier when dealing with RST files. In my opinion, the best thing about Riv is how it handles table creation. You create cells by simply pressing tab, and when you modify the content, the table automatically reshapes when you exit the edit mode.

A few shortcuts for you:

• tab: move to the next cell
• option + enter: create the header row
• control + enter: create a new regular row

Create tables with Riv.

How to translate a document or review a translation with OmegaT

You want to translate a document or you're given someone else's translation to review. You also want to do it like a pro, i.e., using a professional CAT tool.

Then, you're best option is probably OmegaT. OmegaT is a translation memory application that has, in my opinion, two main advantages over its competitors:

1. It's free and open-source,
2. It runs on Windows, Mac and Linux (actually, any system where the Java Runtime Environment can be installed).

I found myself in this situation recently, so I'll give you a brief account based on my experience on how to import, translate and review translations for plain text files.

Finite difference simulation of a simple harmonic oscillator in Python

When I first started learning Python a couple of years ago, I was looking for a simple case to test my newly acquired skills. The simulation of a simple harmonic oscillator using finite difference methods was the simplest problem I can think of with a bit of complexity, a sort of "Hello World!" on steroids.

I have already discussed about the harmonic oscillator and the anatomy of a finite difference code in a previous post. (You haven't read it? Go ahead, I'll wait... done?) Here, I will simply give my rendition of the algorithm (specifically using Python 3).

Sound synthesis of multiple degree-of-freedom systems in Matlab: Modal and finite different approach

This post is adapted from a lecture I gave on multiple degree-of-freedom systems (arrays of masses and springs) and their connection with ideal strings. Part 1 is presented in a previous post, and deals with the nitty-gritty of the theory.

Here, the emphasis is given to sound synthesis applications of the mass-spring system. I will explore two simple examples of physical modelling sound synthesis, namely the modal and finite difference methods, and present two basic codes that produce sounds in this way.

Multiple degree-of-freedom systems and ideal strings

This post is adapted from a lecture I gave on multiple degree-of-freedom systems (arrays of masses and springs) and their connection with ideal strings. Here's a brief outline:

Outline¶

Multiple degree-of-freedom systems¶

• Equations of motion
• Simple example
• Normal modes and frequencies

Energy conservation in a finite difference simulation of a simple harmonic oscillator

One key concept in physics is the conservation of energy---in an isolated system, the total energy cannot increase or decrease, it simply remains constant. Thus, the simple lossless harmonic oscillator model defined by the equation

$$M\frac{d^2 u}{dt^2} = -K u$$

has an associated energy $H$ defined as

$$H(t) = \frac{M}{2} \left( \frac{du}{dt} \right)^2 + \frac{K}{2} u^2, \qquad \frac{d}{dt} H =0,$$

which is conserved.

Such a concept can also be applied in a numerical simulation, where the existence of a numerical energy-like quantity with certain properties can become a powerful tool in guaranteeing the stability of the scheme.

Anatomy of a finite difference scheme: How to simulate a simple harmonic oscillator with Julia

In this post, I will try to analyse a finite difference simulation of a simple harmonic oscillator (SHO) with damping, and code the algorithm using the programming language Julia. If you are not familiar with Julia, I recommend you visit this website: http://www.julialang.org.

As you probably know, the equation for an SHO is the following:

$$\frac{d^2 u}{dt^2} = -\omega_0^2 u - 2\sigma \frac{du}{dt}$$

where $u$ is the position of the oscillator around the equilibrium point, and $\omega_0$ and $\sigma$ are two positive parameters. This second order differential equation requires two initial conditions to be fully specified, the initial position and velocity of the SHO, i.e.:

$$u(0) = u_0, \qquad \text{ and } \qquad \frac{du}{dt}\Bigr|_{t=0} = v_0.$$

A finite difference implementation of this equation requires the discretisation of time in integer multiples of $k$, the time step. Let $u^n$ denote the discrete approximation to $u(t)$ calculated at the discrete time $nk$, with $n$ positive integer. Given the initial values $u^0$ and $u^1$, the idea is to find a recursion that gives $u^2, \dots, u^n$ in a way that is consistent with the continuous equation. Many different schemes are available, which present different properties. One possibility is the following: