Similar Posts
API Client Design
When you extensively work with certain APIs, like Shopify’s for example, you will end up with bunch of functions that map to API’s endpoints. One of the approaches I have seen so far is to create an API class ShopifyApi and make those functions class methods. So it looks something like the figure below. I…
Debugging Webhooks
A webhook is an HTTP callback, that occurs when something happens (a resource changes its state). Webhooks provide a way to build event-driven apps, because you can be notified about changes. Since webhooks require a publicly accessible URL to function they can be hard to test from your local machine. There are three main problems…
Replace Funky Characters While Importing CSV
Sometimes uploaded text/csv file may have non-utf8 or other funky characters using the function below. public static function processUploadedBundles($request) { $content = file_get_contents($request->file(’uploadedFile’)->getRealPath()); $lines = explode(PHP_EOL, $content); $array = []; foreach ($lines as $line) { $arrayCsv = str_getcsv($line, ","); $arrayCsv = array_map(function($value){ return preg_replace(’/[\x00-\x1F\x7F-\xFF]/’, ”, $value); }, $arrayCsv); $array[] = $arrayCsv; } return…
Create WordPress User with Admin Privileges in MySQL
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES (’admin’, MD5(’password’), ‘User Admin’, ‘user@admin.com’, ‘0’); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (SELECT MAX(id) FROM wp_users), ‘wp_capabilities’, ‘a:1:{s:13:"administrator";s:1:"1";}’); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (SELECT MAX(id) FROM wp_users), ‘wp_user_level’, ’10’);INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES…