Showing posts with label soft. Show all posts
Showing posts with label soft. Show all posts

Thursday, July 14, 2016

Error associating all .ply files to MeshLab in OSX El Capitan


When trying to associate MeshLab application to all the .ply files with the Always open with or Change All...  buttons I get the following error
An unexpected error occurred (error code -10813).
The operation could not be completed.

The problem is that MeshLab is missing the key CFBundleIdentifier in its Info.plist.
To solve the problem edit its plist file
> open /Applications/meshlab.app/Contents/Info.plist 
and add the key CFBundleIdentifier with value com.vcg.MeshLab.

Then touch the application tell OS X about the change
> touch /Applications/meshlab.app
And retry associating the file type.

Sunday, October 14, 2012

Download/backup BibTeX library from CiteULike, including all the attached PDF

CiteULike is a convenient solution for bibliographic management, but sometimes an off-line replica of the bibliography is also needed. This can be achieved by exporting the CiteULike library in BibTeX format, furthermore BibDesk (and probably other managers too) can be synchronized directly with the CiteULike server.

While it is easy to export a .bib file from CiteULike, downloading all the attached files and having the .bib linking to the downloaded files is a different story.

BibTeX and JSON exports of the CiteULike library can be retrieved from:
  http://www.citeulike.org/json/user/USERNAME
  http://citeulike.org/bibtex/user/USERNAME
The BibTeX export can be read directly into a bibliographic manager, but the JSON export contains more information than the .bib, in particular it contains the location of the attached PDFs. So the idea of the Python script linked below is to do the following
  1. download the CiteULike library in BibTeX and JSON formats
  2. parse the JSON export and download all the attachments
  3. modify the .bib file to include links to the downloaded copies of the attachments
the links in the .bib file should work for BibDesk and JabRef.

Before running the script:
  • setup CITEULIKE_USERNAME and CITEULIKE_PASSWORD variables in the script
  • verify you have wget and pybtex installed
Download the Python script:  citeulike_backup.zip

http://wiki.citeulike.org/index.php/Importing_and_Exporting#JSON


Gory details from http://wiki.citeulike.org/index.php/Importing_and_Exporting#JSON:
# save session cookies
> wget -O /dev/null --keep-session-cookies  --save-cookies cookies.txt --post-data="username=xxxx&password=yyyy&perm=1" http://www.citeulike.org/login.do
# download bibtex with private comments and download an attachment
> wget -O export.bib --load-cookies cookies.txt http://www.citeulike.org/bibtex/user/xxxx
> wget --load-cookies cookies.txt http://www.citeulike.org//pdf/user/xxxx/article/123456/891011/some_99_paper_123456.pdf

Thursday, August 16, 2012

Homebrew package manager for OSX + Tips

Forget Fink and MacPorts, Homebrew is the miracle package manager you are looking for.

Homebrew installs packages to their own directory and then symlinks their files into /usr/local.
Then there is no need to tweak the system's and compiler's search paths to reach the packages. Also the installation is extremely simple, and the syntax familiar:
  brew [search, install, remove] packagename

The big critic I read about was the lack of packages. Never noticed, probably because the number of packages have exploded during the last year. The packages are built locally, so compiling large applications may take considerable time.

Tips:
  • Compile for multiple architectures. If, for some reason, you need to compile a program/library with multiple architecture support, like on a 64bits system but with 32bits legacy applications. Then, while installing use the --universal flag:
         brew install --universal -v libtiff
    it will compile a "fat" library with multiple architectures (env UNIVERSAL_ARCH="i386 x86_64" to specify which architectures).
  • Python. This setting is very important, but may depend on the version of OSX.
    When I installed Homebrew it did not compile its own python, instead it used the python that came with the system. Then all python packages installed with Homebrew are stored in: /usr/local/lib/python2.6/site-packages,  which is not in the search path for  python. It must be specified with the environment variable PYTHONPATH, by adding this line to ~/.bash_profile :
      # CONTRIBUTED PYTHON LIBRARIES
     
      #------------------------------------------
     
      export PYTHONPATH=/usr/local/lib/python2.6/site-packages:$PYTHONPATH
     
      #------------------------------------------


    More on Python and Homebrew.
  • Big projects like GIMP, Inkscape, Firefox,  and many others...  Are not available as packages, they are already distributed as standalone OSX applications.

