Author Archives: Devendra Verma

Install or update nodejs usin NVM in Ubuntu

Node JS is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event driven, non-blocking I/O model that makes it lightweight and efficient
 Using nvmNVM, which stands for “Node.js version manager” we can install multiple versions of nodejs on Ubuntu.

To install or update nvm, you can use the install script using cURL: ( You can find the installation instructions on projects github page https://github.com/creationix/nvm/blob/master/README.md)


or using Wget:


Run the script by running 


To get the list of available Node.js versions

React Native Issues

Recently I started learning React Native to build native mobile applications using React JS. I faced lots of issues while making my first application run on my Ubuntu desktop. Here I am recording issues I faced and the solutions that worked for me, so that beginners like me don’t have to reinvent the wheel.

A problem occurred configuring project ‘:app’.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
  1. Go to your React native Project -> Android
  2. Create a file local.properties
  3. Open the file
  4. paste your Android SDK path like below
    • in Windows sdk.dir = C:/Users/USERNAME/AppData/Local/Android/sdk
    • in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk
    • in linux sdk.dir = /home/USERNAME/Android/Sdk

Replace USERNAME with your user name

Now, Run react-native run-android in your terminal
ENOENT: no such file or directory, open ‘android/app/src/main/assets/index.android.bundle’
Manually create this directory
mkdir android/app/src/main/assets
Unable to load script from assets index.android.bundle
  1. (in project directory) mkdir android/app/src/main/assets
  2. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
  3. react-native run-android

ou can automate the above steps by placing them in scripts part of package.json like this:

Ref: https://stackoverflow.com/questions/44446523/unable-to-load-script-from-assets-index-android-bundle-on-windows

 

Then you can just execute npm run android-linux from your command line every time.

I will keep updating this as and when I encounter new issues with solutions that worked for me.

Convert GMT to Local timezone in PHP

Following code snippet converts a date time in GMT to Local timezone.

 

mysql table is marked as crashed and last (automatic?) repair failed

If you are getting this error

mysql table is marked as crashed and last (automatic?) repair failed

Go to your data folder and try running

You should stop MySQL process first. If that doesn’t work, you can try with

I had to navigate to /var/lib/mysql/<database> and run myisamchk -r -v -f ./<table name>.

PS – This was answered at following thread, this post is for just personal reference in future.

Reference – http://stackoverflow.com/questions/8843776/mysql-table-is-marked-as-crashed-and-last-automatic-repair-failed

Requires Doctrine DBAL Laravel migration

If you are running a migration to change the data type of a column in a table. You might come across this error message in terminal.

This error message is telling you to install doctrine/dbal to make this work. You can learn more about this package here https://github.com/doctrine/dbal

To install this package through composer, run following command in terminal.

Now you can run your migration by running

This should work now.

npm install – Please try running this command again as root/Administrator

If you are getting this error while running npm install, then you are not having write permission on .npm directory.

To get the ownership of this directory run following command

Also we need to give write permission to node_modules directory

ref – http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo

Install Mcrypt PHP extension on Ubuntu (PHP-FPM + Nginx)

To install Mcrypt PHP extension on Ubuntu / Debian run following command ( this step is same for Nginx and apache )

This will create a mcrypt module in /etc/php5/mods-available directory. If it doesnt we need to create symlink for this.

Now enable mcrypt by running

After this restart php5-fpm service by

 

Upgrade Google Cloud Compute Engine VM Instance

There two ways you can upgrade or downgrade your VM instances.

a. Stop – configure – start

b. Minimum downtime ( by swapping the disk )

a. This is a very easy method to do this. The main disadvantage of this is, it requires downtime. If you are okay with a 5 – 10 minute of downtime then you can go with this method.

b. If you this to happen almost real time then follow these steps

If you have a Google cloud compute engine VM Instance and wants to upgrade or downgrade  Continue reading