How to show an Android Snackbar message

To show an Android Snackbar message from an Activity or Fragment, use Java code like this:

Snackbar.make(view, "going to: " + url, Snackbar.LENGTH_LONG).show();

One key is to remember to call the show() method after make(). I have a tendency to forget to call show() and then wonder why my Snackbar message isn’t showing up. So maybe a better way to show that code is like this:

Android: How to load an image from a file and set on an ImageView

If you’re working with an Android application, this source code seems to work to load an image from a file:

Bitmap bitmap = BitmapFactory.decodeFile(pathToPicture);

The Bitmap and BitmapFactory classes are located in the package:


Assuming that your pathToPicture is correct, you can then add this bitmap image to an ImageView like this:

The PHP MySQL mysql_connect() can't connect to local MySQL server through socket error

PHP MySQL socket error FAQ: I'm getting a MySQL error like "Warning: mysql_connect(): Can't connect to local MySQL server through socket '/home/lib/mysql/mysql.sock'" when trying to connect to my MySQL database from a PHP application, what can I do to fix this?

I just ran into this problem on a new server I'm using with A2 Hosting, where the exact error I got in my PHP MySQL program is this:

How to show the full path to the current Finder folder

So, you're sitting there, looking at your Mac Finder window, and you see the file you need to work with, but wait ... what is the path to the directory you're looking at?

The Finder is a clever interface -- especially now that it sports four different views -- but at times like this, it just leaves you hanging. I run into this problem all the time when I go to upload a file using any of my web-based email clients, or when I upload a file using a web form.

iPhone song rating - How to set a song rating on your iPod or iPhone

iPhone songs FAQ: Can I set or change the rating of an iTunes song on my iPhone or iPod?

Wow, I'm such an iPod/iPhone/Itunes dummy, I didn't realize that I could change the rating of a song from my iPhone until I dug into it a little bit. Here's a quick look at how to change the iTunes song rating from your iPhone/iPod.

Setting/changing an iPhone/iPod song rating

You can set the iTunes song rating directly from your iPhone (or iPod) when the song is playing.

How do I access a MySQL database with the MySQL command line client?

I may have shown this before in other ways, but I wanted to take a moment to show how to use a MySQL database from the MySQL command line client. The basic command to work with an existing database is the use command, where you say something like this:

mysql> use my_database

For instance, if you have a database named orders, you would declare that you want to start working with it (use it) like this:

MySQL FAQ: How do I show the fields or schema of a database table?

MySQL FAQ: How do I show the schema of a MySQL database table?

Answer: Use the desc command from the MySQL command line client.

For instance, in my current application I have a database table named orders, and when I need to see the schema for that table I show it with the desc command like this:

desc orders

The MySQL output looks like this:

How to un-hide a hidden Mac OS X window

Mac OS X "hide" FAQ: How do I "un-hide" a hidden Mac Window (hidden Mac application)?

At one point or another every new Mac OS X user learns that you can easily hide a window on Mac OS X using the [Command][h] keyboard command, but that moment of fun is usually followed by a few moments of panic and terror and the thought "How do I un-hide/show/display a hidden Mac OS X window?"

Mac tip: How to show just the current application

Mac OS X has a couple of cool tricks for helping you focus on just one application at a time. One of them is the "hide all other programs" trick.

To hide windows from all other applications, and just show windows from your current application, type [Option][Command][H]. Instantly all the other windows are hidden.