How to Generate a Page for Each Day of Month in Microsoft Word using VBA
I briefly joined my wife at her practice to help her grow the business and figure out how to make things more efficient. One of the things I learned is that my wife created a sign-in sheet for the office in Microsoft Word. Every week she would open the file and manually enter the date for each day of the week and then print out the documents. I took over the responsibility for a month and it annoyed me due to how inefficient the process was and I decided to automate the entire thing. I couldn’t find a solution to the problem online so I had to roll my own and am sharing the code in case someone else can benefit from it.
Important Details
The script will calculate the first day and last day of the month and then do a loop to append the date in the “Day, Month day, Year” format (i.e. Thursday July 17, 2019) to a text field.
There are a few important steps involved to get the script working as is:
- Create a Word doc with the first page that you want to duplicate.
- Add a text field from the developer tab. To copy and paste the code below as-is, you’ll need to name it txtDate. This is where the date will be added. If you want a different field name, change the name at line 26 and 83. You can also change the date formats to suit your needs here as well.
- Add a second blank page to the document. I was running into issues where the paste was appearing partially on the first. The blank page resolved this and I added code to remove the original page as well as the blank one from the beginning.
How to Use
Open up Word, then open up VBA, and copy and paste this snippet into a module. When you run the function, it’ll create a copy for every day of the month. I also created a function to start at a specific date in case you run it in the middle of the month.
Sub CreateSigninsForMonth()
Dim N As Integer
Dim sCurrentMonth, sCurrentYear As String
Dim sNewDate As String
N = 1
Count = Day(GetLastDayOfMonth)
For CopyNumber = 1 To Count
With Selection
.GoTo wdGoToPage, wdGoToAbsolute, 1
.Bookmarks("\Page").Range.Copy
.Paste
End With
With ActiveSheet
sCurrentMonth = Format(Date, "mmmm")
sCurrentYear = Format(Date, "yyyy")
sNewDate = (CopyNumber & " " & sCurrentMonth & " " & sCurrentYear)
ActiveDocument.FormFields("txtDate").Result = Format(sNewDate, "DDDD MMMM dd, YYYY")
End With
N = N + 1
Next CopyNumber
'Delete template + blank page
For i = 1 To 2
With ActiveDocument
strt = .GoTo(wdGoToPage, wdGoToLast).Start
Set r = .Range(strt - 1, .Range.End)
r.Delete
End With
Next
End Sub
Sub CreateSigninsForMonthStartingDate()
Dim Count As Integer
Dim N As Integer
Dim sCurrentMonth, sCurrentYear As String
Dim sNewDate, sEndDay As String
N = 1
Count = 0
iStartDay = InputBox("Which day do you want to start on?", "Starting Day", "1")
Count = InputBox("Which day do you want to end on?", "Ending Day", Day(GetLastDayOfMonth))
Do While Count > Day(GetLastDayOfMonth)
sEndDay = InputBox("Which day do you want to end on?", "Ending Day", Day(GetLastDayOfMonth))
If iStartDay = vbNullString Or sEndDay = vbNullString Then
MsgBox "You clicked cancel.", vbOKOnly, "Try again later!"
Exit Sub
End If
If IsNumeric(CInt(sEndDay)) Then
Count = CInt(sEndDay)
End If
Loop
For CopyNumber = iStartDay To Count
With Selection
.GoTo wdGoToPage, wdGoToAbsolute, 1
.Bookmarks("\Page").Range.Copy
.Paste
End With
With ActiveSheet
sCurrentMonth = Format(Date, "mmmm")
sCurrentYear = Format(Date, "yyyy")
sNewDate = (CopyNumber & " " & sCurrentMonth & " " & sCurrentYear)
ActiveDocument.FormFields("txtDate").Result = Format(sNewDate, "DDDD MMMM dd, YYYY")
End With
N = N + 1
Next CopyNumber
'Delete template + blank page
For i = 1 To 2
With ActiveDocument
strt = .GoTo(wdGoToPage, wdGoToLast).Start
Set r = .Range(strt - 1, .Range.End)
r.Delete
End With
Next
End Sub
Function GetFirstDayOfMonth(Optional dtmDate As Date = 0) As Date
' Return the first day in the specified month.
If dtmDate = 0 Then
' Use the current date if none was specified
dtmDate = Date
End If
GetFirstDayOfMonth = DateSerial(Year(dtmDate), Month(dtmDate), 1)
End Function
Function GetLastDayOfMonth(Optional dtmDate As Date = 0) As Date
' Return the last day in the specified month.
If dtmDate = 0 Then
' Use the current date if none was specified
dtmDate = Date
End If
GetLastDayOfMonth = DateSerial(Year(dtmDate), Month(dtmDate) + 1, 0)
End Function
Why I’m switching from Namecheap to Cloudflare
Years ago, when the internet was young, I purchased my first domain from InterNIC for about $70 a year. When the alternatives finally popped up, I switched my domain to Godaddy. As prices dropped, I ended up buying more domains through them for ideas and projects I developed. Eventually, I got tired of Godaddy’s shenanigans with pricing (increasing prices and having privacy as an add-on) and upselling everything, and after reviewing many technical forums, ended up switched everything to Namecheap where I even signed up for their shared hosting.
Things started well, but after a short while, the hosting ended up not being any better than Godaddy as all my sites became ridiculously slow as they oversold capacity. I finally made the jump to DigitalOcean, and the same site without any changes or optimizations jumped in performance about 60% based on the metrics reports I was running. No joke, people were pinging me asking what I changed to make my site run so much faster because they wanted to do the same.
I was annoyed that Namecheap refused to refund a partial credit on the hosting even though I wasn’t using it anymore despite their bait and switch caused the performance issues by overselling capacity. In the end, I didn’t fight, because it was cheap, I was beyond the credit card chargeback period, and I still had domains with them and didn’t like any of the other registrars out there enough (nor were the prices better) to make the switch.
On the domain side, their control panel was pretty confusing at first. Godaddy’s was more straight forward for managing DNS and records, so I had to constantly figure out what the Namecheap configuration equivalents were because it wasn’t straight forward. They updated their control panel, and things got easier, but it still wasn’t intuitive. I think a lot of my confusion came from them trying to default to their parking pages or their hosting.
I’d run into issues, and their support would always be good enough to help fix them. I then ran into an issue with setting up a txt record. The fix required them to manually enter the entry on their side due to a bug in their control panel that they still haven’t fixed to date. The bug was serious enough that if I made any changes to any of the domain settings (like adding another A/CNAME/MX record), it would undo their change and I’d have to file another ticket for them to complete the change.
All changes would take hours to propagate. Many of the services that validate DNS changes would not see them for hours or even a day. It hadn’t been a great experience, and now I’ve wanted to find a new registrar to replace Namecheap.
In 2018, CloudFlare announced their registrar service. I’ve patiently watched to see how reliable it is and finally ended up testing it last month with a domain for an existing project that’s in development. To say I was blown away was an understatement. The experience hasn’t been perfect, but the things that really matter are well executed.
I found Namecheap to be a bit deceptive in the transfer process. All other registrars I’ve used let you approve transfers instantly via a link in the notification email. Namecheap sent an email saying they received a request to transfer the domain and this is the text about approving/canceling:
I wanted to expedite the transfer only because I wanted to get the control panel cleared out to find out what’s left and what’s worth keeping and what domains I should let go. I reached out to their chat and learned that they implemented a dark pattern. I never clicked the link because I didn’t want to accidentally cancel an approved transfer as I had assumed it was a direct link to cancel.
It turns out that their support person confirmed the text is deceptive and the link opens a page lets you approve or cancel it:
Not cool Namecheap, but I digress. So let’s look at the pro’s and con’s of CloudFlare which elaborate why I’m switching to them.
Pros
- Price point is cheaper than everyone else since they sell wholesale.
- Transfers are painless.
- Control Panel is intuitive compared to both Namecheap and Godaddy’s. It allows for managing records quicker.
- DNS changes reflect instantly on all the third party domain verification services.
- Cloudflare offers free SSL on the domain level.
- Support responded in a few hours to an issue I had.
Cons
- Can’t register new domains directly at Cloudflare which requires purchasing a domain somewhere else and then waiting 60 days to transfer.
- Doesn’t support all the TLD domains yet.
- Can’t create custom nameservers without paying $200 a month, which was free with godaddy and namecheap.
Not bad for a cons list, so I migrated most of my domains over to Cloudflare, and it’s a win all the way around. They sell domains at cost, offer a ridiculously easy to use control panel where everything works. Even better are how quickly changes take effect, and third party services can validate the changes.
Why the Drobopro-FS Pro sucks
A few years ago, I purchased a DroboPro-FS Pro 8 bay NAS system. After getting a demo from one of my vendors, I was sold on the ability to have different sized hard drives, hot swapping, and the self repairing file system. Another feature I liked was that it also monitors the health of my hard drives. If one starts developing issues or gets full, Drobo will warn me, and robotically shift my data to other drives until I can replace that drive. I did my research and at the time, it looked like a fantastic deal.
After a few years with it, I can readily admit I made a huge mistake in purchasing the product. I’m lucky in that the unit has not failed yet like it has for others but it’s also a horrible choice for backups for a myriad of reasons.
- IT LOSES DATA: My Drobo mysteriously loses data after it reboots. I’ve noticed this a few times after I’ve come home from vacation and turned off the unit to save power. Files (entire gigs of them) I haven’t accessed in months are mysteriously gone. Because it’s a custom file system, I have no way of trying to recover anything. I’ve confirmed this actually happens by running a disk catalog before shutting down and then running a report on the compare which shows files are definitely missing. I’ve done this 4 times and have verified it happened 4 times now. Missing file range from a few to hundreds and they vary in size so there’s no discernable pattern.
- Vendor Lock-in: You can’t access any of the files without a Drobo due to the custom file system. If the unit fails, you lose everything unless you buy another unit.Â
- Terrible Support: Support is lackluster. The warranty is one year and then you’re on your own which is not exactly confidence building.Â
- Weird Custom Desktop App: The Drobo dashboard is terrible and should have been a web interface like the other NAS options on the market. The dashboard is an app that runs in the background to connect to the shares and manage permissions, which every OS can do natively. Even worse, the dashboard app supposedly connects to the Drobo through port 5000 and then broadcasts over a randomized port which requires custom firewall permissions if it doesn’t support app level permissions. There’s no reason for the app to exist let alone broadcast anything.
- Doesn’t Deliver on Core Features: One of the features of the Drobo that sold me on it was that it should notify you when a drive is failing. In reality, the Drobo did not actually notify me about failing drives until it was too late and the drive failed completely and it didn’t move any of the data to other drives.
- Apps: Non-existent. They released some basic app support by doing a weird workaround by creating a directory and adding the app files to it but then it suddenly disappeared from the Drobo website. A third party site came up to mirror the lost apps but at this point it’s not even worth the effort to me. Droboapps was an extremely limited offering and afterthought. They actually removed support for apps from the Drobo because they didn’t want to deal with supporting users.
- Remote File Access – Doesn’t exist natively.
Compared to Synology DS1918+
I purchased a Synology DS1918+ 8-Bay Drive and the differences are pretty stark. I’ve actually been moving important files from my Drobo over to it as a safeguard.
- No data loss: Thus far, no data has been lost on the Synology.
- Apps: The apps support on Synology is incredible. I use a bunch (Plex, Photos, Backups, and many others) but the one I love most is Synology Drive, which works as a replacement for DropBox.
- Web Interface: The Synology web interface is extremely intuitive and easy to work with. There’s options for power users to make the NAS even more useful. I love that there’s no custom app to run in the background on my desktop. Connecting to shares is as simple as using the network shares native to the OS.
- Permissions/Security: The Synology permissions can be extremely granular, and includes support for roles/groups + users.
- Sharing: Synology offers an easy way to share files over the internet with permissions, like Dropbox does. The only difference is you aren’t limited to file size restrictions. Drobo does not.
- Remote Connect: Synology offers a browser based remote connect solution they call Quick Connect. Once you configure your Synology for remote access (it even configured my firewall permissions), you can access it via the quickconnect URL. No jumping through hoops for setup or access, and it just works. Good luck with setting this up with the Drobo, as I haven’t figured it out.
How to Get Laravel Debugging to work with PHPStorm and MAMP Pro 5
This has been one of the more aggravating things I’ve had to deal with in setting up software for development. I’ve followed the official documentation from JetBrains, over 30 other blog tutorials, and literally failed in getting any of them to work.
I figured out an easy way to make the setup work so I’m sharing it in case someone else finds it useful and for self-reference since I’ll probably forget how to do this again in 6 months when I start a new project.
MAMP Configuration
- Load MAMP and setup your host. Make note of the host name as you will need it to configure PHPStorm.
- Go to PHP on the left under Languages.
- On the right under Extensions, check Xdebug (Debugger).
PHPStorm Configuration
- Load PHPStorm and load your Laravel project.
- Setup your PHP executable and interpreter as per the official documentation and then resume here.
- On the top right of PHPStorm, select Edit Configurations from the dropdown.
- Click on the Plus Button on the top left of the dialog and then select ‘PHP Web Page’.
- Enter a descriptive name in the textbox. I use the host name from MAMP so it’s easy to identify visually. Click on the 3 dots with next to Server.
- Enter a descriptive name. I use the host name here as well. For the host, omit the http/https and just add the host name from MAMP.
- Click OK
- Now add your breakpoints and click on the Debugger Button on the top right and PHPStorm will load the site into the browser and break when breakpoints are hit.
Happy debugging!
How to Automate Sending Emails through Outlook interop using C#
I was tasked with a tricky issue in sending emails. Due to security concerns, the client’s IT team was not willing to share SMTP information for their mail settings and was only willing to set up an account in Outlook directly on a dedicated machine without sharing the password with us to send the emails. The client’s ask was to send emails through Outlook without letting users see the emails or Outlook itself.
Installing Office Interop for Outlook
Sending emails through Outlook can be done using Microsoft.Office.Interop.Outlook but the documentation is really lacking. If you need to do the same, I hope this will save you the hours of time it took me to figure out what ends up not being complex code.
Create a new desktop application project in Visual Studio. Install the Microsoft Office Interop for Outlook. I used the NuGet package manager to install it since it wasn’t present on my system:
Install-Package Microsoft.Office.Interop.Outlook
Automating E-mails using C#
I created a static class to send the email through Outlook. Note that my error handling code was replaced with Debug.Writeline. Remember to modify it to handle errors or implement logging so it doesn’t fail silently.
Email.cs:
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Outlook;
using Exception = System.Exception;
namespace Email.classes
{
public class Email
{
public static void SendWithEmbeddedImages(string to, string subject, string htmlMessage)
{
var missing = Type.Missing;
Application oOutlook = null;
NameSpace oNS = null;
Folder oCtFolder = null;
Items oCts = null;
MailItem msg = null;
var sHeaderPath = Path.Combine(Environment.CurrentDirectory, "emails", "header.jpg");
var sLogoPath = Path.Combine(Environment.CurrentDirectory, "emails", "logo.jpg");
try
{
// Create an Outlook application.
oOutlook = new Application();
// Get the namespace.
oNS = oOutlook.GetNamespace("MAPI");
//Assumes MAPI profile name is Outlook
oNS.Logon("Outlook", missing, false, true);
msg = (MailItem) oOutlook.CreateItem(OlItemType.olMailItem);
var attachHeader = msg.Attachments.Add(sHeaderPath, OlAttachmentType.olEmbeddeditem);
var attachLogo = msg.Attachments.Add(sLogoPath, OlAttachmentType.olEmbeddeditem);
attachLogo.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "logo");
attachHeader.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E",
"header");
msg.Subject = subject;
msg.To = to;
msg.BodyFormat = OlBodyFormat.olFormatHTML;
msg.HTMLBody = htmlMessage;
//Show email
msg.Display();
//Send email
//((Outlook._MailItem)msg).Send();
oNS.Logoff();
}
catch (Exception ex)
{
Debug.WriteLine("Automate Outlook throws the error: {0}", ex.Message);
}
finally
{
// Manually clean up the explicit unmanaged Outlook COM resources by
// calling Marshal.FinalReleaseComObject on all accessor objects.
// See http://support.microsoft.com/kb/317109.
if (msg != null)
{
Marshal.FinalReleaseComObject(msg);
msg = null;
}
if (oCts != null)
{
Marshal.FinalReleaseComObject(oCts);
oCts = null;
}
if (oCtFolder != null)
{
Marshal.FinalReleaseComObject(oCtFolder);
oCtFolder = null;
}
if (oNS != null)
{
Marshal.FinalReleaseComObject(oNS);
oNS = null;
}
if (oOutlook != null)
{
Marshal.FinalReleaseComObject(oOutlook);
oOutlook = null;
}
}
}
}
}
Example on how to call the class:
var sEmailPath = Path.Combine(Environment.CurrentDirectory, "emails", "single.html");
var htmlMessage = "";
if (File.Exists(sEmailPath))
{
//Load HTML from file
htmlMessage = File.ReadAllText(sEmailPath);
}
Email.SendWithEmbeddedImages("toaddress@test.com", "Outlook Automation Test", htmlMessage);
email.html:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
</head>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="cid:header"></td>
</tr>
<tr>
<td>
Hello world!
</td>
</tr>
<tr>
<td><img src="cid:logo"></td>
</tr>
</table>
</body>
</html>
Important Notes and Gotchas
- CIDs need to be unique. I’ve seen them on all other posts with the format “file.extension@{random #}” but keeping it simple like in the code above worked for me with no issues with Outlook 2016. I did not test on older versions of Outlook to confirm as I no longer have access to them.
- Outlook ignores font rules in the HTML/CSS you code in the email and defaults to Times New Roman. I know Outlook uses the Word renderer but I have no idea why and the only solution I found was to update the default font in Microsoft Word. Yes, to change the font in Outlook, you’ll need to update the default font in Word. Here’s how to set it:
- Open Word
Go to Options -> Advanced -> Web Options
Change the default font in the Fonts tab
- Open Word
- Outlook only supports a subset of HTML so don’t forget to test and verify everything as most CSS formatting won’t work in Outlook.
How to Extract Text from image using Laravel and Amazon Rekognition API
I’m currently working on a project that requires extracting text from images of variable quality. I’m doing quick prototypes using PHP and Laravel, but I’ve found the documentation for accomplishing this a bit lacking. After working on it for a bit, I figured out a really simple solution and am sharing in case it helps anyone else.
This sample will send the image to the API as a blob instead of using a URL. I had tried Base64 encoding it without any luck. I discovered that using Imagick was the easiest way to make this work so the sample relies on that.
Fire up terminal and add a requirement for aws/aws-sdk-php:
composer require aws/aws-sdk-php
Add keys for your AWS access keys and region to your .ENV file:
AWS_REGION=YOUR_REGION
AWS_SECRET_ACCESS_KEY=ENTER_YOUR_KEY
AWS_ACCESS_KEY_ID=ENTER_YOUR_KEY
Create a controller, add the snippet below, and create a route to the controller. Check the URL and you should have a dump showing the array returned from AWS with all the text, bounding boxes, and information.
//Build config array for AWS variables
$config = array(
'region' => env('AWS_REGION'),
'version' => 'latest',
'credentials' => array(
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET')
)
);
//Replace with path to image or uploaded image.
$path = '{path to image.jpg}';
$image = new Imagick($path);
$imdata = $image->getImageBlob();
$client = new RekognitionClient($config);
$result = $client->detectText([
'Image' => ['Bytes' => $imdata],
]);
//Dump Result
dd($result);
How to Execute a Stored Procedure in Laravel 5.6
I’ve been stumped on this and tried everything I can think of but I can’t get Laravel to execute a working mysql query to reorder an ordering column when deleting a row.
Here’s a sample simplified query, which works directly in mysql:
SET @number = 3; UPDATE images SET order = (@number := @number + 1) WHERE id >2 AND project_id = 10
Laravel code that doesn’t update the database but throws no errors:
$sql = 'SET @number = 3; UPDATE images SET order = (@number := @number + 1) WHERE id >2 AND project_id = 10';
DB::raw($sql);
Other things I’ve tried which throw errors including saying there’s an error in the query:
DB::unprepared($sql);
DB::statement(DB::raw($sql);
DB::statement($sql);
DB::update($sql);
DB::select($sql);
I’ve also tried splitting it the statements with no luck:
DB::statement("SET @number = 3;");
$sql = 'UPDATE images SET order = (@number := @number + 1) WHERE id >2016 AND project_id = 10';
$update = DB::update($sql);
I tried a few other things which I didn’t log in Git but I had no luck getting any of it to work. I asked for help on the forums and people told me to use Laravel’s Eloquent model to update rows one by one which is pretty inefficient. You get extra trips over the network (especially important when the code is not on the same server as the database server since you can get dropped calls), extra connections to the server, the extra overhead of processing the query on the server and in the database, etc instead of just having mysql make the update.
The recommended solution may not seem like a big deal but I’ve run into issues where client connections have been dropped mid-update and left a table partially renumbered.
As a last resort and workaround, I opted to use a stored procedure to accomplish my goal. That presented its own can of worms as searching for examples on how to execute stored procedures in Laravel 5.x was also not easy. There’s nothing in the documentation and all the examples I found didn’t work.
Here’s what worked for me with Laravel 5.6, with mySQL 5.6.38:
DB::statement('call spRenumberComments(?, ?)', [$id, $projectid);
Self-signed SSL certificates not working with MAMP and Chrome
I use MAMP Pro for most of my PHP development and Chrome has annoyingly been blocking the self-signed SSL certificates MAMP generates, saying the certificate is not valid and “Your connection is not private”:
Thankfully, I found an easy solve to fix this. These steps assume you’ve created a host in MAMP. You’ll need to go to the SSL tab of the host you are trying to fix and
- Check the SSL button
- Click the self-signed certificate button.
- Fill in the fields in the dialog modal and click Generate
- You’ll be prompted to save the certificate. Choose whatever location you’d like.
- Click on the circle with the arrow to open the directory where the certificate was saved.
- In the finder window that opens, double click the .crt file (be sure it’s the same file name that’s in the SSL window in case you have multiple).
- In the Add Certificate window, click Add. I testing adding it to login and system and both worked, so add whichever you prefer.
- In the Certificates Window, double click the certificate. It’s easier to filter by name if you have a lot of items.
- In the next modal window, choose Always Trust from the dropdown.
- Close out the next confirmation window, and you’ll be prompted to authenticate with your mac login to save the updates.
Go back to Chrome, and reload the page and the certificate should work now:
How to get shape type in Visio using VBA?
I’m working with a Visio 2016 file with over 100 tabs and need to extract the data (mainly text, connector from/to, and shape) for data processing for a processing engine. I was trying to figure out how to get the shape type name in Visio using VBA. For example, in a flowchart, I’m trying to figure out how to tell if a shape is a process, decision, data, etc. The
visShape.Type
property seems to always return 3 which appears to be visTypeShape from https://docs.microsoft.com/en-us/office/vba/api/visio.visshapetypes. After hunting through all the available properties on the Shape object, I found that the shape.Master.Name property will return the shape name, but you need to check if it’s Nothing first in case it’s not a shape.
I didn’t do that and it kept breaking the script originally because some of the pages had text fields and the first few items on the first sheet I was working with were text boxes. Hopefully this snippet will save you the time I wasted figuring it out.
Public Sub GetShapeAndID()
Dim visShape As Shape
For Each visShape In ActivePage.Shapes
If Not visShape.Master Is Nothing Then
Debug.Print visShape.ID & " - " & visShape.Master.Name
End If
Next
End Sub
How to get website average latency in BASH
I was working on a project today and wanted to be able to get the average latency for an API that I was working on. Performance is a concern because we’re running the API over a VPN, and then SSH tunneling over to another server. I wanted a quick way to do it and wrote a little bash function that will calculate the average for me. I couldn’t find an example on how to do this online so I’m sharing in case anyone else runs into the same issue.
This is tested on Mac only. Add these two functions to your .bashrc and do a shellupdate in terminal to load the latest, or just grab my dotfiles from my github: https://github.com/gregvarghese/dotfiles
curlb(){
curl -s -o /dev/null -w '%{time_starttransfer}\n' "$@"
}
# Usage:
# latencyavg [# of times to run] [URL]
function latencyavg()
{
time=0.00
for (( c=1; c<=$1; c++ ))
do
num1=$(curlb $2 -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,ja;q=0.6' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36' -H 'Connection: keep-alive' --compressed)
echo "$c - $num1"
time=$(echo "$time + $num1" | bc -l)
done
echo "Total Time $time"
echo $(echo $time / $1 | bc -l)
}
Usage example:
latencyavg 20 https://www.godaddy.com