Instantly share code, notes, and snippets.

View What have I been working on (2018 edition).md

What Have I Been Working On? (2018 Edition)

Since I left my government job over 6 months ago, a lot of people have been asking me, "What have you been up to?" It's a fair question. My life as a contractor/student has been busy and quiet and then busy again (kind of like a "hurry up and wait" situation on repeat inside a front-loading washing machine). I've decided to start looking for full-time employment in November of this year. I hope that until then I will have enough time to study all of the things that I want to (there's just never enough time).

Anyways, this is a post that I hope to update periodically. I think that I will make a post like this every year from now on. It's really handy to have. I just want to simply list out the things that I have been working on over the year and update them as time moves on (via Git). Next year I will be sure to create a post like this near the start of the year and keep adding to it throughout the year. However this year, I am a little tardy (it's October).

Lik

View Get Data from an API with VBA.md

Getting Data from an API with VBA

The other day I had to use VBA in order to retrive data from the stockwatch.com. StockWatch offers a fairly extensive stock API with a daily changing API key. StockWatch allows up to 100 stocks to be queried via a query string in each call.

getStockDataString() takes: an array of strings which represent each stock symbol, the market or "region" where the symbols are located, and the daily API/authorization key (provided to you by StockWatch).

I wrote the function/"sub" in Excel 2010 and the HTTP_GET request uses the MSXML2 library and the XMLHTTP method. I don't know if this library is available in later versions of Excel, but I'm sure the process for making HTTP requests would be similar.

The StockWatch API returns each stock on each line of the response and each requested field seperated by a comma. For example:

View Using rsync as a Backup Method.md

Using rsync as a Backup Method

I like rsync. It's an amazing little Unix utility that allows the user to sync files across two drives/folder structures. I use it personally for backuping up photos and other important documents to a mounted USB drive. I then (periodically) update the drive and keep it locked up in a safe place when it's not in use.

Here is an example script that you could use to backup your Dropbox's Code, Documents, Sites and Photos directories (on Windows, using Git Bash):

#!/bin/bash

rsync --size-only \
View Checking Out Microsoft Cognitive Services.md

Checking Out Microsoft Cognitive Services with PHP

AI? Huh?? Oh.... yeah.. I've heard of that! That's that movie where the Skynet becomes sentient and attempts to destroy mankind, right? Scary stuff.

What's that you say? Artificial intelligence won't kill me?! Huh.. OK - well, maybe I'll stop smoking a pack of cigarettes a day then. I kid.. I don't smoke - sorry if you do (if you are still alive and able to read this).

I was listening to the Shoptalk Show podcast the other day and heard about this crazy new(?) thing that Microsoft and some of the other big data players are cooking up.

Cognitive services is a form of artificial intelligence because you have to train it first on a controlled dataset and then it gets smarter and more accurate based on its previous experiences.

View How to Setup SSH Keys.md
View Scrape HTML Into an RSS Feed.md

Scrape HTML Content Into an RSS Feed

If you still like RSS as a technology (like I do), then you might be interested in creating an RSS feed for a website that no longer supports RSS. That way, you can point your RSS reader to a PHP file on your server and have your RSS reader update when new content is created. Yes folks, we are screen scrapping with PHP today!

One of my favourite photographs is Hedi Slimane. I really like his style and exculsive use of black and white. However his blog site doens't support RSS. Since I really want to know when new content is posted, I created a little PHP script that will check his site and return an XML RSS feed from my server to my RSS reader.

This is just an example of what is possible in the vast and scary world of screen scraping. I just thought that I would post this script up as an example.

Cheers!

View Coding Sabbatical.md

Taking a Coding Sabbatical

I did it! I left my secure job. I even left without having another job lined up. My dad told me never to do that (sorry, dad).

The plan for the next 3 months is to accept only small jobs and to study a lot in my spare time. I want to level up my JavaScript skills and to eventually get a local or remote position with a company that I find engaging and inclusive.

I feel like quiting my job was necessary as I simply did not have enough time available during the day in order to study and work. I need several hours a day free and clear if I'm to be efficient. Web developers constantly need to be learning these days. Every time you turn around there is a new framework or a new tool or a new best practice bandwagon that we should all be jumping on. It's very hard to keep up - I'm sure that you agree.

It's not surprising that the 2018 Stack Overflow Developer Survey found that developers really want code and that they want to learn

View Jonathan Goes Windows.md

Jonathan Goes Windows

It's "official", I have switched to Windows! Some may call me crazy (and maybe I am) but I've actually been enjoying the web dev experience on Windoze. Like those brave soles before me, I have decided that it's time to combat the Mac monoculture and try something different.

It's strange to me that the web is all about open technologies and inclusiveness and then we all use Mac and preach our technology choices hard from the rooftops. I started off using Windows for photography in 2005 on a severely under powered machine, switched over to Mac around 2007 and then became a semi-hardcore Linux user from about 2013 to 2018. I've come to learn that it really doesn't matter which machine the web developer is using, as long as they get the job done at the end of the day.

Tools That Made the Switch Easier

Obviously, I couldn't give up the tools that I need to do my job. I was curious if there would be useful alternatives on Windows. Tur

View Connect Mac OS X to a Samba File Server Remotely via PHP.md

Connect Mac OS X to a Samba File Server Remotely via PHP

Ever had to connect a Mac web server to a Samba file share remotely via a PHP/HMTL form? No?! Really!? Are you sure?? Check again, I'll wait.

What's that you say!? The answer is still no!? Oh. Well.. OK.

Well anyways, I had to do this the other day and I'm going to write it down here so that I don't forget how I did it.

My work uses a little Mac web server to serve up a GitList installation (a listing of all our repos). Problem is, the Git repositories live on our LAN (Samba) file server. The Mac needs to talk to the LAN so that it can read the Git repositories and display them on the page via GitList. The Mac web server doesn't have any credentials of its own to supply to the Samba share, so, with this scipt, we ask the user for their credentials and then use those to connect to the Samba share.

View Connect PHP to LDAP.md

How to Connect PHP to LDAP

The other day I needed to connect PHP to my organization's LDAP/Active Directory server. I hadn't done this before and found it pretty difficult/annoying.

Hopefully, this will help someone else in the future or even just the future version of me if I have to do this again. I've heavily commented the code below for clairity. We are just outputing a form that asks for the LDAP credentials. If we do not have any relevant $_POST values submitted to our webpage/server we output the form. Otherwise, we will attempt to login to the LDAP server with the credentials provided and retrive some of the user's information.

Now that the user has passed authentication, you could check to see if the user is part of a certain group or has certain value(s) associated with their account.