Dynamic GPU usage monitoring (CUDA)

To dynamically  monitor NVIDIA GPU usage, here I introduce two methods:

method 1: use nvidia-smi

in your terminal, issue the following command:

$ watch -n 1 nvidia-smi

It will continually update the gpu usage info (every second, you can change the 1 to 2 or the time interval you want the usage info to be updated).

use Ctrl + C to terminate.

method 2: use the open source monitoring program glances with its GPU monitoring plugin

in your terminal, issue the following command to install glances with its GPU monitoring plugin

$ sudo pip install glances[gpu]

to launch it, in your terminal, issue the following command:

 $ sudo glances

Then you should see your GPU usage etc. It also monitors the CPU, disk IO, disk space, network, and a few other things

use Ctrl + C to terminate.

For more commonly used Linux commands, check my other posts at here  and here .

Unzip file from Terminal on Linux

This post provides the instructions about how to unzip a file from terminal on Linux.

Step 1: install unzip using the following command

$ sudo apt-get install unzip

Step2: cd to the directory where you zip file located

Step3:  use  the following command to unzip your file

$ unzip yourfile.zip 

#this will unzip the file to the current folder
#if you'd like to extract to a particular destination folder, use the following instead:
$ unzip yourfile.zip -d destination_folder

For more commonly used Linux commands, check my other posts at here  and here .

Counting files in a Linux directory

This post will show you how to count files under a Linux directory.

Step 1: cd  to the folder you would like to count the files.

Step 2: issue the following command, then you should see a number, which is the number count of the files under the current directory.

find . -type f | wc -l
  • -type f indicates  counting files only.   You can remove the -type f to include directories (and symlinks) while counting.
  • | (note: not ¦) redirects find command’s standard output to wc command’s standard input.
  • wc (stands for word count) counts newlines, words, and bytes on its input (see here for more details.).
  • -l to count just newlines.

Notes:

  • This command may overcount if filenames can contain newline characters.

For more commonly used Linux commands, check my other posts at here  and here .

List files by time (in reverse order) and in human readable file size

This post tells you how to list files under a directory by time in reverser order and in human readable file size (works on Linux OS and Mac).

  • ls -ltrh 

list all the csv files under the current directory in long format by time and in reverse order, the file size in human readable format (e.g., in mb, or gb, instead of byte size)

  • -l List in long format. If the output is to a terminal, a total sum for all the file sizes is output on a line before the long listing.
  • -r Reverse the order of the sort to get reverse lexicographical order or the oldest entries first (or largest files last, if combined with sort by size.
  • -t Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.
  • ls -ltrh *.csv

list all the csv files under the current directory in long format by time and in reverse order, the file size in human readable format (e.g., in mb, or gb, instead of byte size)

 

For more commonly used Linux commands, check my other posts at here  and here .

How to add and use widgets in WordPress

This post introduces how to use widgets in WordPress.

What are Widgets? Why You Need to Use Widgets in WordPress?

Widgets are tiny blocks of specific functionality that you can place in your WordPress sidebars (also known as widget-ready-areas). This is an easy way to add things like galleries, quotes, popular posts, and other dynamic items such as maps on their WordPress site.

Widgets can be found on Appearance » Widgets page in your WordPress admin area.

 

You will see the widgets that you can add under the list of available widgets.

On your right hand, you will find the designated areas on your WordPress site where you can place these widgets. These designated areas are defined by your WordPress theme. They are called sidebars or widget-ready areas.

If you don’t see a specific widget you’re looking for, then it can likely be added with a plugin (more on this later).

Adding Widget to a Sidebar in WordPress

There are multiple ways to add widgets to sidebars available in your WordPress theme.

(1) The easiest one is to simply drag and drop them to your sidebar.

Animation showing how to drag and drop a Widget to a sidebar in WordPress

(2) You can also click on a widget title from the list of available widget. WordPress will show you the list of sidebars where you can add this widget.

Simply select the sidebar where you want to add the widget, and then click on Add widget button to add it.

Add widget button

 

How to Remove a Widget in WordPress?

Removing a widget in WordPress is just as simple as adding them. Visit the Appearance » Widgets page.

Look for the widget that you want to remove in your sidebars and click on the widget title to expand it.

Removing a widget by deleting it from your WordPress sidebar

Below the widget settings, you will find the link to delete the widget. Deleting a widget will remove it from your sidebar and will also delete widget settings like title or any options that you selected.

Some widgets are too simple and don’t have many options in their settings while others have many options and settings. If you would like to remove a widget without losing the settings, then you need to drag and drop it to the inactive widgets section.

Removing a widget without deleting its settings

Deleting or sending a widget to inactive widgets does not remove it from the list of available widgets. You can always add a widget again from the list of available widgets or inactive widgets.

What Kind of Widgets are Available for WordPress?

A default WordPress installation comes with some built-in widgets like recent posts, recent comments, archives, search, etc.

Many WordPress themes and plugins come with their own plugins.

For example, Envira Gallery plugin allows you to create beautiful image galleries in your WordPress posts and pages. But it also comes with an Envira Gallery widget, which you can add to a sidebar to display image galleries in WordPress.

Envira gallery widget

Similarly, countless other themes and plugins add widgets, so their users can add things to their WordPress sidebars without writing any code or html.

There are hundreds of WordPress plugins that just add widgets for you to use in your sidebar. See our list of the 25 most useful WordPress widgets for your site.

 

References

Ubuntu command line check disk usage

To check hard disk usage on Ubuntu from a terminal (command line), issue the following command  in your terminal.

liping:~$ df -h

-h stands for human which makes it readable by us humans, otherwise the file size will be in bytes:)

