tag:blogger.com,1999:blog-26175449954341030732023-11-16T08:06:31.355+01:00Robertomontagna.itRobertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-2617544995434103073.post-8761931633516395282016-05-23T14:00:00.000+02:002016-05-23T14:00:21.632+02:00Matlab memory management<p>A couple of quick tips if you run out of memory in Matlab. All of these commands will have an almost insignificant impact on your actual work, but they might be useful in some occasions when Matlab gets cranky. It has happened to me before that Matlab runs out of "heap memory" when opening and closing figures. Then all you want to do is to save your work, exit and relaunch Matlab, but Matlab might complain that it doesn't have enough memory for that. So I'm listing a couple of commands that might just about allow you to save and exit without losing the content of your workspace.
<ul>
<li><code>pack</code> This command calls Matlab's garbage collector. It only works from the command line, and if you call it inside a procedure it will return an error. You shouldn't need to use it, as Matlab calls its garbage collector automatically, but it might still be helpful if you're using some other software along with Matlab and you're running low on memory.</li>
<li><code>java.lang.Runtime.getRuntime.gc</code> This command calls Java's garbage collector. Matlab's UI is largely written in Java, and when you open a lot of figures you sometimes incur in out of Java memory errors. This command has been helpful in some occasions as it's given me some leeway to save my work and restart Matlab.</li>
<li><code>java.lang.Runtime.getRuntime.freeMemory</code> This command doesn't really free any memory, but it will show you the amount of memory available for the Java runtime environment. Using this you'll clearly see the effect of the previous <code>gc</code> command.</li>
</ul>
Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-59955578141390553462016-02-08T13:00:00.000+01:002016-02-08T13:00:01.735+01:00Odd behaviour of imresize in Matlab<p>I stumbled across what I would classify as a bug in Matlab's <code>imresize</code>. Try out the following snipped of code:</p>
<pre>
little1 = imresize(IM, 0.2, 'nearest');
[M, N] = size(little1(:,:,1))
little2 = imresize(IM, [M, N], 'nearest');
</pre>
<p>I would expect <code>little1</code> to be exactly the same as <code>little2</code>. If I wrote a routine to rescale images, I'd probably take as input the final dimensions <code>[M,N]</code>, and if I had to handle a single scaling factor I'd use that to calculate the final width and height for the previous case.</p>
<p>It is not so in Matlab. I don't know exactly what's going on there, I don't have the time to debug <code>imresize</code> and see what happens. But if you try the snipped of code above for any image <code>IM</code>, you'll find that <code>norm(little1(:)-little2(:))</code> is not 0, and in fact you can also <code>imshow</code> the absolute value of the difference and see where the resizing differs. Indeed, the picture below is exactly that.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoI2eX_4dJxJ-1zsoEfaPoO_X36mXMc44LPV0K3rU3mKNZT99BsEw3Ne2xg8qNlQPLwZakAK72AUnw-zj6cLGgO3V7LzgTXLQ9sXeBNv2Tzi6EcD4V401kBwp0CneuS-RgLjAYUk1Thio/s1600/imres.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoI2eX_4dJxJ-1zsoEfaPoO_X36mXMc44LPV0K3rU3mKNZT99BsEw3Ne2xg8qNlQPLwZakAK72AUnw-zj6cLGgO3V7LzgTXLQ9sXeBNv2Tzi6EcD4V401kBwp0CneuS-RgLjAYUk1Thio/s1600/imres.png" /></a></div>
<p>This little quirk costed me probably about two days worth of work! I hope I've saved you some headaches by sharing this.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-43606505137640994532015-08-07T12:00:00.000+02:002015-08-07T12:00:02.878+02:00Matlab's repmat in Python<p>This post is partly to remind myself of this, partly for others who might find themselves in a similar situation. I find myself wanting to use a <code>repmat</code> function in Python - used as I am to Matlab's syntax. A quick search will tell you that the function to use is <code><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.tile.html" target="_blank">numpy.tile</a></code>, and that's indeed true.</p>
<p>But, say that you have an image of shape (1024,512) and you'd like it to become (1024,512,3). What's the way to go? In Matlab you would just say</p>
<pre>
B = repmat(A,[1,1,3]);
</pre>
<p>and if you try that with <code>np.tile</code> you'll find that <code>B</code> has shape (1,1024,1536). Somehow, it's added a new dimension at the beginning, not at the end!</p>
<p>To obtain the same behaviour as Matlab, you have to do</p>
<pre>
B = np.tile(A.reshape(1024,512,1), (1,1,3))
</pre>
<p>In practice you're explicitly adding a dimension to the array <code>A</code> before tiling it.</p>
<p>Having said that, numpy does something that Matlab doesn't: it <b>broadcasts</b> operators. So if you have two arrays of different dimensions, numpy can automatically repeat the same operation (a bit like Matlab's <code>bsxfun</code>). The catch is that the operation is repeated over the first dimension of the array. So let's say we want to add <code>A</code> of shape (1024,512) and <code>B</code> of shape (1024,512,3). The way I'd go about doing that is with transposes:</p>
<pre>
C = A.T + B.T
C = C.T
</pre>
<p>Transposition in numpy is more generic than in Matlab and can be applied to n-dimensional arrays. It changes the dimensions so that that an array of size <code>w,x,y,z</code> its transpose will have size <code>z,y,x,w</code>. So that's now adding matrices of shapes (512,1024) and (3,512,1024), which works because the broadcasting happens along the first dimension. Then, of course, the result needs to be transposed back.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com1tag:blogger.com,1999:blog-2617544995434103073.post-80155096382458691792015-07-29T12:00:00.000+02:002015-07-29T12:00:05.326+02:00Compiling OpenCV on Yosemite<p>I found myself wanting to use some OpenCV features from Python. But I prefer to use Python 3, which made the Homebrew distribution of OpenCV almost useless - as the version coming with Homebrew doesn't support it. The only option was then compiling OpenCV 3.0.0. Here's how I went about doing it.</p>
<p>For the following, I'm assuming you're using Python 3.4.3 coming with Homebrew. Note that future updates might break the compilation, so proceed with care. Also, the OpenCV distribution that comes with Homebrew mustn't be installed or you'll have problem linking this one later.</p>
<p>The first step is downloading OpenCV 3.0.0 - using git works just as well as downloading the zip file.</p>
<p><pre>git https://github.com/Itseez/opencv.git
cd opencv
mkdir release
cd release</pre></p>
<p>Now I'm assuming you'd like to keep your installation tidy, and the best way is to let Homebrew handle this. The next command will let you configure the compilation, and to do so you will have to set some variables. The command to launch is</p>
<p><pre>ccmake ..</pre><p>
<p>You need to fill in the following variables:</p>
<table border="1" style="table-layout:fixed; word-wrap: break-word; width=100px; font-family:monospace;">
<tr><td>CMAKE_INSTALL_PREFIX</td><td>/usr/local/Cellar/opencv/3.0.0</td></tr>
<tr><td>PYTHON2_EXECUTABLE</td><td>/usr/local/bin/python3.4</td></tr>
<tr><td>PYTHON3_EXECUTABLE</td><td>/usr/local/bin/python3.4</td></tr>
<tr><td>PYTHON3_INCLUDE_DIR</td><td>/usr/local/Frameworks/
Python.framework/Versions/3.4/
include/python3.4m</td></tr>
<tr><td>PYTHON3_LIBRARY</td><td>/usr/local/Frameworks/
Python.framework/Versions/3.4/
lib/libpython3.4.dylib</td></tr>
<tr><td>PYTHON3_NUMPY_INCLUDE_DIRS</td><td>/usr/local/lib/python3.4/site-packages/numpy/core/include</td></tr>
<tr><td>PYTHON3_PACKAGES_PATH</td><td>/usr/local/lib/python3.4/site-packages</td></tr>
</table>
<p>Now, <code>CMAKE_INSTALL_PREFIX</code> is what will later allow Homebrew to handle your installation of OpenCv. Also, you might notice that <code>PYTHON2_EXECUTABLE</code> is actually set to Python 3. For reasons beyond me, without that it doesn't look the Python bindings are compiled correctly so, well, whatever works.</p>
<p>At this point, you can check that <code>cmake</code> is happy with what you've done with Python. To do so, first of all, save your configuration by pressing <C> from the keyboard, and then <Q>. Then, just type</p>
<pre>cmake ..</pre>
<p>and you should see the following:</p>
<pre>
-- Python 2:
-- Interpreter: /usr/local/bin/python3.4 (ver 3.4.3)
--
-- Python 3:
-- Interpreter: /usr/local/bin/python3 (ver 3.4.3)
-- Libraries: /usr/local/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib (ver 3.4.3)
-- numpy: /usr/local/lib/python3.4/site-packages/numpy/core/include (ver 1.9.2)
-- packages path: /usr/local/lib/python3.4/site-packages
--
-- Python (for build): /usr/local/bin/python3.4
</pre>
<p>This way you should be confident that the compilation process will generate all your Python bindings. And now we go with the usual<p>
<pre>
make
make install
</pre>
<p>and of course, to make sure that Homebrew will take care of your installation,</p>
<pre>brew link opencv</pre>
<p>If you want to make sure that the Python binding has been compiled, you should find the file <code>lib/python3/cv2.so</code> inside your <code>release</code> directory.</p>
<p>And finally, one little catch. Keep in mind that this <code>cv2.so</code> will end up inside your python site-packages, i.e., outside the reach of Homebrew. An alternative might be to set <code>PYTHON3_PACKAGES_PATH</code> somewhere inside the Cellar, and then add it to your <code>PYTHONPATH</code> variable, but I don't know if that will work or not.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-26780607039663165822014-02-07T10:00:00.000+01:002014-02-07T10:00:09.529+01:00A rather impressive demo<p>I'm not sure what would push anyone to do this, but hats off. <a href="http://www.mathworks.com/matlabcentral/fileexchange/40961-super-mario-bros-demo" target="_blank">Here's a Super Mario Bros demo that runs in Matlab</a>. I haven't really had the time to skim through the code, but I'm impressed with the effort it must have taken to get this to work at 60 fps.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com1tag:blogger.com,1999:blog-2617544995434103073.post-28451435314855925332013-09-03T10:30:00.000+02:002013-09-05T18:08:57.721+02:00Undocumented Matlab<p>I'm not writing here nearly as often as I'd like, but as the theme of the latest few posts has been Matlab I thought it would be appropriate to continue in the same fashion.</p>
<p>I came across a <a href="http://undocumentedmatlab.com/" target="_blank">very interesting blog about undocumented Matlab functions</a>. It has all sort of tips and tricks: for example, did you know you can have Matlab to run using a more recent JVM? No? Me neither. (But there are very few reasons why anyone would want to do it.) Or, did you know you can force Matlab to use a new (still beta) version of the handle graphics (i.e., the component that draws the plots)? No? I had no idea either. This could be useful as the new graphics look a lot better than the usual ones.</p>
<p>Well, I've given you the source of all that, so dive in and enjoy...</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-18895617267640971802013-01-29T10:00:00.000+01:002013-01-29T10:00:14.721+01:00Functional programming in Matlab<p>I came across a very interesting blog post recently. I'll just link it here so you can read it at the source. But to give you a cliffhanger, how would you write a <code>min_and_max</code> function in Matlab, that does this:</p>
<pre>
[extrema, indices] = min_and_max(y);
</pre>
<p>You could write an m-file but the alternative is the following mind-blowing and very clever one-liner:</p>
<pre>
min_and_max = @(x) cellfun(@(f) f(x), {@min, @max});
</pre>
<p>I love it. <a href="http://blogs.mathworks.com/loren/2013/01/10/introduction-to-functional-programming-with-anonymous-functions-part-1/" target="_blank">Check out the original blog post on <i>Loren on the Art of Matlab</i></a> for an explanation on how it works.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-66277880646492148272013-01-24T10:00:00.000+01:002013-01-24T10:00:09.924+01:00Homebrew<p>I haven't used Linux for a long time now. I remember with mixed feelings compiling programs: partially, the satisfaction of having a piece of software exactly tuned for your machine, and partially the pain of stashing up files somewhere in the system without being exactly aware of how to get rid of them later on.</p>
<p>Fast forward 10 years (did I say 10? Great Scott!), I'm sitting here at my shiny MacBook Pro and thinking "Heck, I'd really need <a href="http://pfstools.sourceforge.net/" target="_blank">this</a> or <a href="http://www.cybercom.net/~dcoffin/dcraw/" target="_blank">that</a> program/library/whatnot".</p>
<p>Now, would I be happy to pile up files randomly in OS X? Not exactly. Would I be happy to create a <code>~/local</code> folder where to save the binaries? Good luck with that if you need to link to a library. Here's where tools like <a href="http://www.finkproject.org/" target="_blank">fink</a> or <a href="http://www.macports.org/" target="_blank">MacPorts</a> come in handy. However, for a reason or another, neither of those never quite hit the spot for me.</p>
<p>The one that did hit the spot was <a href="http://mxcl.github.com/homebrew/" target="_blank">Homebrew</a>. I'm not exactly sure why. Probably because it's quite easy to use (not that the others aren't) but allows you to customize quite a lot of your installation (<code>brew install --interactive package</code>). Also, it's very easy to compile a package that isn't included in the distribution, but registering it within Homebrew so that it's easy to remove or update later on. Once you do that, you can also contribute to Homebrew itself if you're so inclined, that way you'll save others from going through the same pain you've suffered (I haven't gone that far yet, possibly because what I compiled so far required a few tricks that would take me too much work to recreate in an automated script).</p>
<p>So, here are a couple of tricks I learnt that weren't obvious from the documentation. Say you want to compile some package that comes with Homebrew, but for some reason you <i>desperately</i> want it to be tuned for your CPU, or you want to compile it with/without a certain feature which Homebrew doesn't/does include by default. The way to go is:</p>
<pre>
brew install --interactive package
</pre>
<p>At this point you're on your own to go through the usual <code>configure; make; make install</code> routine. Something that helps you in this is <code>brew diy</code>, which can be used to tell <code>configure</code> where to send your compiled binaries (it sets the <code>--prefix</code> option to <code>configure</code>). The command would be something like this:</p>
<pre>
./configure $(brew diy)
</pre>
<p>although of course you have to add your own options to that.</p>
<p>The other very useful trick is compiling packages that aren't included in Homebrew, registering them in Homebrew so that you can easily delete them later on. Say you want to install painfulcompilation 1.0. You decompressed the .tar.gz and now your terminal is on the folder <code>painfulcompilation-1.0</code>. This is what you need to do:</p>
<pre>
./configure $(brew diy)
make
make install
brew link painfulcompilation
</pre>
<p>and magically, painfulcompilation is installed in what is know as the <i>Cellar</i>, and all the binaries are linked to <code>/usr/local/</code>. How cool is that?</p>
<p>Naturally not everything is perfect. Something quite crucial is to make sure that your user has permissions to write in <code>/usr/local</code> otherwise you're going to have a bad time (although fortunately this type of error is quite easy to track down).</p>
<p>The good thing in all this is that it allows for all the dirtiest tricks that get something compiled. For example, I was trying to install the <a href="http://pfstools.sourceforge.net/" target="_blank">pfstools</a> on my laptop (they're a set of tools to operate on HDR images, if you're interested). Funny thing, clang would compile most of them but then would fail in one of the tone mapping operators (Fattal's if you're interested) because it doesn't support OpenMP. On the other hand, llvm-gcc supports OpenMP but would give an error on another tone mapping operator. So I used two compilers to compile the whole package, by calling <code>./configure</code> a second time after I got the first error. So <b>that</b> is the kind of stuff that you can get away with using homebrew.</p>
Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-22598919880836688492012-12-18T10:00:00.000+01:002013-09-05T18:17:57.353+02:00Have you seen the pictures from Mars?<p>No? Ah, that's a shame. Here you go. First link, <a href="http://photojournal.jpl.nasa.gov/targetFamily/Mars?subselect=Instrument%3AMastcam%3A" target="_blank">NASA photojournal</a>. The photos there have already been processed and stitched, and I find the panoramas astonishing. It's just unbelievable that those pictures come from another world.</p>
<p>Second link, <a href="http://mars.jpl.nasa.gov/msl/multimedia/raw/" target="_blank">raw images</a>. You probably want to select pictures from Mastcam or MAHLI if you want to see anything of interest. In the Mastcam photos you'll find also a few images taken in the near-infrared spectrum, if you're into multispectral imaging at all (<a href="http://msl-scicorner.jpl.nasa.gov/Instruments/Mastcam/" target="_blank">here is a detailed description of the Mastcam</a>, including the spectral sensitivity of the sensor and the spectral transmission of each filter).</p>
<p>For me, the drawback of the raw images is that for most of them only the visible-light high resolution version is available, while there's only a tiny thumbnail for the near-infrared. The reason for this is bandwidth. Yes, it doesn't take a lot of bandwidth to download a photo. But Curiosity is on Mars, and the interplanetary bandwidth is <i>very</i> limited. On top of this, the same antenna that communicates with Curiosity is used for all the other probes as well (or at least some of them, I'm not sure now and can't be bothered to google it). So, limited bandwidth and limited time slot too. The result is that at NASA engineers download only thumbnails of images, and then download the higher resolution version of those they deem worth the effort.</p>
<p>It's a shame, because I'd be very interested in putting my hands on some misty image of the horizon, where the near-infrared version is crisp and clear...</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-79159200032333251262012-12-03T10:00:00.000+01:002012-12-03T10:00:15.774+01:00More about exponents<p>
<a href="http://www.robertomontagna.it/2012/11/operator-vs-logs-in-matlab.html" target="_blank">My previous post</a> raised some interest (i.e., one person asked me about it), so I decided to follow up a little bit on that. In a nutshell, I suggested to use logarithms and exponents to raise large matrices to some non-integer power because it's faster. That is, <code>exp(log(A)*x)</code> is faster than <code>A.^x</code>, subject to the constraint that <code>A>0</code> everywhere. Referring to this, I can confirm that it works on Octave as well as in Matlab. I wouldn't know about other programming languages though, if you feel like trying and letting me know in the comments, I'll create a new post about it.
</p>
<p>
To that, I wanted to add something else. If we want to raise a large matrix to some integer power, it's worth using the <a href="http://en.wikipedia.org/wiki/Exponentiation_by_squaring" target="_blank">exponentiation by squaring</a>. The following Matlab code is significantly faster than the <code>.^</code> operator already when the exponent is 4.
</p>
<pre>
<span class="keyword">function</span> y = pow(x,p)
y = ones(size(x));
<span class="keyword">while</span> (p > 0)
<span class="keyword">if</span> (mod(p,2) == 1)
y = y.*x;
<span class="keyword">end</span>
p = floor(p/2);
x = x.*x;
<span class="keyword">end</span>
</pre>
<p>
Interestingly, this does <b>not</b> work for Octave, which probably implements a similar algorithm when it realises that the exponent is an integer. So, if you use Octave keep going with your <code>.^</code> operator.</p>
<p>
In Matlab the code doesn't look great, probably because most of its commands are native for double precision floating-point arithmetic, while here we're dividing the exponent which is an integer. Somehow, the same function written in C looks a little bit more neat.</p>
<pre>
<span class="keyword">float</span> powN(<span class="keyword">float</span> x, <span class="keyword">unsigned int</span> p) {
<span class="keyword">float</span> y = 1.0;
<span class="keyword">while</span> (p > 0) {
<span class="keyword">if</span> (p & 1)
y *= x;
x *= x;
p >>= 1;
}
<span class="keyword">return</span> y;
}
</pre>
<p>Here we can use directly bitwise operators in the condition and in place of the division by 2. That said, this is a very low-level operation which is likely to be implemented more efficiently in whichever API you're using (except for Matlab, it seems). So I'd recommend you to double-check first, because it might very well be that you can use a vectorised version that outperforms this one.</p>
Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-10915024786332076322012-11-28T10:00:00.000+01:002016-07-14T11:06:02.832+02:00.^ operator vs. logs in Matlab<p>Quick comparison test. Say you have a large matrix <code>A</code>, what's faster, <code>A.^2.4</code> or <code>exp(log(A)*2.4)</code>?</p>
<p>Obviously, the fact that I'm asking should kind of give away the answer and the latter is faster. There's however a catch in all this, so it really depends on what you're doing, because you can't take <code>log(0)</code>. But, for what I want to do this isn't a problem.</p>
<p>Let's say that our big matrix is actually an image in sRGB colour space, and I want to convert it to linear RGB, that is, I want to remove the gamma correction. From the <a href="http://en.wikipedia.org/wiki/SRGB" target="_blank">Wikipedia page</a> I find the formula, and the straightforward implementation is:</p>
<pre>
linear = srgb;
small = linear < 0.04045;
linear(small) = srgb(small) / 12.92;
linear(~small) = ((srgb(~small) + 0.055)/1.055) .^ 2.4;
</pre>
<p>But if the image is big (or your computer is slow) we can save seconds using logs.</p>
<pre>
small = srgb < 0.04045;
linear = exp(log((max(srgb,1e-3)+0.055)/1.055) * 2.4);
linear(small) = srgb(small) / 12.92;
</pre>
<p>This code, if in a function, is about three times as fast as the previous.</p>
<p>In this case, clipping the image to 0.001 works perfectly fine whether you use 8 or 16 bit precision images, because all those small values are only transformed linearly by this gamma function. Obviously, if you're not doing image processing this may not be good enough for you and you might have to stick to the <code>.^</code> operator.</p>
<p>Anyhow, this works also for applying the gamma to a linear RGB image. The code is the following:</p>
<pre>
small = linear < 0.0031308;
srgb = exp(log(1.055) + log(max(linear,1e-3)) / 2.4) - 0.055;
srgb(small) = linear(small) * 12.92;
</pre>
Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-32393205340677286032012-11-26T10:30:00.000+01:002012-11-26T12:29:36.601+01:00City of Norwich Half Marathon, the aftermath<p>I made it. I ran my first half marathon, 21 km (or 13 miles). I ran it all, with a very steady pace, just over 5'30" per km on average. Just under two hours (1:58'23") from start to finish, of which I'm very happy given my poor training. The arrival time was a couple of minutes longer because I started pretty far behind.</p>
<p>My legs ache though. They're better now, but yesterday shortly after the race I was limping around like an 80-year-old man (in fact I've seen 80-year-old men in a better shape than that!).</p>
<p>What's next? Who knows. I think I'll keep running, I'm not sure when I'm going to race next time. I'm really tempted to give the City of Norwich Half Marathon another go next year though!</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-17164916087235841612012-11-24T19:00:00.000+01:002012-11-24T19:00:02.487+01:00City of Norwich Half Marathon<p>Tomorrow I'm running the <a href="http://www.cityofnorwichhalfmarathon.com/" target="_blank">City of Norwich Half Marathon</a>. I had the idea just over three months ago, and I read that three months are enough to prepare for a half marathon. They would be, if you're able to maintain a good training regime.</p>
<p>If, like in my case, you can't, three months become a very short amount of time. Unfortunately, I had two pretty long breaks from running over this time.</p>
<p>The first was when I bought some running shoes that weren't appropriate for me and my legs ended up aching so much that I wasn't even able to run. Two weeks down the drain there.</p>
<p>The second is that my left shin started to hurt and I was afraid I had <a href="http://en.wikipedia.org/wiki/Shin_splints" target="_blank">shin splints</a> (and no, I didn't learn about them through Wikipedia). I stopped running again, until I finally went to a physio who assured me that I didn't have shin splints. Still, three weeks down the drain there, and unfortunately they were the last before the actual race.
</p>
<p>Anyhow, the time has come, three months flew by and after a 5 mile run on Wednesday I'm just glad that I still have a few hours to rest before the race. It's going to be very, very tough for me.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-71001661421620428672012-11-23T11:59:00.000+01:002012-11-23T11:59:21.510+01:00New website<p>
Welcome to my new website! It's about time. I hadn't updated my old one for ages. I was managing the CMS myself, which is some extra faff that I really didn't need. I'm now on blogger, which does all I need and is simple to maintain. At this point, I'll probably switch my hosting plan to a domain-only plan.
</p>
<p>
Some people might know that I also had a blog on <a href="http://www.tumblr.com" target="_blank">tumblr</a>. This new website, hopefully, will be the union of both my previous personal website and my old blog, but without all the "noise" of tumblr. Now I'd like to close that blog but I can't without deleting my tumblr account all together (which I might do, eventually), but to give a sense of continuity I reposted here its last entry, which you should see below this one.
</p>
<p>
So ultimately, the purpose of this website is to have somewhere to host my CV and provide a way for people to contact me; but I'd also like to use it as blog. Knowing myself I'm genuinely not sure how often I'll be able to update it. But hey, still worth a try. What will I talk about? I'd say anything that crosses my mind. Work-related things, hobby-related things... I guess I'll play it by the ear!
</p>
Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0tag:blogger.com,1999:blog-2617544995434103073.post-80351660016299830782012-07-27T14:36:00.000+02:002012-11-18T14:58:11.101+01:00Problems with MacBook and Bluetooth speakers<p>I recently bought a Bluetooth speaker (Creative D100), and was really annoyed about how badly it worked with my Macbook. As soon as the sound stopped for a little while (even 30 seconds), the pairing would drop and the Mac wouldn’t be able to reestablish it on its own, and would start playing sounds from the embedded speakers. I had to reconnect the speakers manually a few times before they’d start working again.</p>
<p>Conversely, on my Android phone they work very smoothly - the pairing would start as soon as I enable the Bluetooth.</p>
<p>After a little bit of googling, I found <a href="http://mariusvw.com/2011/06/16/how-to-fix-the-crackling-bad-sound-of-bluetooth-a2dp-headsets-or-speakers-on-mac-os-x/" target="_blank">the solution</a>. It helped a lot, although I have the impression the connection isn’t quite as smooth as with my Android phone yet. But then, I haven’t tried it much so I might be wrong.</p>
<p>For the lazy who don’t want to click the link:</p>
<ol>
<li>Find the file ~/Library/Preferences/com.apple.BluetoothAudioAgent and double click on it. It should open on the plist editor.</li>
<li>Change the value “Apple Bitpool Min (editable)” to 50.</li>
<li>Save and close.</li>
</ol>
<p>That’s it. Should this cause problems, just follow the same steps again and change the value back to the original (35 I think, or whatever it was on your system).</p>
<p><b>Edit</b>: Mountain Lion seems to have solved these issues.</p>Robertohttp://www.blogger.com/profile/14584383295003516037noreply@blogger.com0