Do Androids Dream of Electric Sheep?
OK, for years I have been pretending that I read books, while I have never read more than 20 books a year. At least that’s what my Goodreads stats say. But I have planned to change that for good now. Saturday, April 13: Read 11… Read More »Do Androids Dream of Electric Sheep?
WordPress Solution: Updating failed. Error message: The response is not a valid JSON response.
In your wp-config.php add the following code, preferably on top Also, see if your write permissions are good. Here is how to do that via FTP Also, you can see which user on your server is the owner of the WordPress installation directory. You can… Read More »WordPress Solution: Updating failed. Error message: The response is not a valid JSON response.
WordPress: Fastest Way to update all plugins using WP CLI
Update all WordPress plugins using WP CLI. It’s a lot faster than the WP admin interface.
Solution: Waiting for another flutter command to release the startup lock…
This happens when a flutter API task is half done and finishes prematurely. On a Mac, this should solve the problem This worked for me on Mac. On Windows, you can try the following This should work irrespective of the IDE or editor being opened… Read More »Solution: Waiting for another flutter command to release the startup lock…
Solution to: zsh: command not found: flutter on macOS Catalina
Since the recent update to Mac OS Catalina and forced update to zsh, I was having problem with a lot of my CLI tools, including flutter. The reason being, zsh uses ~/.zshrc and not ~/.bash_profile So to solve the problem, simply add your flutter path… Read More »Solution to: zsh: command not found: flutter on macOS Catalina
Solution to zsh: command not found: expo on macOS Catalina
So I recently upgraded to macOS Catalina and all hell broke loose. Many of my command line utilities kept working but I have definitely wasted close to 30 hours trying to fix everything to make it work just like it did in the previous macOS… Read More »Solution to zsh: command not found: expo on macOS Catalina
Update the core jQuery version that ships with WordPress
You can replace the default version that ships with WordPress like that:
Python: Measure the execution time of small python code
The “timeit” module lets you measure the execution time of small bits of Python code. This can help you find the execution time of your code and thus help in a quick performance improvement of your code. A tiny example follows. Please note that every… Read More »Python: Measure the execution time of small python code
Git: Delete all branches except for the master/main branch – CLI Alias
It can be as simple as this alias in your terminal In my case, I had multiple branches and when I ran the gbr command, it showed the following result, deleting all three branches I had.
Python: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
This post is one of my new series solving one problem per day. For those of you solving coding challenges for your next software engineering job, here is one more problem. This problem was asked by Uber. Problem Statement Given an array of integers, return… Read More »Python: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
Python: How to merge two dictionaries
In Python 3.5+ In Python 2.x: In these examples, Python merges dictionary keys in the order listed in the expression, overwriting duplicates from left to right.
Load a script after a web page is loaded
So I was writing an A/B testing and was looking for the default jQuery method for loading an external script. So using the jQuery.getScript, you can do exactly that; load a script after a web page is already loaded and perform actions once it is… Read More »Load a script after a web page is loaded
Add a wordpress admin account programmatically
In cases when you have access to code and not to an existing admin account, here is a way to create an admin account for yourself without waiting for someone else to create it for you. In your `functions.php` file, use the following code: function… Read More »Add a wordpress admin account programmatically
Find code comments using regex in an IDE
So if you are a developer, you might need to clean up comments from a code that you might have copied from somewhere else and updating the documentation needs you to start from scracth, or you just want to get rid of comments. Afterall, it… Read More »Find code comments using regex in an IDE
PHP: Adding hours to timestamp fields while printing the formatted date
So imagine your MySQL is on a shared host and you have time stamps which are automatically inserted in the table. In this case, updating MySQL’s time zone settings is beyond your control. Or even if you can set the time zones, for any records… Read More »PHP: Adding hours to timestamp fields while printing the formatted date
PHP: Remove and Prepend zeros in a string
So in a recent project, the hardware being used was sending data always prepended with the zeros. I was using this as a number in my database, so this is what I did for removing the leading zeroes from the string $str = ltrim($str, ‘0’);… Read More »PHP: Remove and Prepend zeros in a string
LAMP: Linux/ Apache / MySQL / PHP: Upgrading PHP to 7.1 and enabling extensions
Step 1: sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get upgrade sudo apt-get install php7.1 # for PHP 7.1 Step 2: Install extension with the following commands sudo apt-get install php7.1-gd php7.1-mysql php7.1-dom php7.1-cli php7.1-json php7.1-common php7.1-mbstring php7.1-opcache php7.1-readline
Github Pages: Deploying a subfolder to GitHub Pages
Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest… Read More »Github Pages: Deploying a subfolder to GitHub Pages
Linux/ Debian / Ubuntu: Restart Apache 2 web server
Use # /etc/init.d/apache2 restart OR $ sudo /etc/init.d/apache2 restart OR $ sudo service apache2 restart OR simply create an alias for the command that works for you. alias rsws=’/etc/init.d/apache2 restart’ Using my alias ‘rswd’ $ rsws [ ok ] Restarting apache2 (via systemctl): apache2.service.
Linux: Quickly accessing your project files
Sometimes, all you need is quick command which you can run and land on a directory you access most. In this case, on one of my test servers, I wanted to go to the main directory where I keep my websites. I just created an… Read More »Linux: Quickly accessing your project files
Linux: Add and list aliases
Print all existing aliases alias Add a new alias alias list=’ls -la’ In the above example, an alias list has been added which actually runs the command ls -la
MongoDB: Copy a collection from one database to another
It’s quite simple db..find().forEach(function(d){ db.getSiblingDB(”)[”].insert(d); }); You can do a mongodump of a collection from one database and then mongorestore the collection to the other database. I used robomongo and it a documents view, just used this query with the right names for collections and… Read More »MongoDB: Copy a collection from one database to another
Git: Amend the last commit
So you just committed some code only to realize you had a few files missing from your commit, which you forgot to add. This happens a lot in everyday coding and git has an easy fix for that. If you are like me, you have… Read More »Git: Amend the last commit
My Github Pages
Just released a new version of Github pages which you can find at fahdi.github.io. Github pages are an interesting feature of github to update a personal portfolio or a project page or any static (or dynamic: look at PakistanJS). You push your code as a static… Read More »My Github Pages
Releasing first version of my postman collection for Teamwork API
Teamwork API is great but while while working on it, I badly felt the need of being able to test different end points before putting them into my app. Naturally, I tried looking for it on the web and didn’t find anything, so I finally… Read More »Releasing first version of my postman collection for Teamwork API
Python Solution: Could not find a version that satisfies the requirement requirements.txt
So I recently upgraded a project to python3 and installing via pip was giving me this message Could not find a version that satisfies the requirement requirements.txt (from versions: ) No matching distribution found for requirements.txt The solution was to do this pip install –upgrade… Read More »Python Solution: Could not find a version that satisfies the requirement requirements.txt
Javascript: Array Reduce
Here is a simple example of using reduce for adding all values in an array let add = (…args) => { return args.reduce(function(a, b) { return a + b; }, 0); }; let args = [3, 5, 7]; console.log(add(…args)); Clean, right? In regular JS or… Read More »Javascript: Array Reduce
Breaking changes from Angular 2 beta to final release candidate
If you’re using the Angular 2 beta version and want to upgrade to angular 2 final release candidate, it’s a good idea to be aware of the breaking changes from beta to final release. I followed a few youtube tutorials and struggled with it, so here… Read More »Breaking changes from Angular 2 beta to final release candidate
Javascript/ Angular: `ng new` command stuck at ‘Installing packages for tooling via npm’
So I am learning Angular 2 and decided to use Angular CLI this time instead of those seed projects. BTW, I am following this course to study basics of Angular. sudo ng new angular-app And this is what happened Password: As a forewarning, we are… Read More »Javascript/ Angular: `ng new` command stuck at ‘Installing packages for tooling via npm’
Simple code highlighter using only CSS
Over the last 10 years, I have learnt that sharing code on websites can be tricky. Just yesterday I was working on a blog post and realized that anything between the <code></code> can look ugly if not styled properly. For example, after writing some bash code… Read More »Simple code highlighter using only CSS
Restart apache on CentOS
Recently, I had a friend setup a CentOS server for me as I personally have experience setting up and managing lamp on Ubuntu servers but needed a CentOS expert. Anyhow, the way to manage Apache on CentOS is a bit different than how it’s done… Read More »Restart apache on CentOS
Javascript: Copy object or variable from console into clipboard
While I was doing some debugging, I badly needed to compare two Javascript objects that I could easily print into console but then was having a hard time remembering all of the differences from one object to the other one. This was a major API… Read More »Javascript: Copy object or variable from console into clipboard
React – Lets start with a ‘Hello world’
Skip to real stuff. My mom always says, just do it! Or was it Nike? Anyhow, I plan on actually just doing it. Like this guy! So I am going to challenge myself everyday. It’s 6:35 AM in the morning and I have been up… Read More »React – Lets start with a ‘Hello world’
Hello world!
OK, so here is hoping I blog for the next 365 days. Amen to that! Right now, it feels like in the process of making a real catapult, I’d end up with something like that Image was stolen from: http://www.instructables.com/id/Mini-Siege-Engines/