www.flickr.com
Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

Tuesday, August 26, 2008

Flickr Learned LOLspeak & OS X Screen Captures



Flickr Learned LOLspeak, originally uploaded by smithco.
Flickr greeted me with a boisterous "O HAI" this morning. I laughed out loud.

This also reminded me of a good OS X tip.  Screen captures in OS X are really easy.  ⌘-Shift-3 will drop a PNG-format image file on the desktop for each screen.  ⌘-Shift-4 will give a cross-hair selector to grab a portion of the screen: just select a region and a PNG appears on the desktop.

Tuesday, January 02, 2007

Emacs Tip: Install Ispell on Windows

One little hiccup with running Emacs on Windows is that, by default, the spell checker does not work. The reason is simple enough, Emacs relies on an external program called ispell to do the spell checking work, and ispell is typically not installed on Windows.

Installing ispell isn't too difficult, though it's not trivial either. The first requirement is that Cygwin needs to be installed, or at least, the cygwin1.dll shared library needs to be somewhere accessible. Once Cygwin is installed, you can download ispell. See the README file for instructions. Do make sure to follow the instructions! Especially, do not forget to set the variable DICTDIR. It's easy with the instructions, but skipping a step can result in odd errors.


Afterwards, ispell can be invoked on the current Emacs buffer with the simple command M-x ispell.

Wednesday, December 06, 2006

ps2pdf tip: How to Get Around the "broken" ps2pdf Arguments

I through hours with a ps2pdf problem. Thank God someone on the PostScript news group managed to help me out. Here's the story for posterity's sake.

I'm currently working on a LaTeX document with some photos in it. As I'm using the PowerDot class, which is incompatible with pdflatex, I need to convert all my images to EPS and use ps2pdf to get my final PDF document. On the first attempt, I used the command

ps2pdf file.ps file.pdf

and it worked, except that my photos came out all muddy, a result of over compression. So, I added the option to turn off compression,

ps2pdf -dEncodeColorImages=false file.ps file.pdf

and end up with the wonderfully obtuse error message

Error: /undefinedfilename in (false)
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1122/1686(ro)(G)-- --dict:0/20(G)-- --dict:70/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 8.54: Unrecoverable error, exit code 1

Ick.

It turns out that ps2pdf on Windows is a batch file, and batch files do not accept = in an argument. I had no idea that this was the case, but so it is. The solution, which is annoyingly absent in the documentation, is to replace = with #. Thus, the command on windows should be,

ps2pdf -dEncodeColorImages#false file.ps file.pdf

Like that, it works. And, I get my beautiful uncompressed photos in my document.

Friday, December 01, 2006

Emacs Tip: Troublesome Tabs in Python Mode

The Python mode in Emacs 22 (using python.el, not the python-mode.el from XEmacs) has a nice feature of deducing the spacing style based on the spacing and tabs that already exist in the file. Most of the time, it works really well, but, it does make getting rid of large tabs difficult. So, if you're having problems getting rid of tabs, simply toggle the indent guessing mode with the command python-guess-indent and just use the default Python mode settings for indentation.

Thursday, November 30, 2006

Python Tip: Make Python & Emacs Play Nice on Windows

I've discovered that making Python 2.4.4 work well under Emacs 22 on Windows has a few speed bumps. I'm not sure if these problems apply to other combinations of versions, but they may. Here's a list of things I had to do to make for a happy working environment.

To Run Python in Emacs
To Run Using Pychecker
  • Download the pychecker package
  • Decompress it and go to the extracted folder in a Command Prompt
  • In that folder, run the command python setup.py install
  • Use C-c C-v to run the python code loaded in the current buffer with pychecker
