How to set off an Alarm on Macbook when the battery is full?

If you’re one of those people who keep their laptop on charging and get busy doing other stuff IRL then you’ll like this post.

In this post, I’ll be sharing a tip which will help you set off an alarm on your Macbook as soon as the battery is full.

The idea here is to add a command to the Crontab file. Crontab is basically a list of commands that you want to run on a regular schedule.

To add a command to Crontab, open the terminal, type the following command and press enter.

crontab -e

Press ‘i’ key on the keyboard to edit the file and enter this command in the file –

*/1 * * * * python /Users/USERNAME/battery.py

The number 1 in the command above represents an interval of 1 minute. So the python script located in that respective directory will be run every 1 minute.

Exit the edit mode by pressing the escape key. Save the file by pressing SHIFT+Z twice.


Now create a python file called battery.py with the following script. Also, make sure to keep it in the right directory which you mentioned before in the crontab.

 import subprocess
import webbrowser

battery_info = 'pmset -g batt'
battery_info_output = subprocess.check_output(battery_info, shell=True)

if "charged" in battery_info_output:
 webbrowser.open("file:///Users/omkarbhagat/scripts/play.mp3")

And also make sure to change the last line to locate a music file on your computer.

That’s all. With this setup, the script will run every 1 minute and the music file will run once the battery is full. 🙂

How to connect to a Wireless Printer?

I have HP Deskjet 2540 printer. It’s a wireless printer. And when I got this one, I had no idea about how to configure a wireless printer.

I guess most people will have no idea about it like I didn’t. So I’ll write this post to make it easy for people looking for answers.

Before I start, note that I’m not an expert on Wireless printers, I’ve no idea about every kind of wireless printer. But I’m pretty sure this tutorial will work for most wireless printers out there. So let’s start!

Most of the wireless printing happens by connecting your printer and your computer to the same WiFi network. So the only thing you actually need to do is connect your printer to the WiFi network.

To connect your printer to the WiFi network, you’d need to configure your printer by selecting the network and entering the WiFi password. But you can’t do that if your printer doesn’t have a keypad, right?

So you’ll need a cable to connect your computer to the printer and then you’d be able to configure it. Plus you’d need the right software (usually found on the printer’s website). For my printer, I use something called HP Utilities.

Long story short (TL;DR)

Connect your printer to your computer using a cable. Download the drivers/utility software. Open it and configure your printer to connect to the WiFi network. Once that’s done, just go ahead and print a test page.

The only part which sucks about this whole thing is that you ‘need’ a wire (cable) before you can go wireless!

Unlock iPhone without having to press the Home button (iOS 10 update)

I just installed the latest iOS 10 update on my iPhone. It’s pretty cool except for one thing. I have to press the home button to unlock my iPhone.

I hate it. I know my friends hate it. And I’d like to disable that feature and go back to how things were before this ‘iOS 10 update’.

If you feel the same, this is how you can unlock your iPhone by just resting your finger on the home button (as you used to do before this update) –

Go to Settings > General > Accessibility > Home > Toggle ‘Rest Finger to Open’ option!

And you’re back to unlocking the phone without having to press the home button. Enjoy 🙂

How to transfer music to iPhone via iTunes?

Transferring music to iPhone can be confusing if you’re coming from Android or Windows. But it’s not that hard if you get the basics clear.

There are two music libraries which you should keep in mind, one is iTunes music library on your computer and another one is iTunes music library on your iPhone.

  1. iTunes library on Computer – called Songs
  2. iTunes library on Mobile (iPhone) – called Music (Devices > Your iPhone > Music)
screenshot-2016-10-12-18-57-51

Notice the  ‘Songs’ and the ‘Music’ option in this screenshot

The idea (in short) is to connect your iPhone to the computer. Open iTunes. Enable Music Sync for the connected iPhone.

Move (drag/drop) music files in Songs. Click on Sync and done. The music files will appear in Devices > Your iPhone > Music. And of course they’ll also appear in your iPhone.

If that’s confusing, here’s a step by step explanation of the same – Continue reading

How to install WordPress on localhost using XAMPP?

This is the WordPress beginner stuff that every WP developer must know. You can say this is probably the very first step in the journey of WordPress development.

Because once you know how to run WordPress on localhost (on your computer), you can do all the customization that you want to do. You can develop themes, plugins, etc. You will basically get access to edit each and every file in the WordPress directory.

Note that this tutorial is for Mac OS X users. If you’re on Windows, you should search for “How to install WordPress on Windows?”

  1. Download XAMPP
  2. Download WordPress and extract it (wordpress folder appears)
  3. Install XAMPP
  4. Copy (CMD+C) wordpress folder
  5. Open Finder > Click on Go Menu > Applications > XAMPP > htdocs
  6. Paste (CMD+OPT+V) WordPress folder in htdocs
  7. Run XAMPP (Applications > XAMPP > manager-osx)
  8. Click on Manager Servers tab and hit start all
  9. A dialog box appears – do you want to accept incoming connections? Click on allow
  10. Open web browser and type localhost/wordpress in the address bar
  11. Hit enter
  12. WordPress installation screen appears 🙂

Once you complete WP installation, you will be directed to the front page of the site. That’s how you get WP running on localhost! 🙂


WordPress installation documentation can be found here. And if you run into permission issues on Mac OS X, then this post can help you! 😀

How to delete all the Emails from Gmail’s promotions tab

I wanted to delete all the emails from Gmail’s promotions tab and I was doing it wrong the whole time. And no, I wasn’t deleting my emails one by one! 😛

You know the Gmail page by default shows a list of 50 emails. And it says 1-50 of X are shown on the current page. You can navigate between pages to see a list of 50-100 emails and so on.

I used to select all the emails on one page and delete them. Then I’d select all the emails on the second page and delete them. That’s fine if you’ve like 100-200 emails. But if you have to delete thousands of them then it becomes monotonous.

Then I discovered that it’s actually possible to delete all the emails in a particular tab instead of deleting them page by page.

All you have to do is select all the emails in a particular tab (like the promotions tab). Then you’ll see something like this appears on screen –

All 50 conversations on this page are selected. Select all 83 conversations in Promotions

Now you have to click on “select all” and all the conversations will get selected in that respective tab. And then, of course, you can delete them! 🙂