Posts

Showing posts from December, 2017

word count tool | wordcounter

Image
I have to write a post for Alibaba cloud platform. I come to know that the post has to be 1300-1500 word long. So I write a post and that searched for a word counter tool. 
In the search result, i found two site
wordcounter.networdcounter.io
wordcounter . networdcounter.net is the best site I found. It gives more details than just count of the word. 
It gives the information of 
characterswordssentence paragraphs word density
have been written. 
In additions, it also provides information like,
Reading levelReading timespeaking time

datastore remove index

Image
Cloud Datastore imposes limits on the number and overall size of index entries that can be associated with a single entity. These limits are large, and most applications are not affected. However, there are circumstances in which you might encounter the limits. Types of Datastore index Built-in indexes By default, Cloud Datastore automatically predefines an index for each property of each entity kind. These single property indexes are suitable for simple types of queries. Composite indexes Composite indexes index multiple property values per indexed entity. Composite indexes support complex queries and are defined in an index configuration file (index.yaml). Cost Counting for Datastore write In the current pricing model, inserting a new entity costs 2 write operations for the entity + 2 write operations per index. here index may be the composite index or built-in index ( single property index). You can remove composite index using either gcloud tool or appcfg


Remove composite Datastore indexTo r…

Host secured laravel 5.x appliaction on ubuntu 16.04 vps with apache

Image
Aim

The aim of this tutorial is to show how to migrate the local laravel 5.x project to the Ubuntu 16.04 vps. We will see how to setup the vps for hosting from scratch. We also see the ways you can copy your laravel project to the vps and at last we will see how to secure your project with ssl using the lets encrypt. we will also add a cron job to auto update the ssl certificate. PrerequisitesTo follow this guide along you will require this  Ubuntu vps with 16.04 laravel project you want to hostssh clientFor windows you can use puttyFor Mac you can use terminalsftp clientFor windows you can use winscpFor Mac you can use cyberduckGitRemote Git repository ( optional )Steps Now after gathering the required elements you can follow these steps to host your laravel 5.x project. Prepare the vps for the web hostingInstall PhpInstall Mysql Install ApacheInstall GitCopy and setup the local laravel project on vpsCopying the projectUsing sftpUsing gitInstall the dependenciesSetup the project and run m…

use hilite me for code sharing on your site

Image
I have seen many sites which are sharing the code snippets having a good look. Like having the sublime like format. One example is laravel-news.com. In my early posts, I was used to putting the code as it as without any formatting other than making the code in italic.


After certain posts, I started to use GitHub gist for sharing. But the gist was not the actually for what I was looking. Though it was quite good for code sharing thing is that it was not giving the look I was wanting.



After searching for certain days I find hilite.me which is actually I was looking for. A site/service that takes programming language code as input makes the syntax highlight and puts in the box of CSS we have defined.

It actually provides HTML-CSS code which can paste on the blog to share the code with specific highlight and format.
Here is my favorite CSS for the box



( Code for the box below you are seeing is also generated with hilite.me )


background:#111111;overflow:auto;width:auto;color:#eee;font-size:19px;…

Use Cli based Utilties and application with golang

Image
Actually, this post is about " use cli based utilities and application with golang", but I will explain it using the example of the 7zip.

The best way I found for zip extraction is using the 7zip cli. This is just sample how you can use any cli based application with your golang project. I will explain it using the example of 7zip cli.


( I am assuming that you have basic knowledge of golang )

What we are going to do is we will make cli command calls from our golang app using the os/exec package
For details of os/exec package please visit this official doc.

Let's see the code of unzipping of the archive using cli and golang

cmd:=exec.Command("7z","e","path-to-file")err:=cmd.Run()iferr!=nil{fmt.Println("error during extraction:",err.Error())continue}


In this code first, we are getting the command struct for our cli based process.

Here Command takes the name of cli utility as the first argument like 7z or echo.

For the simplest example,
if you …

golang oauth2 facebook example

Image
Todays most sites are integrated with social platforms like twitter, facebook, google plus for one or other purpose. I am writing this post to show how you can integrate Facebook with your golang app using facebook oauth2.

Just Some Word About OAuth2

OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and DigitalOcean.
For More information read this article ReadMore
Create App For FacebookTo integrate Facebook with your golang app, first of all, you have to need a facebook app_id and app_secret. Those are app identifiers for facebook. 

To create an app on facebook you should have an account on Facebook ( and ( think you might have already ). Using your Facebook account login on developer.facebook.com



 After login click on MyApps dropdown and click on Add a New App Button




Create New AppId by providing the Display name and contact email address.
After creation of your new app, you will see the da…

String trim in the golang

I found it somewhat confusing at first sight and done lots of buggy code due to the misunderstanding of the trim functions.
TrimLeft
func TrimLeft(s string, cutset string) string as shown in the trimleft function it takes two arguments  Input stringcutset string Here cutset string is not the string it means the string made of the runes you want to trim from left side until a rune found that is not defined in the cutset string
For example,

cutted_string := trimleft ( "hello manish","he")fmt.println(cutted_string )

It will give output string as  "llo manish"
Now lets edit the cutset string,
cutted_string := trimleft ( "hello manish","hel")

fmt.println(cutted_string )
If you are like me you might be expecting this output "lo manish" But its exctual ouput is "o manish" The reason is trim left trims the runes ( characters ) from left side until a rune found that is not inside the cutset list.  If you want to trim the string/word "h…

Parse Custom Delimeter Seperated File In Golang With encode/csv Package

Image
Package csv reads and writes comma-separated values (CSV) files. There are many kinds of CSV files; this package supports the format described in RFC 4180.
A csv file contains zero or more records of one or more fields per record. Each record is separated by the newline character. The final record may optionally be followed by a newline character. For More


CSV stands for the " comma seperated values ", But you can parse the file with any custom defined delimeter with the encode/csv package of golang. For example ,you can use pipe ( | ) symbol or underscoer (_) as delimiter insted of comma.


Writing A Pipe Seperated File With encode/csvHere is the example in which we are encoding the string of array to a csv
Here we are sending output to standard output. But you can also store it in file.
Output Is
First_name|last_name|username
Rob|Pike|rob
Ken|Thompson|ken
Robert|Griesemer|gri





You can also read a file with custom delimiter.The paramter that defines the delimiter is w.Comma. Here Comma f…