Posts

Setup electron and sqlite3 in windows

Image
I am writing this post to share the information that will be helpful to you to setup the electron and sqlite3 in windows environment.
Setup of electron is quite simple but sqlite3 is some tricky to setup.So to setup electron and sqlite3 with minimum setup is as follows.

Install NodeJs



Install the electron-prebuilt 


Install the electron-rebuild as dev dependency


Install the sqlite3

Now it is time to pull node-gyp
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It bundles the gyp project used by the Chromium team and takes away the pain of dealing with the various differences in build platforms.

For detail node-gyp



Now we have to install build tools consisting   python 2.7 and visual c++  dependency so gyp can built our native module. Just run the command shown below and it will pull the necessary files automatically. I recommend to use this.


This command will take lots of time to download files. But don't close until

Full text search with TNTSearch in laravel

Image
Every site which has an aim to provide information to the end user inform of blog or artilce has to have an efficient search. You can do it with sql query using %like% and where queries. But its not sufficient. Some time user don't have idea about the text of field you are using so it might not get information through your site. So in that case we need some kind of thing that can do full-text search.
For example, You write an article name " Google ".             Google is a search engine. Search engine is the program that helps to find the information we need from the database. Google is one of the best search engines in the world. ... ..
Now you are just searching with name field with pure mysql. So if someone search for google. it will get result but , if will search for search engine result will be null. Here you can use full-text-search engine to resolve this problem.
We have several options for full-text-search engine Algolia SearchI have hear…

Infinite scroll using laravel pagination and jquery

Image
Loading the content dynamically at the end of the page when user reaches the end of the page.

It is quite easy to implement. So exactly what we want to do is
When page loads we want to show some posts.When user scrolls we want to load more posts and append it at the end. Upper to line gives hint what we want to do, show list of some post at  on page loading,when user scrollsfetch other posts via ajax and append it to the list of current post list. 
First Implement the code for the Controller In this function when request is simple get request it returns view with 9 latest posts. When it gets an ajax request instead of returning view it returns the compiled html of post and url for the next page in laravel pagination as the json array.

When data comes as json array we have to append that rendered output in the view file. So view file will be like this.Initially setting the next-page-url attribute of the div with id posts as the url of the next-page-url that is created by the normal lara…

Debug errors of external packages used in laravel project

Image
Sometime happens that you do everything that read me file said and still you get errors like class not found or file not found because you are getting just different version of package. The conman reason is below here. That might be unnoticed if you are beginner.


Composer Requirement Mismatch
Laravel packages are created by experienced Larvael and php developers. They are best at their work. But when we use that packages we get errors because we don't find out exact requirement for that package or at least for the particular version of the package.  For example requirement of the Laravel versionrequirement of the php version.
There are many packages which have different versions for the different laravel version or for different php version. For example, spatie/laravel-analyticsvinkla/Instagram etc.
Example We will go with example of spatie/laravel-analytics package because it is the package made me aware of this.
When you go for a package on github.com you will see the…

Creating Virtual Host In Apache

Image
DefinitionVirtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name.You can read more here
Wikipedia - Virtual Host

If you have purchase vps than you can use virtual host to host multiple site from the single vps ( or form single droplet if you use digitalocean). Most of vps provider gives linux based os because they are free. I will explain how to create and setup virtual host on digitalocean lamp stack with ubuntu 16.04

RequirementsUbuntu 16.04 with Apache

Install ApacheIf you don't have already installed then run this commands to install the apache on you os

sudo apt-get update
sudo apt-get install apache2


Setup folders for site to be hostedSite that are hosted has to be inside the /var/www folder

You can give any name to site folder. But it is good to give…

Upload image with WYSIWYG editor in laravel

Image
Almost every one who start learning any thing in web starts with creating a blogging web site in what ever technology or framework he starts to learn.
When we create blog site for learning we just consider the text, but real problem happens when we are building the real blogging site because now we have to consider the images also.

Most of the WYSIWYG  editors ( Summernote which is my favourite ) provides the facility to upload the image either through the url or user can upload image from the device. In those two situations

 If user uploads image via link then there is no problem as it just put a img tag and set's it's source to the url of imageBut if user uploads image from its device than img tag stores the image as base64 data.
Exact Idea So in the second option the actual image is sent to the server as the base64 encoded data,  That means if you applied summernote to a text area and upload a image than the request going to the server will look like

 <p> Image upload…

Debug Laravel App with Clockwork

Image
Laravel is written in the way you can easily track the bug by the error or expection thrown by the laravel. Laravel containas the facility of logging. It logs every thing that happens. It stores this log data in the file name larvel.log. Laravel.log file can be found in the storage/logs folder of your laravel project. Most problem will be solving in laravel if you able to understand the logged data. 

One thing that make us to use the external debuggers is run time data. Limitation of laravel's log is that it can not log the run time uninterpreted data, or at least i don't found the way to do so.  In this case we have two choise  1. we use the laravel's log driver and find the clever way to log the data of our interest.  2. We can use external debuggers like clockwork, laravel-debugger etc.

The reason i need to find package like this In the project puberstreet.com i had to use the polymorphic relation for likes. I was stuck in a problem where every thing was going right, wh…