delete

A simple Java JDBC example that shows SQL insert, update, delete, and select alvin August 10, 2016 - 10:53am

Here’s a short Java/JDBC example program where I show how to perform SQL SELECT, INSERT, UPDATE, and DELETE statements with JDBC:

How to use the Linux sed command to delete a range of lines

In a previous blog post I demonstrated how to use sed to insert text before or after a line in many files, and in this example I'd like to demonstrate how to delete a range of lines using sed.

sed delete - How to delete a range of lines using sed

The problem I had today was that I just re-generated 99 HTML files for my Introduction to Unix/Linux tutorial using Latex2HTML, and it generates a bunch of "junk" in my HTML files that looks like this:

A Perl script to delete binary files

As a quick note and a little bit of source code sharing, I wrote the following Perl script to delete all of the binary files it finds in a list of files it’s given. I named this script deleteBinaryFiles.pl, and it should be called like this:

deleteBinaryFiles.pl listOfFilesToLookAt

where listOfFilesToLookAt is a file that contains a list of filenames, with one filename per line.

Given that brief introduction, here’s the source code:

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.

How to delete elements from Sets in Scala (operators, methods)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.27, “How to Delete Elements from Sets in Scala”

Back to top

Problem

You want to remove elements from a mutable or immutable set.

Back to top

Solution

Mutable and immutable sets are handled differently, as demonstrated in the following examples.

Back to top

Mutable Sets

When working with a mutable Set, remove elements from the set using the -= and --= methods, as shown in the following examples:

Table of Contents

  1. Problem
  2. Solution
  3. Mutable Sets
Back to top

Scala: How to add, update, and remove elements with immutable Maps

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.16, “How to Add, Update, and Remove Elements with Immutable Maps”

Problem

You want to add, update, or delete elements when working with an immutable map.

Solution

Use the correct operator for each purpose, remembering to assign the results to a new map.

To be clear about the approach, the following examples use an immutable map with a series of val variables. First, create an immutable map as a val:

How to delete Array and ArrayBuffer elements in Scala alvin June 6, 2015 - 12:57pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.9, “How to Delete Array and ArrayBuffer Elements in Scala”

Problem

You want to delete elements from an Array or ArrayBuffer.

Solution

An ArrayBuffer is a mutable sequence, so you can delete elements with the usual -=, --=, remove, and clear methods.

You can remove one or more elements with -=:

How to delete elements from a List (or ListBuffer) in Scala alvin June 6, 2015 - 12:33pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.4, “How to Delete Elements from a List (or `ListBuffer`) in Scala”

Problem

You want to delete elements from a List or ListBuffer.

Solution

A List is immutable, so you can’t delete elements from it, but you can filter out the elements you don’t want while you assign the result to a new variable:

Emptying the Mac OS X trash from the command line

When using a Mac OS X computer, it's easy to forget that it's just Unix running under the hood ... until your iMac graphics card dies and all you can do is use single-user mode, which has no GUI ... then you're reminded very quickly that it's all just Unix.

Take emptying the trash, for instance. Graphically, you right-click the Trash Can icon, then select the Empty menu option. From the Mac command line (Terminal) you just do this:

rm -rf ~/.Trash/*

It's funny how simple that is from the command line.