document

Scala: How to delete documents in a MongoDB with Casbah

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.8, “How to delete documents in a MongoDB with Casbah.”

Problem

You want to delete one or more documents in a MongoDB collection.

Solution

Use the findAndRemove method of the Casbah MongoCollection class to delete one document at a time, or use the remove method to delete one or more documents at a time.

Scala: How to update documents in a MongoDB collection with Casbah

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.6, “How to update documents in a MongoDB collection with Casbah.”

Problem

You want to update one or more documents in a MongoDB collection.

Solution

Use either the findAndModify or update methods from the Casbah MongoCollection class, as shown in this example:

Scala: How to insert documents into MongoDB with insert, save, and +=

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 16.4, “How to insert documents into MongoDB with insert, save, and +=.”

Problem

You want to save documents to a MongoDB collection from a Scala application.

Solution

Use the insert, save, or += methods of the Casbah MongoCollection class.

Scala and XPath - get the first element of an array

Scala/XPath FAQ: How do I get the first element of an array in an XML document using Scala and XPath?

I ran into the problem of needing to get the first array element from an XML document using Scala and XPath recently, and in short, I ended up writing some Scala/XPath code that looked like this:

iPad PDF documents: How to read, transfer, and save

iPad PDF FAQ: How do I transfer a PDF file onto my iPad, iPhone, or iPod? (Or, "How can I read a PDF on my iPhone, iPad, or iPod?)

Since the iPod, iPhone, and iPad all use the Apple iOS operating system, the process of getting a PDF file onto these devices is identical (or nearly identical) for each device. In this article I'll generally refer to the iPad, as it's actually hard to read most PDF documents on an iPhone of iPod.)

Java undo and redo in a Swing application

Here's a step-by-step approach for how to implement "undo" and "redo" behavior in your Java text components, i.e., the JTextArea JEditorPane and JTextPane I should note that you don't get this behavior for free -- you have to implement it yourself, hence this undo/redo tutorial.

PHP here document (heredoc) examples

PHP here doc FAQ: Can you share some examples of the PHP "here" doc (heredoc) syntax?

"Here" documents in many languages are provided as a way to address the following problems:

Software requirements writing - two notes on my frame of mind

Here are a couple of notes I just sent someone on how to get started writing a software requirements specification.

They may be a little vague, but I hope they show my intent, or perhaps my frame of mind, when writing a software specification.

Fred,

Here are two notes on my mental approach when writing software requirements specifications:

Get the LaTeX chapter name and section name on the document header

Wow, this was a tough LaTeX problem, and it would really help if I knew a lot more about LaTeX.

My goal for a LaTeX PDF that I created recently was to get the header of my pages to look something like this:

Section Name (Chapter Name)

where "Section Name" and "Chapter Name" are left-aligned in the header of the page, and would be dynamically replaced by the actual values of the current section and chapter names, respetively.

LaTeX - underline text (font) in a LaTeX document

LaTeX font question: How do I underline text in a LaTeX document?

This actually ends up being one of the easiest things to accomplish related to LaTeX font formatting. Its a little inconsistent from the LaTeX tags you use to create bold and italicized text, all you have to do is use the LaTeX \underline tag: