Tuesday, December 26, 2017

Tuesday, November 14, 2017

Installing Mongo for PHP on MacOS

Use below guide

https://stackoverflow.com/questions/36760759/mongoclient-not-found-in-php-on-mac-osx-using-brew

brew install php56-mongo

Monday, November 13, 2017

AWS auto snapshot and backup

refer:

https://github.com/CaseyLabs/aws-ec2-ebs-automatic-snapshot-bash

Sunday, October 15, 2017

How to update nodejs

npm cache clean -f
sudo npm install -g n
sudo n stable

npm install npm@latest -g

Tuesday, October 3, 2017

how to download php composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Install Tex2PNG on system

use below commands:

sudo apt-get install texlive-latex-base (for latex command)

install dvipng

use Tex2Png php library

https://github.com/Gregwar/Tex2png/blob/master/Tex2png.php

Friday, July 21, 2017

How to create detached byobu sessions

Below is process to create detached byobu sessions:



byobu-tmux new-session -d "sh ./api_build.sh"

Saturday, July 15, 2017

php7 setup on ubuntu 16

https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-16-04-lamp/


Sunday, June 25, 2017

Friday, June 2, 2017

ngrok.. expose localhost to internet

ngrok is great tool to expose internet to outside internet.

./ngrok http <port number>
http://localhost:4040/inspect/http

run it on byobu


Bhola Meena's ngrok end point is :  https://54f3ee7e.ngrok.io


Thursday, May 18, 2017

How to reduce size of EC2 EBS volume

Latest link: https://medium.com/@rahulian/how-to-reduce-volume-of-an-aws-ec2-instance-d493ec891698

copy commands:
-aAxXSH
-aHAXxSP


attach two volume and issue below commands:


Block Device Name Big Volume = /dev/sda1
Block Device Name Big Volume Snapshot = /dev/sdg
Block Device Name Small Volume = /dev/sdf

Restart the Instance and SSH in

Login:
Create a file system for the 2 volumes you have created (Note: In Ubuntu I had to do a cat/proc/partitions to work out which device was which).
Create two mount directories and mount the new volumes.
Sync the files.
Unmount the smaller volume.

Stop the instance


link from:
http://cloudacademy.com/blog/amazon-ebs-shink-volume/

Wednesday, May 10, 2017

common bugs in PHP: Include same file name

If two files with same names available, then content of second include will not be read if include_once used.

include vs include_once : There is only one difference between include() and include_once(). If the code from a file has been already included then it will not be included again if we use include_once(). Means include_once() include the file only once at a time.
include vs require : if include() is not able to find a specified file on location at that time it will throw a warning however, it will not stop script execution. For the same scenario, require() will throw a fatal error and it will stop the script execution.
require vs require_once : There is only one difference between require() and require_once(). If the code from a file has been already included then it will not be included again if we use require_once(). Means require_once() include the file only once at a time.


Monday, February 20, 2017

Points with Online Education Seminar

1. Mindspark - leading adaptive learning co in india
2. only quality content will win in online education.
3. courses will replace the textbooks in future
4. online education like video game. need to tune for each students
5. swayam- india govt initiative

Monday, January 9, 2017

image optimization for websites

refer: https://jmperezperez.com/jpegoptim-optimize-jpg-page-speed/

jpegoptim
smushit for wordpress

In my opinion the best option out there that effectively handles most image formats in a go is trimage. It effectively utilizes optipng, pngcrush, advpng and jpegoptim based on the image format and delivers near perfect lossless compression.
The implementation is pretty easy if using a command line.
sudo apt-get install trimage    
trimage -d images/*

I use jpegoptim to optimize JPG files and optipng to optimize PNG files.
If you're on bash, the command to losslessly optimize all JPGs in a directory (recursively) is:
find /path/to/jpgs/ -type f -name "*.jpg" -exec jpegoptim --strip-all {} \;
You can add -m[%] to jpegoptim to lossy compress JPG images, for example:
 find /path/to/jpgs/ -type f -name "*.jpg" -exec jpegoptim -m70 --strip-all {} \;
To optimize all PNGs in a directory:
find /path/to/pngs/ -type f -name "*.png" -exec optipng -o2 {} \;
-o2 is the default optimization level, you can change this from o2 to o7. Notice that higher optimization level means longer processing time.
optimize() {
jpegoptim *.jpg --strip-all
optipng -o7 -preserve *.png
for i in *
do
if test -d $i
then
cd $i
echo $i
optimize
cd ..
fi
done
echo
}
optimize