Disk Usage

“What happened to all my disk space!”

It can be amazing how quickly all your disk’s capacity gets filled up with random files and forgotten downloads. Here are a few commands to point you towards some of the culprits clogging up your file system.

This command will list the largest 10 objects in the current directory.

sudo du -a . | sort -n -r | head -n 10

Here’s the breakdown of the command: du is a utility on mac and linux that can list disk usage of directories and files. The -a option specifies du to list all (both files and directories). The period stands for the current directory (so you could change this to any directory you want to examine that folder’s disk usage). The sudo command executes the following command (du) as the root user so that you will be able to read all the files and folders on the system.

The pipe character ( | ) captures the output of the command to its left and makes it the input to the command on the right. So the output of du gets piped into sort, which sorts lists of things. The -n and -r flags direct it to sort the list like they are numbers (since we are giving the file sizes, they are numbers) and to sort in reverse order. We then pipe the output of the sort into the head command. head will display only the first few lines of input. We specify how many lines to read by passing the -n flag followed by the number of lines to read: 10, because we want to see only the 10 largest files.

The Five Stages of Being Hacked

  1. I could never be hacked.

  2. I hate that I was hacked.

  3. Please let the hack go away.

  4. I’m sad that I was hacked.

  5. I accept that I have to fix this hack.

If you’re still on stage one, consider this: 88% of websites contain a serious vulnerability (Urgent, Critical, or High) and 13% of sites can be compromised automatically. [1] That means the hacker doesn’t even have to look at your website to exploit it. To some people these statistics are shocking. To many though, they think “My website isn’t that valuable. Why would anyone spend time hacking into my website?” Well, you may not see the value of your website, but a hacker sees a goldmine. One man’s trash is another man’s treasure I guess. They see another IP that they can use in launching DDoS or Brute Force attacks. They see processing power they don’t have to pay for to crack passwords or even mine BitCoin. They also see a domain name to send spam from. They see an anonymous location to host their phishing attempts, luring all your customers’ into stealing their data! Your little place on the web is more valuable than you knew. That is why it is so important for everyone to keep their websites secure. Unfortunately security has been difficult and confusing to set up correctly. That is why we recommend using (and use ourselves) services and software like Wordfence for WordPress installations and Securi. It’s also why you should not be afraid to pay for premium hosting or to hire trusted, experienced developers, just like you shouldn’t be afraid to pay for a good construction contractor. Cutting corners can lead to your house falling in on your head.


Welcome to CLI Magic!

The command line is a seriously powerful place, but it can be a bit like arcane magic trying to divine the right incantation of flags and commands.

This will be a series of short posts that give one or two commands that do something really cool or powerful in a condensed form, with a short explanation of what they do. They might be useful or just fun. The commands here will be primarily for Bash on Mac/Linux but can usually be adapted for most *nix environments.

Let’s begin with a command I used the other day. This is useful if you want to view a file kept on a remote computer using your favorite text editor on your mac (without depending on any X window nonsense)

ssh user@server.name "cat /absolute/path/to/file" | open -fa "/Applications/Example.app"

For example I opened a wordpress theme php file with sublime text to debug the website

ssh root@ourserverat.eclarian.com "cat /example/wp-content/themes/MyTheme/template-home.php" | open -fa "/Applications/Sublime Text.app"

(And no that is not the real name of our servers)

Neural Networks

There’s a lot of buzz going around about “Deep Learning”, “AI”, and “Neural Networks”.

But what do those words even mean?

A Neural Network is essentially a model of how neurons in a human’s brain might work. By using a few sets of simple mathematical models connected together in a simple structure, we are able to model extremely complex systems. Like the game of Go, or to recognize hand written text in pictures.

Computerphile has made an excellent series of videos that explains a certain type of Neural Network, a Convolutional Neural Network. You can watch them below:

(The first three videos don’t explicit talk about neural networks but they are important precursors to the last two videos)


Go from WordPress Beginner to Pro!

WordPress is the most popular website content management system and blogging software available today. It now powers 25% of all websites on the internet!

WPMU DEV is a resource where you can get tools and support to make great WordPress websites. The team at Eclarian found that staying instep with WPMU DEV helps us solve pretty much any WordPress issue that arrises!

Here’s a link to an article from the latest WPMU DEV newsletter. It has something for every WordPress developer, no matter if you’re a WP-new born or an advanced, plugin-building, theme-creating WP-master!



Batch Resize Images from Command Line

Quick tip if you need to batch resize a number of photos from the command line:

Step #1: Install ImageMagick

Step #2: Run the following script, replacing the brackets with the actual paths. This will resize to 1024px wide and auto-resize the height in ratio.

mogrify -resize 1024 -quality 100 -path [full path to new file folder] [path to photos to resize]    

Here is an example of the full script:

mogrify -resize 1024 -quality 100 -path /home/user/resized /home/user/original/*.jpg