After you issue the command, you would  see your disk usage similar to the info given below.

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda7              68G   23G   43G  35% /
udev                   10M     0   10M   0% /dev
tmpfs                 800M  1.6M  798M   1% /run
tmpfs                 5.0M     0  5.0M   0% /run/lock
/dev/sda6             264G  173G   78G  69% /home
tmpfs                 3.2G  992K  3.2G   1% /tmp
.
.
.

For more commonly used Linux commands, check my other posts at here  and here .

Some tips for creating a good poster

This post provides some tips for creating a good poster.

(Stay tuned, as I keep updating it.)

Check HERE for creating a Poster with PowerPoint.

  • There is often way too much text in a poster  – there definitely is in this template! Posters primarily are visual presentations; the text should support the graphics. Look critically at the layout. Some poster ‘experts’ suggest that if there is about 20-25% text, 40-45% graphics and 30-40% empty space, you are doing well.
  • Remember the poster session will be crowded so design the poster to be read in columns so people can read what is in front of them and move left to right to get the whole story.
  • The poster should use photos, figures, and tables to tell the story of the study. For clarity, present the information in a sequence that is easy to follow.
  • Include more figures than are in the paper so you can talk to them.  Include things that are not in the paper and then encourage them to read the paper. Don’t try to just put all the paper here.
  • If it looks like a cut/paste of the paper, people skip that poster since they can read the papers after the conference. Many people find it better to spend time talking with poster presenters that have more to offer than just redoing the paper content paper in big fonts.
  • Remember Poster boards look like this.. This is your canvas. Paint us a picture of your work.

  • Leave enough margin for pushpin and remember many big plotters cannot get within .5” of the actual paper edge.
  • You are free to use colored backgrounds and such but they generally reduce readability.
  • You are free to use what ever fonts you like.
      • San Serif fonts like Arial are more readable from a distance,
      • Serif fonts like times may look more consistent with your mathematics
  • TBA

References:

 

 

 

Creating a Poster with PowerPoint

Procedure

Download and edit a poster template (e.g.,  poster template, or HERE, and HERE) or follow the instructions below.

check HERE for some tips of creating a good poster.

  • Start PowerPoint and open “new presentation”
  • From the menu bar, select File > Page setup.
  • In the box that appears, the first section is “size.”
  • Next to the heading “slides sized for,” select “custom” from the pull-down menu
  • Required dimensions are 48” wide by 36” high. Click “OK.”
  • You will see this prompt: “the current page size exceeds the printable area of the paper in the printer.” It will offer three options: cancel, OK, and fix. Click “OK.”
  • Set the slide layout to “blank.” This is done differently in different versions of PowerPoint. If you are having difficulty, type “layout” in the PowerPoint help menu, and you will find instructions on how to create or change slide layouts.
  • You can look at the poster at different sizes. Using a smaller size (e.g. 25%) will allow you to see the whole poster at once. Using a larger size (e.g. 75%) will allow you to read your text more easily.
  • If you find it difficult to keep track of what you are doing, create a second PowerPoint file, with a regular sized PowerPoint slide presentation. You can make a series of slides and then copy the text boxes and pictures from those slides into the custom poster file

 

 