Friday, August 10, 2012

Record audio from the system output

soundrec.exeBy default in OSX it is not possible to record audio from the system output. This occurs if you try to record sound from an application, like a web browser.
Moreover, besides GarageBand there is no integrated lightweight sound recorder in OSX (like the old and reliable soundrec.exe).



The solution to the first problem is provided by an Audio Routing device/application.
Soundflower is popular open source extension that allows applications to pass audio to other applications. This article explains how to use it.
Jack is another free option but apparently has more features and is more complicated to use. Other popular non-free options are WireTap and Rogue Amoeba.

As for recording under OSX, Audacity is a free and "lightweight" (80Mb) application that works.

Sources:
http://gerrybeauregard.wordpress.com/2011/08/31/soundflower-great-tool-for-recording-the-macs-audio-output/
http://www.macworld.com/article/1159440/soundflower_capture.html

Friday, May 18, 2012

Convert PDF presentations to Keynote

PDF to Keynote is a free tool for converting PDF-based presentations (e.g., made using LaTeX with Beamer) into Apple's Keynote format. Once translated into Keynote format, every page of the original PDF becomes an image on its own slide, so no further edition is possible.
The advantages of presenting PDFs using Keynote include: the presenter display, rehearsal support, and notes visible only to the presenter.

Source: http://www.cs.hmc.edu/~oneill/freesoftware/pdftokeynote.html

Thursday, September 15, 2011

MegaWave2 V3.01 - "Advanced - Ultimate" for OS X 10.6.8

I'm addressing again the installation of Megawave 2 V3.01, this time in OS X 10.6.8 (Snow Leopard).
A default installation of Snow Leopard uses a 32bits kernel, but which can run both: 32 and 64bits applications. This implies that all the system libraries are complied for both architectures.

Megawave however, is not 64bit-friendly so it mut be compiled as a 32bits application. The patches I've made are centered on enforcing a 32bits compilation at all stages of the Installation.
To avoid complications related the dependence on libtiff and libjpeg (which must be also compiled in 32bits), I've opted to include them in the package and compile them as part of Megawave installation.
The compiled libraries are stored inside Megawave library path sys/lib/ix86, so they do no interfere with other system libraries.

The resulting package only requires the gcc compiler, which can be either 4.0 or 4.2.

The installation should go as follows:

Monday, April 25, 2011

Extract content from a pkg or mpkg "file"

Ever wondered what's inside a .pgk or .mpkg file?
In general they are directories so it can be accessed from the shell, or right-clicking it and choosing "Show Package Contents". The application data is packed in the file named: Archive.pax.gz.
To uncompress it:
   gunzip Archive.pax.gz
   pax -rvf Archive.pax

and voilĂ , behold all the package content unrolled before you.

I the right-clicking does not work then the .pkg is not a directory but a file. In this case there is a handy application named unpkg, that will just do the trick.


Sources:
http://en.wikipedia.org/wiki/Pax_(Unix)
http://www.linuxquestions.org/questions/linux-general-1/cant-extract-macosx10-4-universal-pkg-678167/
http://www.macupdate.com/app/mac/16357/unpkg

Tuesday, September 21, 2010

Python and cherrypy on OSX

While running a cherrypy application I got this error:
ImportError: No module named header

The problem and the solution is described here http://old.nabble.com/py2exe-fails-with-%22%22-td18029166.html

>
> .... Creating the exe file works but running it fails with:
>
> Traceback (most recent call last):
>   File "bootstrap.py", line 2, in  
>   File "cherrypy\__init__.pyc", line 164, in  
>   File "cherrypy\_cperror.pyc", line 6, in  
>   File "cherrypy\lib\http.pyc", line 23, in  
>   File "email\__init__.pyc", line 79, in __getattr__
> ImportError: No module named header
>
>
> For that particular import (email.Header) you can upgrade to trunk
> HEAD or apply this small patch: http://www.cherrypy.org/changeset/1967.
> That email module is only used for decoding RFC-2047 text, which hardly any clients ever do.
>
                                                                  
The solution is to modify the file: /sw/lib/python2.6/cherrypy/lib/http.py (this is the path particular of my machine)