Unresolved Problems (I'm Working on These, Be Patient)
  • It seems that the debugger (pdb) is set up differently with Python 2.4.4 under Windows than other configurations. Consequently, Emacs' calls to pdb are all wrong.
  • When the Python interpreter is loaded into Emacs, it appears to be in a text-only mode. Running programs with graphics does not seem to work.

Monday, November 20, 2006

Visual C++ Tip: Visual C++ is Broken

Once again, I feel the urge to severely beat the people responsible for Visual C++.

I've once again run into examples of severe stupidity in this compiler. It seems that somehow,
Visual C++ got released without someone checking to see if the standard libraries can actually be compiled at the highest warning levels (for Visual C++ 8, that's with the option /Wall).

It really is quite essential for best practices that a compiler can compile it's own standard libraries at the highest warning levels without producing warnings. Otherwise, it causes obfuscation and hides legitimate messages related to the users' code. What's worse, the warnings produced from the standard library are completely opaque.

Here's an example of the warnings I've been given by the compiler.
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\string.h(141) : warning C4619: #pragma warning: there is no warning number '4609'
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\wchar.h(116) : warning C4820: '_wfinddata64i32_t' : '4' bytes padding added after data member '_wfinddata64i32_t::attrib'
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\wchar.h(121) : warning C4820: '_wfinddata64i32_t' : '4' bytes padding added after data member '_wfinddata64i32_t::name'
The first one is a real gem. A warning that there's a warning that doesn't exist. And I think the second one is an indication that there's a nasty shortcut for memory initialisation somewhere. Ugh.

The only lesson here is that the compiler option /Wall is completely unusable. So, use /W4 instead. It's less rigorous, but at least, there's fewer strange warnings emitted from the compiler regarding the standard library at that level. Few enough that they can be disabled or filtered out.

Friday, November 17, 2006

Visual C++ Tip: How to Enable Standard C++ Keywords

The people at Microsoft responsible for Visual C++ need to beaten with a stick. Those responsible for the documentation should be beaten severely.

Once again, I just finished another round of frustration with the non-compliance problems of Visual C++ 8. One would think that by six years after the ISO standard, they would get around to having all the embarrassingly glaring compliance issues sorted out, but sadly, it is still the case that simple, conforming C++ programs will not easily compile.

My current frustration is that, by default, Visual C++ has the boolean operator keywords disabled. That's right, by default, Visual C++ has certain, standard C++ keywords disabled. And it isn't some obscure functionality that I'm referring to, it's the keywords for the logical boolean operators.

It is possible to enable them with the option /Za. To be clear on this, we can refer to the MSDN documentation for the /Za option,
/Za flags language constructs not compatible with either ANSI C++ or ANSI C as errors. /Ze enables Microsoft extensions.
Uh oh, it looks like Microsoft tied two bits of unrelated functionality together into one compiler option, and left one of the bits undocumented. I think I have the full story figured out now, but caveat lector! We've landed in an undocumented, side-effect territory. It seems that we can either have the standard keywords or the language extensions, but not both. Now, most of the language extensions are useless, losing them is no problem, but there is an exception here. The keyword "extern" is erroneously considered a language extension by Microsoft. If you need that very useful keyword, you may run into problems.

Like I wrote at the start of this post, the people at Microsoft responsible for Visual C++ need to beaten with a stick. Those responsible for the documentation should be beaten severely. The design choice here is a shining example as to just how bad the compiler actually is.

Friday, October 13, 2006

LaTeX Tip: Typesetting Nice Fractions or How to Make xfrac Work

One reason that we all love LaTeX is that it does a beautiful job of typesetting mathematics, provided that you're in an equation environment. Unfortunately, the typesetting of mathematics in inline text does not always work well.

One major problem that can occur is that fractions set inline in text either forces some extra space above and below the line of text or fails to nicely follow the text's current formatting.

The solution is to use the xfrac package, a package that solves all the nasty typesetting issues for fractions. Unfortunately, xfrac doesn't work if it is installed in the default way. A little LaTeX expertise is needed to coerce it into working. The instructions to do so with a MikTeX installation follow (the instructions for other LaTeX installations should be very similar).
  1. Do a full update of using the MikTeX Update Wizard
  2. Install the xfrac package, either automatically by including it in a document or using the MikTeX Package Manager
  3. Get the LaTeX project repository download xbase.tgz, the base package for the experimental features (direct link to the file)
  4. From xbase.tgz, extract the file xbase.ins
  5. Run latex on xbase.ins (the exact command is latex xbase.ins)
  6. Copy the generated style files (template.sty, ldcsetup.sty, xparse.sty, and xparse.sty) to the appropriate places, such that we get:
    • C:\texmf\tex\latex3\template\template.sty
    • C:\texmf\tex\latex3\xparse\ldcsetup.sty
    • C:\texmf\tex\latex3\xparse\xparse.sty
    • C:\texmf\tex\latex3\xtools\xtools.sty
  7. Update the package index (the exact command is texhash)
Now, it is possible to set fractions nicely anywhere in a document with the command \sfrac{numerator}{denominator}. All the details of this command can be found in the xfrac documentation (PDF).

Monday, August 28, 2006

Inkscape Tip: Use Inkscape on the Command-line

It turns out that Inkscape (an SVG editor) has a few useful command-line options for non-interactive use. However, these are only documented on the Inkscape website (Manpage of INKSCAPE), but not in the documentation accessible from the program.

The real gem in the command line options is are the export options. These are a command-line interface to load up an SVG file and export as another format in a non-interactive format. This allows for the inclusion of vector format conversions in scripts.

Since the well-known image conversion utility ImageMagick does not have vector-to-vector format conversions, this is a very useful tool.

Particularly, this is an issue when using Inkscape (or other tools that use SVG) to create images for LaTeX documents, where one of EPS, PDF or PNG is typically used.

To convert an SVG file to an EPS file use
inkscape -f file.svg -E file.eps
to a PDF,
inkscape -f file.svg -A file.pdf
and to a PNG,
inkscape -f file.svg -e file.png