Posts

Use Bleve as full text search engine for go app

Image
Bleve Bleve is full-text search library written in go. You can read this article if you are curious to know more about it Short Introduction To Bleve (medium.com)

There are lots of stuff that gives the info about bleve functionality but the problem is they don't provide the way to implement in your project and it is quite difficult for beginners.

I am writing this to show how to use bleve with your project for the full text search.

There are Four Operations 1. Create index files
2. Index the valid entities.
3. Search through the indices  for output
4. Delete invalid entities.
Creating the index files
Index the valid entities  You can ( and should ) create multiple index files according to data , need of search and performance You can increase performance by using the go routines to search throgh the mulitple indices concurrently.
Search throught the indices for output Using the go routines to search throgh the mulitple indices concurrently.
Here the searchResult is the output in …

Deploy Go Application in ubuntu

Image
golang has faciltity of cross compilation. So you can write a your application on any of supported  platform and deploy it over any supported platform. So will go step by step from compilation to deployment of the project over ubuntu server ( linux server )

Requirements 1. Linux Server I mostly use ubuntu but this also work with CentOs

2. FTP/sFTP Upload Tool  For windows I will recommand winScp Download
For Mac I personlly use ftp uploader provided by the mozzila as firefox addon Download

3. SSH Tool For windows i will recommand putty  Download
For Mac I personally use FireSSH  Download

Thats it.


Compile the project for the linux
(I am using the windows for this tutorial , but for mac the links are show where neccessary)

Run this command to compile the project













> set GOOS=linux 
upper command will set the golang host architecture to linux
( this is temporary change so after reboot it will set the original host. GOOS defines the platform/ architactre for which the code will build)

> g…

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…