Index: trunk/cherrypy/lib/http.py
===================================================================
--- trunk/cherrypy/lib/http.py (revision 1836)
+++ trunk/cherrypy/lib/http.py (revision 1967)
@@ -21,5 +21,4 @@
 
 import cgi
-from email.Header import Header, decode_header
 import re
 from rfc822 import formatdate as HTTPDate
@@ -197,4 +196,5 @@
 def decode_TEXT(value):
     """Decode RFC-2047 TEXT (e.g. "=?utf-8?q?f=C3=BCr?=" -> u"f\xfcr")."""
+    from email.Header import decode_header
     atoms = decode_header(value)
     decodedvalue = ""
@@ -366,4 +366,5 @@
                         # Encode RFC-2047 TEXT
                         # (e.g. u"\u8200" -> "=?utf-8?b?6IiA?=").
+                        from email.Header import Header
                         v = Header(v, 'utf-8').encode()
                     else:


The patch is also available at: http://www.cherrypy.org/changeset/1967

Tuesday, September 14, 2010

Wine (windows emulator) for OSX

The wine emulator permits to run Windows binary on Linux and now OSX:
http://wiki.winehq.org/MacOSX

A packaged .dmg file is also available for download at:
http://winebottler.kronenberg.org/

Monday, July 12, 2010

Binary GIMP for OSX including resynthesizer plugin

Resyntesizer is a GIMP plugin from Paul Harrison for texture synthesis and image completion, it provides the same functionality similar to Potoshop's content aware filters.
Thanks to Alfonso for pointing me out this link.

 >>

A binary GIMP distribution for OSX (dmg format) that includes the resynthesizer plugin is available at http://gimp.lisanet.de/Website/Download.html.


Other Sources:
http://www.hutsby.net/2010/04/howto-use-resynthesizer-for-gimp-on-osx.html

Tuesday, June 29, 2010

Adapt OpenGL projection matrix to show objects behind the projection plane



In OpenGL the projection operation is defined by the projection matrix, and the objects drawn in the screen are inside the rendering volume defined by the left/right, upper/lower and near/far boundaries of a frustum (truncated pyramid). The projection plane is generally the near plane. The function glfrustum generates a projection matrix with these characteristics.


However there is a problem with the projection defined by glfrustum. Virtual objects in front of the near plane are not shown. However we whould like to show them as well.



The problem is that glFrustum produces a projection matrix that implicitly sets the near plane as a clipping one. Fortunately this can be fixed after understanding how OpenGL performs the clipping test (read http://www.songho.ca/opengl/gl_projectionmatrix.html).


Let's see how the 3d homogeneous coordinates of the scene are rendered.
  • First the the scene is transformed (mainly to position all the objects) with the GL_MODELVIEW matrices.
  •  Second the projection matrix is applied, its task is to convert the rendering volume to NDC (Normalized Device Coordinates) shown below. The NDC are still 3d homogeneous coordinates with w != 1. 
  • Third the vectors (x,y,z,w) are divided by w, the resulting vectors (x/w,y/w,z/w) that have coordinates in [-1,1]^3 are rendered everything that's outside the cube is clipped (discarded). The positions of each 3d point in the screen is "practically the same as" by (x/w,y/w) (I'm skipping other 2d transformations), and the z/w coordinates are fed to the z-buffer. 



The glfrustum projection matrix is


[ 2n/(r-l)   0      (r+l)/(r-l)    0       ]
[ 0       2n/(t-b)  (t+b)/(t-b)    0       ]
[ 0          0     -(f+n)/(f-n) -2fn/(f-n) ]
[ 0          0         -1          0       ]



where n,f<0 are the coordinates of the near and far planes, l,r,t,b are respectively the (left,right,top,bottom) coordinates, all the coordinates are with respect to the viewer position (the origin). In order to display objects in front of the projection plane we need to modify the projection matrix. We want points (x,y,z) with near<0, to be shown. These points are clipped by the glfrustum's matrix since [near, far] is mapped to the range [-1,1].


Observe that the first two rows compute the (x,y) coordinates of the points in the screen, but we are not interested in changing them.
The third row maps [near,far] to [-1,1], ideally we want to have a mapping [q,far] to [-1,1] with 0>q >near. It is easy to see that the following matrix performs this map


[ 2n/(r-l)    0      (r+l)/(r-l)    0       ]
[    0     
2n/(t-b)  (t+b)/(t-b)    0       ]

