convert

Convert a Scala array to string with mkString

Scala collections FAQ: How can I convert a Scala array to a String?

A simple way to convert a Scala array to a String is with the mkString method of the Array class. (Although I've written "array", the same technique also works with any Scala sequence, including Array, List, Seq, ArrayBuffer, Vector, and other sequence types.)

Here's a quick array to string example using the Scala REPL:

A Perl script to print Nagios log records in a human readable date format

Perl date FAQ: Can you share a Perl date example where you print a date in a decent human-readable format?

Update: Be sure to look at the comments below for some great Perl "one liners", i.e., one-line solutions to this problem.

In this blog I'll share the source code for a Perl program that takes nagios.logrecords as input, then outputs the records with a human-readable date format. More specifically, the input records look like this:

MySQL backup - How to backup a MySQL database

MySQL backup FAQ: How do I back up a MySQL database?

I can't speak about backing up MySQL databases that are modified twenty-four hours a day seven days a week, but on all the MySQL databases I currently work with, there are always times when I can guarantee that there won't be any SQL INSERTs, DELETEs, or UPDATEs occurring, so I find it's really easy to perform a MySQL backup using the mysqldump utility program. Here's how it works.

Java SimpleDateFormat example - Convert a Date to a formatted String

Summary: This tutorial demonstrates how to use the Java SimpleDateFormat class to convert a Java Date to a formatted String.

The Java SimpleDateFormat class provides lets you easily convert (a) between a Java String to a Date or (b) perform the opposite conversion, from a Java Date to a String. In this article we'll at several different ways to convert a Java Date object to a nicely formatted String object, and in another article we'll look at a couple of nice ways for converting in the opposite direction.

Mac - convert BMP files to JPEG or PNG format (command line)

Mac BMP image FAQ: How can I convert BMP image files to the JPEG format?

Mac - Convert BMP image to JPEG, PNG, TIFF, GIF, or PDF

Mac BMP image FAQ: How can I convert a BMP image to a JPEG (JPG) format on a Mac? (Or to a PNG, TIFF, GIF, or PDF format.)

If you have just one BMP image you want to convert, you can do this with the Mac OS X Preview application. Just follow these steps:

A PHP string to date example

Summary: A PHP string to date conversion example.

For a recent PHP calendar project I needed to convert a given string into a 'date' I could work with more easily. In short, given a string date like this:

"2011/05/21"

I wanted to convert that to some type of PHP date data structure I could use to render a calendar.

PHP string to date source code

The following PHP code shows the two steps I used to convert a date string into a PHP date structure I could work with:

Batch convert Mac BMP, JPG, PNG image files, free

Mac batch image conversion FAQ: How can I "batch convert" images from one image format to another on a Mac, such as BMP to JPG, or PNG to JPG?

Free Mac batch thumbnail creation

Mac thumbnail image processing FAQ: How can I create thumbnails images for a batch of original images (or photos) in PNG, JPEG, and other file formats? (Also written as, "How can I batch create thumbnails on a Mac?")

Convert vi/vim tabs to spaces

vim tabs/spaces FAQ: How do I convert vi/vim tabs to spaces?

You can convert tabs to spaces in vim using the usual vim search and replace command. Specifically, this vim "tabs to spaces" command is all you need:

:1,$s/\t/  /g

In short, this command can be read like this:

Syndicate content