How to download from Jio only during happy hours (2-5am)

First make sure your PC is awake during that period. Else you’d have to change the option in Task Scheduler to switch on the computer at the time.

1. Add the required files as a queue in Internet Download Manager and change its schedule to 2-5am.
2. To make sure the computer doesnt download Windows updates other than during happy hours, schedule the following:

#Stop Background intelligent transfer service.
NET STOP "wuauserv" 
#Disable the service 
sc config wuauserv start=disabled
netsh wlan disconnect

The above should be started or 5 am or any time if missed. The last line disconnects from Wifi.

Next schedule the following to start at 2am:

netsh wlan connect name="hermes"

Change hermes to whatever is the name of your Wifi (Jiofi/hotspot) device.

And:

#The service must be enabled before it can be started
sc config wuauserv start=auto
#Start the service
NET START "wuauserv" 
#If this doesnt work, enable BITS

Each block of code should be saved in a batch file, and that batch file should be scheduled to start at the appropriate time.

Questions? Ask.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.
A-PDF Preview and Rename

A-PDF Preview and Rename

You’re often faced with a delimma where you get a set of files from somewhere with the filenames not matching the contents. They may be chapters from a book where it would be good if the title matched the chapter name. We’re previously covered a post on A-PDF Rename, a software which can use the PDF Title metadata to batch rename a set of files. But for complex tasks like where the Title metadata has not been set for some files, A-PDF Rename fails. I’d been using Linux script to workaround this for months. Here’s my script to batch rename such files (may need to be tweaked for your file):

#!/bin/bash
if [ "$1" == "" ]
then
    direc="$PWD"
else
        echo $1
        direc="$1"
fi
for file in *pdf
do
  chap=""
  name=""
  chap=`pdf2txt -p 1 "$file" | grep 'CHAPTER' -A3 | sed '2q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//'`
  if [ "$chap" == "" ]
  then        
        name=`pdf2txt -p 1 "$file" 2>/dev/null | sed '3q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//' | sed 's/ \+/ /g' | sed 's/://g' | sed 's/\*//g'`
        newname="$name.pdf"
  else
          name=`pdf2txt -p 1 "$file" | grep 'CHAPTER' -A3 | sed '4q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//' | sed 's/ \+/ /g' | sed 's/://g' | sed 's/\*//g'`
          newname="$chap-$name.pdf"
  fi  
  echo "$file => $newname"
  echo "move \"$file\" \"$newname\"" >> renfile.bat  
done

But if you’re a Windows user, don’t despair. Enter, A-PDF Preview and Rename, a software that can help you draw boxes around text that contains the name of the pdf that you would like, and recognizes it by OCR, and can even use the similiar location to rename multiple files simultaneously. Get it from here.

The steps to do this are included as screenshots below:
Step1: Draw the files into A-PDF Preview and Rename app:

Step 2: Click on a file, and select option “Select text and OCR”. Drag a box with the mouse around the text you want to select.

Step 3. Click on “OCR” option. You will be shown a preview of the new filename. If this is correct, choose the “Batch OCR” option to rename all files. Note that the program is not 100% accurate, and you may still need to manually correct the filenames in some cases. Still, it works great for a lot of files.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Solve wordpress error: exceeds the maximum upload size for this site.

If you tried to upload a big file in WordPress and came across this error “exceeds the maximum upload size for this site”, this is for you.

This has nothing to do with WordPress and is a php.ini resource limit set by the server. If you are in a shared hosting environment with no access to editing php.ini, woe on you. There’s nothing you can do. Get a VPS or dedicated server!

On a VPS or dedi, the first step in fixing the issue is determining which php.ini is the cause of this, as there may be many. For this, create a file with the following content:

<?php
phpinfo();
?>

Name it as phpinfo.php and run it on you site. It will show you the resource limits, and the php.ini file which caused this. Once you locate the correct php.ini, edit it and change the values for these variables: upload_max_filesize and post_max_size. Yes both of them need to be increased.
Save the php file and you’ll notice the changes right away. If not restart the apache (or nginx) server with:

service apache2 restart

Note that on Webmin, each Virtualmin virtual server has a seperate php.ini file. You can edit it at Virtualmin>Services>php5 configuration>Resource limits


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Search gmail by attachment size

Show all attachments greater than 10MB:

has:attachment size:10MB 

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Remove password from protected pdf file

So, my situation was that I wanted to check whether the credit card bill amount I was receiving was valid. I wanted to calculated for myself. The problem was that the pdf credit card statement being sent out by my bank was password and signature protected. It wouldnt allow copying text from it, which is rather weird. I have a genuine need to archive the pdf without password because after a couple of months, who’s going to remember what password it had, especially if you have a couple of different cards, each with its own password schema?

So the first step was to remove the password from it:
Install and run qpdf:

apt-get install qpdf
qpdf -decrypt --password=mypassword /mnt/c/temp/899XXXXXXXXXX32_11-02-2017.PDF /mnt/c/temp/1.pdf

This removes the password. The signature is still intact, but hooray, the pdf now allows copying text from it. I paste the text into my favorite text editor, and use a perl script to calculate for me.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Log and display correct visitor ip when using cloudflare

Logging Real Visitor IP Addresses: mod_cloudflare for Apache httpd
Because Cloudflare acts as a proxy, you will notice changes to the way that your website visitors’ IP addresses are displayed both in your server logs and web applications – notably that all access appears to be coming from Cloudflare IP addresses. You can read more about the reasons for this in our knowledge base article.

You can change this behavior and log & display the actual visitor IP addresses by using mod_cloudflare.

Install mod_cloudflare:
Download appropriate Debian .deb file from https://www.cloudflare.com/technical-resources/#mod_cloudflare
Eg:

wget https://www.cloudflare.com/static/misc/mod_cloudflare/debian/mod_cloudflare-jessie-amd64.latest.deb
dpkg -i mod_cloudflare-jessie-amd64.latest.deb

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting up email with Webmin/Virtualmin

First create a user account (or use a builtin account):
Virtualmin>Edit users:
Add a user:
Email address: [email protected]
POP3 login username is automatically chosen for you. Set the password.
You can test mail sending by logging in at the webmail interface at https://gody.com:20000/?mail

Next add a mail server record:
Webmin>Servers>Bind DNS Servers>
Choose your domain by clicking on it:
Name is the website name typically.
Eg: I want to send mail to [email protected], fill in the following details:
Name gody.com
Mail Server: mail.gody.com
TTL: Default
Priority: 5

Now go to your DNS registrar (Eg Cloudflare) and setup the following records:
Add an MX record.
Name: gody.com
Value: mail.gody.com
TTL 2 minutes

Now test your settings in a POP3 program like Outlook:
Account type: POP3
Incoming mail server: mail.gody.com
Outgoing mail server: mail.gody.com
Username: joel.gody
Password: What you chose.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Remove highlighting and comments from a PDF file

In Acrobat Pro (I’m using Adobe Acrobat Pro DC), Tools>Action wizard>New action>More tools>Execute javascript>Specify settings>Create and edit JS:

Add the following code:

/* Remove Highlighting only */
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
for (var i=annots.length-1; i>=0; i--) {
if (annots[i].type=="Highlight")
annots[i].destroy();
}
}

or if you want to remove both highlighting and comments:

/* Remove Highlighting and Comments */
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
for (var i=annots.length-1; i>=0; i--) {
annots[i].destroy();
}
}

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install nodejs on Debian

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to arrange an A3 sheet with passport size photos with cutting marks

Steps:
Create a Coreldraw (X8 will be used here) .cdr document with the correct dimensions. Here, I’ll be using 18.9×12.4 inches.
Create a rectangle of size 35mmx45mm.
Use the contour tool to insert an inner contour of 2mm
Contour>2mm
Object>Break contour group apart (Ctrl-K)
In Color palette, right click on X for inner rectangle to have no color border
Click on imported pic, Obj>Powerclip>Place inside frame, click on inner frame
Object Powerclip>Edit powerclip
Resize and arrange photo so it the cropped image would fit as necessary
Make a straight line of 6mm, Copy and paste a copy at the same place
Rotate the copy by 90 degree, so that it creates a cross hair.
Group the photo frame back
Make a copy the crosshairs, select them along with the photo frame.
Click on B,R;
Repeat with a copy of crosshairs, select with the photoframe, B, L;
Repeat with a copy of crosshairs, select with the photoframe,T, L
Repeat with a copy of crosshairs, select with the photoframe,T,R
Group the photo with the cutting mark, drag and position
Object>Transformation>Position
Create as many copies as needed to fill the sheet.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.