[    0        0     -(f+q)/(f-q) -2fq/(f-q) ]
[    0        0          -1         0       ]

The glfrustum matrix can be corrected with


/* Compute the projection matrix */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -1.0 + X , 1.0 + X, /* left, right */
           -1.0 + Y , 1.0 + Y, /* botom,top*/
           ZNEAR_proj - Z,     /* Z near: the projection plane!*/
           ZFAR                /* Z far */ );

/* Recover the current matrix */
GLfloat projectionMatrix[16];
glGetFloatv(GL_PROJECTION_MATRIX,projectionMatrix);
/* Modify the entries */
projectionMatrix[10]=(-ZFAR-ZNEAR_clip)/(ZFAR-ZNEAR_clip);
projectionMatrix[14]=(-2*ZFAR*ZNEAR_clip)/(ZFAR-ZNEAR_clip);
/* Load the modified matrix */
glLoadMatrixf(projectionMatrix);


On projections: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/homogeneous.html

Tuesday, June 8, 2010

Matlab's mxMalloc/mxFree: inefficient for memory intensive algorithms

This was a real headache.
When programming Matlab mex programs, it is customary to use the Matlab's mxMalloc/mxFree routines to manage the memory. It seems that aligns the data (maybe for efficiency), and also have several garbage collecting features (on termination of the program).

It turns out that these routines are very slow and for memory intensive applications, i.e. dynamic lists.


Some reading about using malloc/free inside Matlab mex:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/162021

Friday, June 4, 2010

Debug Matlab MEX files with gdb in Linux / OSX

From the Mathworks helpdesk site here are some instructions for debugging mex files.

Make sure that the mex has been compiled with -g
>> mex -g function.c

Restart Matlab with:
shell> matlab -Dgdb
run -nojvm
>> dbmex on

Run the code:
>> function(param)

To access the debugger:
>> dbmex stop

To add a breakpoint at the gateway function (just before your code):
break mexFunction

Thursday, April 22, 2010

LaTex, equations for Inkscape, OpenOffice and Others

I'm using MacTeX (http://www.tug.org/mactex/) for writing, it includes the TeX Live and the TeXShop editor.
Other utilities that I find quite useful are:

Saturday, February 27, 2010

Create an ITunes account Tunes App Store account without a credit card

Follow the instructions:

http://support.apple.com/kb/HT2534

Thursday, October 1, 2009

MegaWave2 V3.01 in OS X 10.5.7

Megawave is an image processing library from for UNIX, developed at CMLA Cachan.
Compiling it's current version (3.01) under OS X is a truly painful task.
From the experiences of Said, Jeremie and Rafa, I've managed to stitch
together a version that works under OS X 10.5.7 and 10.5.8 using the gcc-4.0.1 compiler.

Requieres Xtool, and a lot of Fink/MacPorts packages i.e. libtiff y libjpeg, (I should someday compile a complete list of dependences).

During the installation process:
when asked for X11 path, answer : /usr/X11/lib/ ,
when asked for the libtiff & libjpeg paths, answer: /sw/lib/ or /opt/local/lib/ or wherever these libraries are in your system.
  • In case you are running 10.5.8 the default compiler is gcc-4.2 and it will not work. So the trick is to link cc to gcc-4.0 ( 'ln -s /usr/bin/cc /usr/bin/gcc-4.0' ) during the installation process. 
  • A common cause of problems is the specification of the include directories for libtiff and libjpeg (/opt/local/include or /sw/include or whatever), these are hardcoded in the installation. In this case just modify the CFLAGS parameter in ./kernel/lib/src/Makefile.in to reflect your configuration.
  • A VERY IMPORTANT TIP. During the installation process some configuration files are generated, and they are not overwritten by running the installation again. So if the compilation fails, any change of parameters/files should be performed on the clean unpacked version
Good luck with it : MegaWave2_V3.01.osx10.5.8.tgz

Tuesday, September 22, 2009

VTK and OS X

This is a true mess.


I am currently using vtk54-cocoa + pyvtk-py24
and VTK works with hardware acceleration.

Bash completion

Bash completion is not enabled by default in OS X.
Use fink to install the completion files:
apt-get install bash-completion


or with homebrew:
brew install bash-completion


Fink: like apt-get for Mac

Install fink: