Friday, April 7, 2017

PHP to prune a Google calendar feed of unwanted events

Here is a little PHP script that I developed to prune unneeded events from a Google calendar feed.

// Set header for calendar and give it a filename
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=modified_calendar_feed.ics');
 
// Download the calendar feed we need into a variable
$ics = file_get_contents('https://calendar.google.com/calendar/ical/
targetaccountnamehere%40gmail.com/public/basic.ics'); 
// Remove the useless header info (if this is not done, other Google accounts will not be able to add the URL)
preg_match('/PRODID.+?END:VTIMEZONE../s',$ics,$tz);
$ics = str_replace($tz,"",$ics);
 
// Grab the events and dump them into an array
preg_match_all('/BEGIN:VEVENT.+?END:VEVENT../s',$ics,$events);
 
// Step threw the events and remove any that don't contain the keyword/phrase from the feed
foreach ($events[0] as $event) {
if (!stripos($event,"
keyword/phrase the event must have if it is to stay in the feed")) {
$ics = str_replace($event,"",$ics);
}
}
 
// Send the modified calendar feed to the requesting device
echo "$ics";
 
// Destroy the variables before leaving
unset($ics,$events,$event)

Monday, March 6, 2017

HoSafe... You said what now?

In July of 2016, after months of issues with neighbors, I broke down and purchased an IP Camera from Amazon.com (HoSafe Camera Amazon Link). Now, to be totally fair, this was the cheapest IP Camera that met my criteria. Setting aside the absolutely hilarious name, the HoSafe 1MB6P met all of my requirements. My criteria were as follows:

  1. It must have POE capability.
  2. It must be able to live outdoors.
  3. It must have night vision with built in illumination.
  4. It must be at least 720p.
  5. It must be ONVIF compatible.
  6. It must be cheap.

POE

Power over Ethernet is very important. I'd rather run a ethernet cable from my network board the attic to a camera than run AC power. You see, a standard ethernet cable has 4 pairs of wires, only 2 of which are used for communication. The others are left unused in almost all instances. So, how do we use this to our advantage? Well, we run 48v across the other pair, of course. The POE camera steps down that 48v to use for powering the unit. So, one cable for both communication and power!

Outdoor

Well, this is kind of self explanatory. But, I wanted to mount the camera on the front of my house to catch the comings and going of my neighbors walking dogs. (Your dog. Your pooh. Take it with you.)

Night Vision

The chip inside security cameras that sense the light and, in the case of IP cameras digitize it, is sensitive to infrared light. That's right! The very light that we use to control our TV, DVD, etc. So, how do we record in dark or low light without mounting big flood lights? Well, we make sure the IP camera has IR lighting built in, of course. This light isn't good for huge distances, but I rolled the dice and ignored the advertised distance of the HoSafe.

720p

Any more, the "P" is mostly irrelevant. That is, the "P" (progressive) should really be assumed. What it means to us is there the image is divided into 720 lines. The more lines, the more detail. Also, when the number of lines goes up the number of pixels (single dot of the line) goes up too. So, this means more detail. In general, the larger the area you are covering, the more pixels necessary to be able to make things out in the video or images.

ONVIF

This is a tricky business. ONVIF is a lot of things. However, for my purposes the only thing that matters is the cameras ability to respond to ONVIF compliant requests for how to make a streaming video connection. This protocol (language) makes it easier for applications on a PC or recording devices to connect to the camera without a lot of technical knowledge required of the user. Now, I'm not allergic to technical specs and setup. However, cheap cameras (and some expensive ones) are notorious for not providing this type of information. So, ONVIF compatibility can reduce the time it takes to get things up and running.

CHEAP!

This unit was $39.99 on Amazon Prime (Free 2 Day Shipping!!!) at the time of the order. This was an excellent price for a unit that was 3 Stars+ at the time.

The Unit Arrives!

This unit came in DOA. It simply would not power up. This was very disappointing. However, upon close physical examination I found the issue to be a slice in the data/power cable attached to the camera. So, I returned it to Amazon as DOA for a refund and reordered another unit. Same model, same seller, Amazon Prime. I saw no reason, at this point to penalize anyone for the error. It could have been missed by the manufacturer. It could have been damaged by a botched installation and returned to Amazon. However, I decided to try again.

The Second Unit Arrives!

This camera was fine. It powered right up! Now, for the fun part!

The Configuration

Before we delve into the config. A little background. I don't like ladders. I don't like spending time on them. I don't like going up and down them when it can be avoided. So, when it comes to device installation that requires my using a ladder. I do all the configuration possible on the ground, usually at my desk, prior to mounting any equipment.

So, from my desk, I connected the HoSafe camera and it powered up. Cool! Now we can start the fun stuff. Being an IP camera veteran, with many installs of everything from FOSCAM to Panasonic cameras under my belt, I did what I always do. I jumped right in and started looking for the camera on the network so I could login to the web page to configure it. 

Uh... Yeah... and NO! That's a big negative, sir! 

This camera doesn't work like that and I wasted a nontrivial amount of time only to find this out. So, it really does pay to read the instructions sometimes. BLAST!

Anyway, once I reviewed the literature, such that it was, I discovered that the application that records the video also configures the camera. So, I installed the provided CMS application and configured the camera. It went smoothly enough, once I was on the right track.

The Installation

The camera came with everything necessary to mount and connect the camera (except the RJ45 connector, but I didn't expect this and neither should you) including weather proofing for the network connection. This is a big score! Not all manufacturers include this in the design, rather expecting the camera to be mounted to a weather proof electrical box, in which all connectors are contained.

The installation was simple and obvious. No instructions needed here! It went up quick with the provided materials and with no fuss.

The PC Software

The CMS software provided is ok. It's only ok. It's not awesome or astounding or even amazing for the price. It's just OK. It's rather like all cheap DVR/NVR software. It hits and misses, and is almost always lacking in an area that is important to the user. So, after playing with it for a few days, it had to go.

The Apps

The iOS and Android apps available specifically for the HoSafe are another story. They are... well, interesting. Like the CMS software, they didn't really work the way I thought they should. However, they did (and still do) work for what I wanted. I wanted to see my camera view from anywhere I have internet and these apps to exactly that. No muss, no fuss, and very little configuration, and absolutely no router port forwarding!

What?! No port forwarding? But how?!

Well, these units connect to a central server on the internet (probably in China). The apps connect to the same server. So, no need to do port forwarding (that can get incredibly tedious with multiple cameras). 

The down side? Well, you're being watched! Well, not necessarily. However, it is certainly possible. So, I don't know that I would want one of these in my house. But, if someone in China wants to watch what is happening in front of my house? Who am I to judge, or care?

The Pros

  • It met all my requirements: POE, Outdoor, Night Vision, 720p, ONVIF and Cheap. 
  • It goes beyond by providing a free iOS and Android apps and accompanying service to allow you to view the camera from just about anywhere.
  • The night vision works really well.

The Cons

  • The CMS software was a dud. Although not surprising, it is a bummer.
  • There is no config path for Mac Users. Internet Explorer and/or the CMS app are required for configuration and they are Windows only.
  • Config and install of the HoSafe 1MB6P is not for the casual user. Like most (if not all) IP cameras, it does require either experience or stubbornness. If you lack both, get help or get a different IP camera.

The Conclusion

The HoSafe 1MB6P works and it let's you view your camera live on an iOS or Android device from anywhere you have internet. While the CMS software is not ideal, it will record and store your camera footage. The ONVIF compatibility means you can use many third party apps and programs to both view and record if the provided apps don't cut it for you.

I have ditched the CMS software and have been testing both free and pay NVR software for recording and archiving. But, that is another story.

Tuesday, May 13, 2014

From Obi to Vestalink (formerly Obivoice)

So, I have had a Google Voice account for years. I have actually been using it as the "One Number to Control Them All..." for the last 2 years. In fact, I had been so pleased with my setup, that I got my parents an Obi last year and ported their number to Google Voice. A few months later, I did it for a client. Then, Google decides that the XMPP protocol that is used for Google Chat (and those evil free calling deals like Talkatone, GrooveIP and Obi) isn't big enough, doesn't have enough industry support, won't do what they want. In other words, they are taking their toys and going home. In this case, home is the new protocol they created for Hangouts.

This means that I have to come up with a solution that uses the Obi equipment and works seamlessly with Google Voice. I don't know about other users, but I find the idea of leaving Google Voice voicemail about as appealing as replacing sugar with saccharin. Yeah, they are both sweet. But, you know which one is the sugar, don't you.

So, after looking at pricing, reviews and features, I settled on Vestalink. I could go probably give an account of how I decided. But, if it's that important to you. Do the research yourself. It'll be good for you.

Spoof the Caller ID first:
The process of converting my parents' Obi to Vestalink went flawlessly. Except for one item. If I had to do it all over again, I would Spoof the Caller ID before running the Obi setup script. Since I programmed the Obi before spoofing the Google Number, I had to login with a GrooveIP client to prove "ownership" of the Google Voice number. Not such a big deal, but easily avoided by Spoofing the Caller ID prior to running the Obi setup script.

7 Digit Dialing:
The one real complaint I have with Vestalink is they don't show you how to setup local 7 digit dialing. Or, BETTER YET, make it a part of the Obi setup. So, below I have a Digit Map that makes it possible.

Login to the Obi and pull up the User Settings > User Defined Digit Maps

Change Map 1 to:

Label Mipd
DigitMap    (<1aaa>xxx xxxx|1xxxxxxxxxx|<1>[2-9]xxxxxxxxx|011xx.|xx.|(Mipd)|[^*]@@.)

Just copy and paste. Make sure you replace the AAA with your Area Code. That's it!

Now, your mileage may vary. Make sure you keep a copy of the original DigitMap in case this one doesn't work for you. USE AT YOUR OWN RISK!!!!

Monday, August 17, 2009

Word and Spell Checking Redux

In the last installment, I shared an uncommon issue with spell checking in Word documents. I also shared a solution, however unsavory and tedious it may be. To recap, from time to time one may run across documents in which proofing (spell and grammar checking) is disabled in certain pages, sections and/or paragraphs.

This may be overcome by marking the problem area and selecting "Clear All Formatting" under Styles and then reformatting. While I admit that this solution is not ideal, it is certainly better than reformatting the entire document.

My approach with to the problem was the same as my approach to any other. Once the problem is identified, find a solution quickly. This solution is not usually going to be easy to implement. However, it is always workable. Once that workable solution is discovered, pass it on to the users that need to use it. This is usually met with groans, but again, it is a solution.

Then, the real fun begins. Since the users have a workable solution, I can work on a solution that is more elegant, easier to perform and implement. In this case, a macro! That's right, a macro. It turns out that the macro solution for this particular problem is, well, really short. One line of code, in fact. Create a new macro called Enable_Proofing and add the code:

Sub Enable_Proofing()
'
' Enable_Proofing Macro
'

ActiveDocument.Content.NoProofing = False

End Sub
Simply add this macro to your Normal.dot template so that it will always be available. No style clearing or reformatting required. The macro simply removes all NoProofing flags from the active document.

I love it when a plan comes together!

Friday, August 14, 2009

Word and Spell Checking

I am currently working in an office environment that has ALOT of legacy documents. What do I mean by legacy? Well, I mean we have alot of documents that were created in older versions of Word and are still used and updated with new information. All of the legacy documents were created with Word for MAC OS 9. Yeah, you read it correctly... OS 9!

So, we have all these documents and they have been modified, folded, spindled and mutilated with various versions of Word on both OS 9 and Windows. This has led to some very interesting issues. (By interesting, I mean very annoying.)

The biggest problem we have is some parts of some documents are excluded from spell and grammar check. Now, I can do without the grammer check. But, I NEED the spell check! This is a major problem, because it is not the document as a whole that is excluded. Only certain portions of some of the documents. It could be a paragraph, a table, a section or even a page. But never the whole document. This makes things very difficult.

However dim it may be, there is a light at the end of this particular tunnel and you don't have to recreate the entire document. If you are having a similar problem there is a way to get rid of these codes that are in the document, but you do not have direct access to. Believe it or not, you can mark the text in question and choose "Clear Formatting" from the Styles drop-down and this will get rid of those nasty little invisible buggers!

Why not just change it to another Style directly? Well, you can. But, if you don't clear all formatting first, the coding for ignoring the spell and grammer checking will remain! So, clear the formatting and then reformat the text to the needs of the document.

So, armed with this new found knowledge, go forth and fix those legacy documents! Show them that you're the boss!

Wednesday, April 29, 2009

Of Hard Drives and RAID...

Some months ago, one of the two hard drives in the server at the office decided to up and quit. Although this is bad, we use a RAID 1 setup to minimize data loss. What this means is there, in our case, two identical hard drives in the server that are"mirrored" at any given time they both have all the same information. So, if one dies the server continues to operate.

The server is getting up there in age, but I am not ready to go to a new Server OS and you can throw all the power you want at Windows Server 2003 32bit and not see much in the way of performance gain for network-centric operations. So, I decided to upgrade the hard drives with a pair of new server-grade Seagate 500gb 7200.11 SATA drives. Mmmmmmmm a slight performance gain, a huge storage gain and cheap. While the server was down and I was under the hood, I decided to bump the RAM from 2gb to 4gb. Yeah, I know that it can't use all 4 gigs but it can use slightly more than 3GBs and it also was pretty cheap.

The upgrade went relatively without a hitch. I booted from a BartPE CD I have with my RAID driver floppy disc (yes, a real 3.5" floppy) and made an image of the partition. Then I installed the new drives, created the new Array and restored the image. It took about an hour.

But here we are a few months later and one of those new drives has failed. No big deal right? Well, it is when the RAID controller Docs don't discuss rebuilding the array. Now, don't get me wrong, this cheap SATA RAID controller has saved me alot of greif up until this point. But, REALLY?!? No docs on rebuilding?!? REALLY?!?

If you find yourself in a position that requires you to rebuild an array then keep this in mind. An OFFLINE RAID rebuild means that you will be rebuilding the array in the BIOS without the benefit of the OS, Internet, Solitaire, etc. So, if you have to rebuild an array and want to has access to all of those wonderful things that make computers worth having make sure you choose ONLINE rebuild.

All of that said, I don't trust it. Choosing an ONLINE rebuild with a cheap controller seems a bit like rolling the dice. Its an OFFLINE rebuild for me! So, I'm sitting back and checking my webmail periodically.

Cheers!

Thursday, October 30, 2008

Is it time to replace your UPS?

Let me ask you a few questions first:

  • Has your UPS been in service more than 2 years?
  • Have you replaced the computer since the UPS was installed?
  • Have you upgraded the computer since the UPS was installed?
  • Is your UPS missing an AVR circuit?
If you answered YES to any of the above questions, then you probably should start looking looking for a replacement UPS.


What size do I get?

OK. This involves some simple addition. Gather all the power requirements for all the devices for which the UPS will be insuring continuos power. Generally, this would be you computer box and the monitor. If you would like to include your modem and router, you can. Specifically you need to get the Watt rating for each of the devices. Once this list is complete, add it up. Your target UPS should be able to handle more than the total. Do not round down!


What is AVR and why do I want it?

AVR stands for Automatic Voltage Regulator. The AVR circuit allows the UPS input voltage within a certain range and output a steady constant voltage without the use of the installed battery. In most cases acceptable input voltage ranges from 90 to 140 volts. When the voltage is less that optimal, the regulator uses the steps up the voltage at the cost of a few amps (don't worry you have plenty.) When the voltage is a little over optimal, the regulator steps the voltage down adding to the available amps. An AVR circuit is to power what the suspension system is to an automobile. What this means to you is the UPS can handle most power fluctuations without engaging the battery and this is very good.


Is AVR pricey?

Well, a UPS with AVR does usually cost more than a comparable UPS without. However, recently the price gap has closed somewhat. For instance, at the time of writing, a Tripp Lite 300 watt UPS without AVR is priced at $59.99 and a Tripp Lite 300 watt UPS with AVR is $69.99. For the $10 difference, take the unit with AVR!


Should I consider anything else?

Yes, if you like to leave your computer on 24 hours/day you need to get a unit with a data cable and software. This combination will allows the computer to shut itself down automatically during an extended power outage.


That's it! Go forth with this knowledge and protect your computer from bad power!