Always struggle with calculating age in PHP for some reason. And there seems to be quite varying ideas on how this should be done. So decided to once and for all sit down and figure out how I could do this.
In a previous post I tried to give an introduction on how to get started with PayPal Payment Data Transfers (PDT). PDT is very handy in several cases, but you can’t always rely on it since it requires the user to return to your page after doing the payment. That will often happen, but it’s not guaranteed to happen. If you for example want to mark an order in your system as paid or something like that, you most likely want to use PayPal Instant Payment Notifications (IPN) in addition to PDT.
Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use it to automate back-office and administrative functions, such as fulfilling orders, tracking customers, and providing status and other information related to a transaction. — PayPal
Once again the documentation, tutorials and code samples I found on this was a bit all over the place. Sort of messy and outdated. So, once again I decided to do my own thing and just follow the steps required and implement them myself. And since the tutorial on PDT turned out to be a bit of a success, I decided to share this too. Hopefully it can make the lives of fellow developers easier
Needed a function that could get me the last N lines of a log file. Wanted it to be efficient and not dependent on anything other than my code.
Found some versions, but they were either a bit messy or depended on unstable arithmetic (where filesize is greater than
PHP_INT_MAX). So, I decided to take on the challenge and try to write one myself. Nice little exercise
Probably an obscure issue I’ll never experience again, but in case it does, I found a solution that worked in a thread on Yahoo Answers.
Run one of the commands below in a Command Prompt or just stick it into the Run dialog (win + r). Then restart Skype *sigh*…
Windows 7 (and Vista?)
Wanted to create an easy interface for reading lines from a stream. It should take care of all the annoying Java IO nitty-gritty for me and I wanted to use it simply by throwing it into a for loop.
Ok, so I was happily reading CSV files from an SFTP server. The file content is returned as an InputStream and I I used a BufferedReader to read it line by line. Each line contained either a header or an order. The header lines started with the string “HDR”.
However, I suddenly discovered that my code was consistently skipping the first header (and as a result the orders belonging to it). The reason, I found, was simple. The first header, on the first line, didn’t start with “HDR”, it started with “□HDR”! And that undisplayable square turned out to be a Unicode Byte Order Mark (BOM).
Was going to test some code the other day which needed to talk to an SFTP server. Stumbled over a small gem which was super simple to use. It’s called Core FTP mini-sftp-server. No installation, no tricky stuff. Just download and run. Great stuff