References:

How (and why) to clear the caches on your Mac

Your Mac takes care of routine maintenance behind the scenes eventually, but that doesn’t mean you can’t keep things tidy yourself in the meantime. One easy way to keep your Mac running its best is to occasionally clean the cache.

This post provides brief instructions on how to clean user caches and brower cashes manually, without using an application. For more in-depth caches cleaning, check out the references section below.

  • Clean up user caches manually

To find and clear your user cache manually, do the following:

    • In your Mac’s user folder, there’s a hidden Library folder, which itself contains a folder of caches left by the applications you’ve installed on your Mac.
    • Strongly recommend that you remove the insides of ~/Library/Caches  and   /Library/Caches folders, but not the folders themselves.
    • Want to make sure your junk user cache data is gone forever? – Empty out your Trash.

How to check a cache folder size

If you are unsure and want a safer option, go ahead and learn on how to use CleanMyMac to handle caches properly. It will find up to 5x more junk cache data to remove from all over your system.

 

  • Clean up browser caches manually

We love our browsers but we don’t love it when they start to use up hard disk space with cache files. Whether you’re wanting to free up space, get your browser performing better or trying to remove your history for the sake of privacy, removing your Mac browser cache will help.

Your browser cache is essentially saved bits of the websites you’ve visited recently. That way, if you go back, your computer can re-use locally cached elements that haven’t changed, which speeds up load times versus reloading everything fresh from the remote server. Your cache will overwrite itself eventually, but you can clear your cache, history, and cookies anytime you want to gain a little bit of extra security and speed up your Mac.

      • Clear Safari caches

To delete Safari’s websites’ caches and cookies via browser preferences:

      1. Click Safari in the top menu click Preferences.
      2. In the window that appears, click the Advanced tab, and enable Show Develop menu.
      3. In menu bar go to Develop and choose Empty Caches.

Check and delete Safari browser cache with Terminal:

      1. Press Command + Shift + G to open up the Terminal
      2. With these simple commands you can delete Safari’s cache file. But first, check its size using the disk usage (du) command:
        du -h /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db
        Note: replace “$HOME” with the name of your home folder

        1. To delete Safari’s cache file type:
          rm /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db
          Note: when you use the remove (rm)command files are essentially unrecoverable.
        2. A more prudent approach is to use the move (mv) command:
          mv /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db ~/.Trash/
          This will move the file to your user’s ($HOME) trash. From there it is still recoverable until you empty the trash.
          Safari will create a new Cache.db file automatically when you open a new webpage.
        3. Open a new webpage or restart Safari and recheck disk usage:
          du -h /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db

Clean cache in Safari

      • Clear Chrome caches

The simplest way to clear Chrome browser cache manually is:

      1. In the top right corner of Google Chrome browser click the 3-dot icon to choose Settings. 
      2. At the bottom of the menu, choose Advanced (or use Cmd+Shift+Delete keyboard shortcut)
      3. Click Clear browsing data and deselect all, but Cached images and files. Choose time range and hit Clear data button.

Delete caches in ChromeOne more way to delete Chrome browser cache is to clear some folders where these data located.

      1. To find Chrome cache files, open Finder and click to Go to the folder.
      2. To go to the folder where Chrome’ primary cache locates type: ~/Library/Caches/Google/Chrome/
      3. To go to the folder with the additional bulk of cached data type:~/Library/Application Support/Google/Chrome/Default/Application Cache/
      4. Select files within these folders and delete them.

          • Clear caches in Firefox manually

      1. Click the hamburger icon in the top right corner and choose Preferences.
      2. Choose Privacy & Security on the left sidebar.
      3. Scroll to the section Cookies and Site Data and click to Clear Data… tab
      4. Now, check Cached Web Content  and click Clear button to delete Firefox cache.
      5. Exit/quit all browser windows and re-open the browser.

