Android React-Native

No emulators found as an output of emulator -list-avds

I got this error when running react-native app by running the command: npx react-native run-android

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch

Checking adb device running and the command not found.

adb devices
zsh: command not found: adb

The solution for Mac user is to edit .zshrc by add following:

# fix adb command not found
alias adb='/Users/softmastx/Library/Android/sdk/platform-tools/adb'

# fix No emulators found
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

Save it and don’t forget to restart zsh for the changes to take effect!

source ~/.zshrc



Find all available images for Image systemName in SwiftUI

These icons are called SF Symbols. There are over 2,400 symbols you can use in iOS 13and later, macOS 11 and later, watchOS 6 and later, and tvOS 13 and later. You can use a symbol everywhere you can use an image.

To browse the full set of symbols, download the SF Symbols app. For more info about SF Symbols check here.

SF Symbols 2 introduces over 750 new symbols and includes:

  • Over 150 preconfigured, multicolor symbols that automatically adapt to vibrancy, accessibility settings, and appearance modes
  • Negative side margins in both standard and custom symbols, giving you greater control over horizontal alignment
  • Localized symbol variants for right-to-left writing systems, as well as script-specific symbols for Arabic, Devanagari, and Hebrew



let heartImage = UIImage(systemName: "heart.fill")


let heartImage = Image(systemName: "heart.fill")



How to switch cocoapod version


The way I usually introduce Bundler to iOS developers is “like CocoaPods, but for Ruby”. This is correct but a bit unfair, as it is actually CocoaPods which took inspiratino by Bundler, not vice versa.

Bundler lets you specify your dependencies into a Gemfile, it installs or update them for you, and finally makes sure that the executables your are calling are actually the ones specified for the project.

Bundler is a Ruby tool itself, so you can install it like this:

gem install bundler

Once installed you can setup your project to use Bundler with this command from the root of your project:

bundle init

This will generate a template Gemfile. Like a Podfile, a Gemfile is actually a Ruby file in which you can use a special DSL to specify which dependencies you are using, and their version.

This is how a Gemfile for an iOS project might look like:

source ""

gem 'cocoapods', '1.0.0.beta.3'
gem 'fastlane', '~> 1.57.0'

The string after the gem names informs Bundler on the version requirement. In our case CocoaPods should be exactly at version 1.0.0.beta.3, while Fastlane latest version that is greater or equal than 1.57.0, but less that 1.58.0.

Fun fact: Bundler and CocoaPods share the same dependency resolution library, molinillo.

To install your dependencies simply run:

bundle install

Bundle Exec

Installing the right version of a given tool is only the start, actually using the tool is what matters.

I can sometimes happen to be working on different projects at the same time which are using different versions of a tool. Sometimes is not wise to always use the latest version on all the projects, for example and older project might be structured in an incompatible way.

Rather than going down the rabbit hole of updating or downgrading everything, you can rely on Bundler to make sure you are actually using your tools in the version specified in the Gemfile. This can be done by calling them through Bundler via bundle exec, for example:

bundle exec pod install

hat’s quite verbose, so I’d recommend to use an alias) for that. Mine is be, I actually have two special aliases for CocoaPods and Fastlane, bp and bf.



Install CocoaPod Version

Recently, I’ve created react native app with this command:

npx react-native init myapp

and I got these error: “Installing required CocoaPods dependencies”

info Installing required CocoaPods dependencies
(node:8874) UnhandledPromiseRejectionWarning: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./myapp/ios && pod install".

and “React requires CocoaPods version >= 1.10.1”

`React` requires CocoaPods version `>= 1.10.1`, which is not satisfied by your current version, `1.10.0`

Here is my solution:

  1. Check cocoapods version
pod --version

2. Cocoapods gem list

gem list cocoapods
*** LOCAL GEMS ***

cocoapods (1.10.0)
cocoapods-core (1.10.0)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.4.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-trunk (1.5.0)
cocoapods-try (1.2.0)

3. Install cocoapods version

gem install cocoapods -v 1.10.1
Fetching cocoapods-1.10.1.gem
Fetching cocoapods-core-1.10.1.gem
Successfully installed cocoapods-core-1.10.1
Successfully installed cocoapods-1.10.1
Parsing documentation for cocoapods-core-1.10.1
Installing ri documentation for cocoapods-core-1.10.1
Parsing documentation for cocoapods-1.10.1
Installing ri documentation for cocoapods-1.10.1
Done installing documentation for cocoapods-core, cocoapods after 3 seconds
2 gems installed

4. Cocoapods install specific version in your project.

pod _1.10.1_ install
// pod _{version}_ install

** Don’t forget to put underscore before and after version number

This does not change the default CocoaPods version used when running pod install

I hope this help.



How to change database charset in WordPress wpdb

Sometime you would get database query results from wpdb with get_results in ????????.

global $wpdb;

$results = $wpdb->get_results("SELECT * FROM tables");
header('Content-Type: application/json;charset=utf-8');
echo wp_json_encode($results);

Although, the encodings of the database, table and the column are all set to utf8, that would not help!

I’ve found a simple solution by setting wpdb character encoding before get_results.

global $wpdb;
$wpdb->set_charset($wpdb->dbh, 'utf8');  // add this line


$results = $wpdb->get_results("SELECT * FROM tables");
header('Content-Type: application/json;charset=utf-8');
echo wp_json_encode($results);

I hope this help.



WordPress React Gutenberg

How this code will be looked when i call wp.element?

class Clock extends React.Component {
  constructor(props) {
    this.state = {date: new Date()};

  componentDidMount() {
    this.timerID = setInterval(
      () => this.tick(),

  componentWillUnmount() {

  tick() {
      date: new Date()

  render() {
    return (
        <h1>Hello, world!</h1>
        <h2>It is {}.</h2>

  <Clock />,

wp.element is basically a React wrapper. Your code can look like this if you use wp.element

const { Component, render } = wp.element;

class Clock extends Component { of the code

  <Clock />,

Or you can keep using React too as it already ships with WordPress, in which case set it as an external in webpack so it isn’t bundled with your build and instead takes it from the WP Core.

Hope this helps!



PHP Formatter in VS Code

PHP CS Fixer Installation

Go to extension menu, searching for PHP CS Fixer and install it.

PHP CS Fixer for Visual Studio Code

PHP CS Fixer Configuration

After installed, go to setting and place following snippet below php-cs-fixer.executablePath

"php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
"": {
    "editor.defaultFormatter": "junstyle.php-cs-fixer",
    "editor.formatOnSave": true
"php-cs-fixer.rules": "@PSR2",
"php-cs-fixer.formatHtml": true,
PHP CS Fixer Configuation in Setting
Right click to format PHP code

And happy coding!