December 11, 2013

Piping input to the gcc preprocessor

Spent a while hacking this little pipe to grab the configuration constants for the Marline firmware on my Rostock 3D printer:


echo "$(grep -e '^#define' Configuration.h)$(echo -e "\nDELTA_DIAGONAL_ROD")" | gcc -E - | tail -n 1


The first part,
echo "$(grep -e '^#define' Configuration.h)$(echo -e "\nDELTA_DIAGONAL_ROD")" 
will spit out all the #define lines in Configuration.h, followed by a newline (echo -e) and the symbol I am after. Having newlines within bash variables still feels like magic :)


After that, I rely on standard Unix notation to make gcc use standard input ("-"). The gcc documentation doesn't seem to mention this possibility.


Note to self: find a way of using markdown on Blogger -- straight HTML and the "Composer" are equally horrible for geeky stuff.

December 3, 2013

Revival

After a long downtime, I'll try reviving this blog mostly as a place to chronicle my experiences with a newly build 3D printer.

First, let's get MathJax online. Looking through the docs, it looks like what I need to match the StackEdit/GitHub configuration is the following (at the end of the <head> block):


<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ['$','$'] ],
            displayMath: [ [ '$$', '$$'] ],
            processEscapes: true
nbsp;    }});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript">



Below should be a displayed equation
$$ E^2 = m^2 + p^2 $$
the same could be inlined like so: $E^2 = m^2 + p^2 $

Am of course planning on moving it all to a static system like all the cool kids, but not right now...

February 23, 2011

Worlds deepest ring trap!

Yup, I am quite sure they will never be deeper than this.
Squeezing any harder from the top would send the poor ions flying out the side.

November 24, 2010

Doing Y's again

I really should be doing some quantum schmantum, but couldn't help fiddling with some ideas for a best-compromise Y-intersection. This time around I'm firmly committed to Mathematica -- once you know the gotchas you can actually get some nifty performance. And the language is heavenly compared to most other things and Matlab in particular.

September 24, 2010

Local minima?

Somehow i don't feel that looking for local minima is going to tell me much when I take this to higher dimensions...

June 8, 2010

Mutliple non-admin users of GoogleAppEngineLauncher under OS X

If you do the right thing® and work as a non-admin user under OS X (10.6 / Snow Leopard), you will get strange errors if you are multiple users who try to use the GoogleAppEngineLauncher in order to toy with Googles awesome AppEngine: Only the non-admin user who (last) installed the program is apple to start the local server, everybody else gets an error that the server is unable to launch google/appengine/tools/os_compat.py or some such.
Turns out it's a permission problem: some of the files (which in my case are owned by sara:admin), doesn't have read/execute permission for everybody else:
fladmast:Contents janus$ pwd
/Applications/GoogleAppEngineLauncher.app/Contents
fladmast:Contents janus$ find . -name '*.py' -not -perm -005 | wc -l
     466
fladmast:Contents janus$ ls -l `find . -name '*.py' -not -perm +005 | tail -n 1`
-r-xr-x---  1 sara  admin  1938 May 16 08:28 ./Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/tools/bulkload_client.py

The fix is simple: Open a terminal and fix the permissions:
fladmast:/ janus$ cd /Applications/GoogleAppEngineLauncher.app/Contents/
fladmast:Contents janus$ sudo chmod -R +r,+X .
(That's a capital X in the chmod)

March 24, 2010

Scan processing with pdfimages and ImageMagick

Just for my own reference, the following procedure works quite well for turning greyish pdf scans into something printable:
pdfimages foo.pdf img
for a in *.ppm; do convert $a -level 50%,80%  ${a%ppm}png ; done
This uses pdfimages (on OSX you can grab the xpdf package from MacPorts) for extracting images from the pdf file, and then ImageMagick convert (probably MacPorts again) to set the white and black levels to 50 and 80 percent respectively. Without pdfimages, ImageMagick just calls ghostscript to convert the pdf at a fixed resolution which is of course useless for this purpose. Next time I might have a look at the contrast-stretch and auto-level options which might be a bit more robust.