Clear cache in Firefox

 

 

 

References

The guide to clean all caches on a Mac

There are three types of caches you can clean on your Mac:

    • User (or App) cache. These cache files created by all the apps that you use on Mac. It includes apps that came with your macOS (like Mail) as well as 3rd-party apps (like Sketch). Every applications creates a lots of cache – it wouldn’t be surprising to clear up gigabytes of space when cleaning app caches.
    • System cache. These cache data created by the built-in macOS system services that run your Mac.
    • Browser cache. All browsers store your browsing history and cache data from websites you visit. You know how you shop for something online and then for weeks you’re seeing it everywhere? That’s because your browser caches hundreds of files that make up the websites you visit. Caches also include cookies and trackers that save information about your browsing history and report the data back to the site. This works out in your favor when you return to a site without having to log in again, but it can also leave you feeling like your computer is spying on you.

Old cache files do nothing but cluttering your system and slowing down your Mac through all the wasted space it is taking up.  Here’s a guide to cleaning all these caches, at the end of which your Mac will be lighter and leaner.

Besides browser and website information, your Mac keeps several caches of its own for different reasons. The good news is you can clean them up manually, or you can clean them with a special app which can clear the browser cache in Safari, Chrome, and Firefox, as well as your system cache, email cache, user cache files, and even your DNS cache files.

How to delete user caches on a Mac

User cache makes up the majority of junk data on macOS. Your applications accumulate user’s cache data on a hard disk the longer they are in use. Some apps and utilities can build up cache sizes that reach into gigabytes. This is often just a waste of space, particularly with apps you don’t use every day. By clearing your user apps cache files, you’ll be amazed at how much hard disk space you can reclaim.

Note: Manually clearing cache files on a Mac is something that anyone can do. It takes some time and patience, but if you follow our instructions, you can get the job done all by yourself. Please follow the instructions closely.

Clean up user caches manually

To find and clear your user cache manually, do the following:

    • In your Mac’s user folder, there’s a hidden Library folder, which itself contains a folder of caches left by the applications you’ve installed on your Mac.
    • Strongly recommend that you remove the insides of ~/Library/Caches  and   /Library/Caches folders, but not the folders themselves.
    • Want to make sure your junk user cache data is gone forever? – Empty out your Trash.

How to check a cache folder size

If you are unsure and want a safer option, go ahead and learn on how to use CleanMyMac to handle caches properly. It will find up to 5x more junk cache data to remove from all over your system.

Get rid of cache files with CleanMyMac

    1. Launch CleanMyMac app.
    2. Select System Junk in the left sidebar.
    3. Hit Scan at the bottom of app’s window.
    4. Then click Clean.

Remove system junk

And you’re done! If you’d like to remove only cache files and nothing else, click on Review Details before clicking Clean. Deselect everything but System Cache Files and User Cache Files, then click Clean.

FlushDNS cache

Your Mac’s DNS cache is a list of all the DNS queries that were resolved for every site. When you type in “setapp.com,” the DNS server resolves that to a numerical IP address. But if you notice a site not loading, or your browser acting up or working too slowly, resetting the DNS cache might be the cure.

To flush DNS cache manually

    1. Open Terminal (⇧ Shift++U, and double-click on Terminal)
    2. Type this into Terminal: sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say cache flushed
    3. Press Enter to run and fill your admin password to execute the command.

To clean your Mac’s DNS cache with CleanMyMac

    1. Open CleanMyMac and select Maintenance in the left sidebar
    2. Check the box for Flush DNS Cache
    3. Click the Run button at the bottom of the window

Flush DNS caches

Delete system caches on Mac

System cache files are generated by OS X and, unlike application cache, have nothing to do with the user. The hidden system caches are mainly created by the apps that run on your Mac. The clearing of system cache is not recommended in manual mode, unless you are very careful or trying to fix a problem. System cache files do not generally take up much space, which is another reason why a clean out isn’t as necessary as with user cache.

Clean up system cache data manually

