Tag: php
- Intro to DOMPDF - light and simple PHP library to generate PDF documents (05 Apr 2024)
Generating PDF documents from your HTML output is a very common requirement and there are several open source libraries to accomplish this in PHP. I came across this need for my project recently and I evaluated many popular ones such as TCPDF, mpdf, FPDF, etc. But the one that truly...
- How to handle long-polling of XHR requests in PHP (02 Jan 2023)
A common need you often face in PHP scripting these days is writing a long-polling endpoint for things like sending notifications or other kinds of responses back to the client. While using something dedicated like node, cometd or websocket makes ideal sense for such things, there are use-cases when you...
- [PHP/Codeigniter] Getting multi-queries right with SQLITE (14 Nov 2022)
My earlier article dealt with multi-query issues of MySQL, this one is dedicated to SQLITE. Multi-queries are often discouraged to begin with but there are times when you find yourself using them. One typical use case is populating the database initially when it’s empty. You do this by running an...
- [MySQL] Setting default date to current date (13 Oct 2022)
The most typical way people set default values to mysql date fields is by using the CURRENT_TIMESTAMP constant as follows: create table ledger_entries ( id int(11) not null auto_increment, entry_date datetime default CURRENT_TIMESTAMP ); This will obviously work if you need both date and time parts in the value. But...
- [PHP/Codeigniter] Playing with multi-queries in MySQL (12 Oct 2022)
Multi-queries are often discouraged with mysqli functions but there are times when you must use them. One obvious use case is initializing the database. One of the first things your app must do is determine if the database tables exist or not, and then run an initializing SQL script if...
- How to approach and evaluate programming languages for a project (21 Sep 2022)
While it’s a topic which has already invited hair splitting debates ad nauseam, it has also invited a lot of hype and there is a need to unclutter that hype and think about this topic objectively. The Toolbox Approach This has been the classic or traditional approach when programming used...
- Wordpress to Pelican in 24 hours (21 May 2019)
Today, I finished migration of my blog from a self-hosted Wordpress site to a statically hosted Github Pages site. For the static site generator, instead of choosing Jekyll which is a hot favorite of rubyists, I went for Pelican instead as I figured my Python skills might be somewhat useful...
- WordPress DIY: Adding syntax highlighting to your WordPress blog without using an external plugin (10 Jul 2018)
Just as my other articles in WordPress DIY series, this one also focuses on doing everything yourself by writing the code rather than using any external dependencies. There are two popular open source implementations of Syntax Highlighting JavaScript libraries: Google’s Prettify and Alex Gorbatchev’s Syntax Highlighter, and in this article,...
- WordPress DIY: Adding twitter cards meta to your blog without using an external plugin (08 Jul 2018)
Just like my last article, we won’t be focusing on using a third party plugin, but write our own plugin. I’m a minimalist and don’t prefer to use layer-2 solutions for really trivial things that can easily be achieved by writing code. Now, though trivial to implement, the twitter cards...
- Wordpress DIY: Adding Google Analytics Script to your Blog Without using an External Plugin (07 Jul 2018)
Adding a custom script element to your Wordpress blog is really straightforward if you know what you are doing and there isn’t any need to install a third-party plugin for this. Now, for something like spam protection (Akismet) or adding contact forms (Contact Form Seven), its quite understandable, but if...
- How to create a Google Drive App in PHP (02 Jan 2017)
This is the second article in the drive series for web programmers that aims to explain how to use the Google Drive API in your web applications to access files/folders on behalf of your logged-in users. One of the basic tasks here is to authenticate to google and access the...
- Farewell Wordpress, Hello Jekyll! (04 Feb 2015)
Here I am, signing off from a self-hosted, over-bloated Wordpress site and finding a welcome change in Jekyll, a blog-aware static site generator. There is nothing new about this, several well-known bloggers have already migrated to Jekyll in the last few years including Rasmus Andersson, Nick Quaranto and Roger Chapman....
- PHP-FPM vs node.js - The REAL Performance Battle (22 Jun 2014)
Even after my last article about PHP and node.js benchmarking, my search for the holy grail of performance truth still continues. However, I do understand now that pitting PHP running on apache against a stand-alone node was a bit unfair with PHP for it was limited by what the apache...
- PHP vs node.js: The REAL statistics (09 Jun 2014)
When it comes to web programming, I’ve always coded in ASP.NET or the LAMP technologies for most part of my life. Now, the new buzz in the city is node.js. It is a light-weight platform that runs javascript code on server-side and is said to improvise performance by using async...
- How to create a custom email plugin for Wordpress (07 Jun 2014)
Last week, I suddenly stopped receiving email notifications for my openshift hosted blog. I came to know after some reading that commonly used cloud hosts such as openshift, aws, etc. are usually blacklisted by most email servers, hence its not a good idea to use them to send mails. In...
- The 7 "Bread and Butter" Plugins for your Wordpress blog (27 Nov 2013)
Based on my experiments while setting up this blog, below are the 7 “bread and butter” plugins for your wordpress blog. These plugins came very handy for me and allowed me to seamlessly integrate much needed functionality in my blog without writing a single line of php code. {.alignnone .wp-image-186...
- Some Wordpress tips and tricks (23 Nov 2013)
Wordpress is a universally recognized and robust blogging platform written in the PHP language. Below are a bunch of Wordpress tricks that I’ve learned during my deployments, and I’d like to share with you. 1. Change breadcrumbs to start from “Home” instead of Site-Title: When I set up this site,...
- Wordpress installation quick-start guide (17 Nov 2013)
Wordpress is a blogging platform that is very easy to use, but involves many configuration trivia which may become overwhelming, unless organized and documented somewhere. Based on my experience of setting up this website, here are the things that I had to keep in mind to get it up and...