You can find and delete system cache in the same way as user cache, by

    1. Going to ~/Library/Caches and hit Enter to removing the insides of the folders with the app name.
    2. System cache folders are named com.apple and should be backed up for safety.
    3. Go into the com.apple folders and delete the files inside of them. Only the files, not the folders!
    4. Right click on the Trash icon and “Empty Trash”.

That’s it, now, just like with your user cache, your system cache is also clear.

Be careful: not all app cache files can be safely deleted. Some app developers keep important information on cache folders. The great idea to backing up a folder before you erase all files inside. If everything works fine, you can delete this backup.

One-button solution to cleanup macOS caches

CleanMyMac is such a great tool because it lets you perform the exact maintenance you want, or run a Smart Cleanup scan with a single click and have the software make recommendations.

Smart cleanup

Clean up browser caches

We love our browsers but we don’t love it when they start to use up hard disk space with cache files. Whether you’re wanting to free up space, get your browser performing better or trying to remove your history for the sake of privacy, removing your Mac browser cache will help.

Your browser cache is essentially saved bits of the websites you’ve visited recently. That way, if you go back, your computer can re-use locally cached elements that haven’t changed, which speeds up load times versus reloading everything fresh from the remote server. Your cache will overwrite itself eventually, but you can clear your cache, history, and cookies anytime you want to gain a little bit of extra security and speed up your Mac.

Clear Safari caches step-by-step

To delete Safari’s websites’ caches and cookies via browser preferences:

    1. Click Safari in the top menu click Preferences.
    2. In the window that appears, click the Advanced tab, and enable Show Develop menu.
    3. In menu bar go to Develop and choose Empty Caches.

Check and delete Safari browser cache with Terminal:

    1. Press Command + Shift + G to open up the Terminal
    2. With these simple commands you can delete Safari’s cache file. But first, check its size using the disk usage (du) command:
      du -h /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db
      Note: replace “$HOME” with the name of your home folder
  1. To delete Safari’s cache file type:
    rm /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db
    Note: when you use the remove (rm)command files are essentially unrecoverable.
  2. A more prudent approach is to use the move (mv) command:
    mv /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db ~/.Trash/
    This will move the file to your user’s ($HOME) trash. From there it is still recoverable until you empty the trash.
    Safari will create a new Cache.db file automatically when you open a new webpage.
  3. Open a new webpage or restart Safari and recheck disk usage:
    du -h /Users/$HOME/Library/Caches/com.apple.Safari/Cache.db

Clean cache in Safari

That’s all.

Chrome clearing cache tutorial

The simplest way to clear Chrome browser cache manually is:

    1. In the top right corner of Google Chrome browser click the 3-dot icon to choose Settings. 
    2. At the bottom of the menu, choose Advanced (or use Cmd+Shift+Delete keyboard shortcut)
    3. Click Clear browsing data and deselect all, but Cached images and files. Choose time range and hit Clear data button.

Delete caches in ChromeOne more way to delete Chrome browser cache is to clear some folders where these data located.

    1. To find Chrome cache files, open Finder and click to Go to the folder.
    2. To go to the folder where Chrome’ primary cache locates type: ~/Library/Caches/Google/Chrome/
    3. To go to the folder with the additional bulk of cached data type:~/Library/Application Support/Google/Chrome/Default/Application Cache/
    4. Select files within these folders and delete them.

How to delete cache in Firefox manually

    1. Click the hamburger icon in the top right corner and choose Preferences.
    2. Choose Privacy & Security on the left sidebar.
    3. Scroll to the section Cookies and Site Data and click to Clear Data… tab
    4. Now, check Cached Web Content  and click Clear button to delete Firefox cache.
    5. Exit/quit all browser windows and re-open the browser.

Clear cache in Firefox

How to clean all browsers cache data at once

    1. Open CleanMyMac and select Privacy in the left sidebar
    2. Click Scan at the bottom of app’s window
    3. Then Select Items to advance to the next page. The list is broken down by app: you can check each browser to remove all data, such as cookies, browsing history, downloads history, HTML5 local storage, saved passwords, and even close the tabs from your last session. Or you can uncheck any of that you want to keep
    4. Click the Remove button at the bottom of the window when you’re ready to delete everything that’s checked

Cleaning in progress