Skip to content

Instantly share code, notes, and snippets.

View gayanvirajith's full-sized avatar
:octocat:

Gayan Virajith gayanvirajith

:octocat:
View GitHub Profile
@gayanvirajith
gayanvirajith / formatArrayIntoComma.js
Created July 23, 2015 11:14
Join the elements in an javascript array, but let the last separator be different eg: `and` / `or`
/*
* Join the elements in an javascript array,
* but let the last separator be different eg: `and` / `or`
* Stackoverflow link: http://stackoverflow.com/questions/15069587/is-there-a-way-to-join-the-elements-in-an-js-array-but-let-the-last-separator-b
* Credit: Chris Barr - http://stackoverflow.com/users/79677/chris-barr
*/
function formatArray(arr){
var outStr = "";
if (arr.length === 1) {
outStr = arr[0];
@gayanvirajith
gayanvirajith / packetbeat-readme.md
Last active July 28, 2022 22:39
How to install packetbeat in ubuntu

Install packetbeat in ubuntu

sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install packetbeat

Configure

@gayanvirajith
gayanvirajith / install-docker_amazon_linux.sh
Last active October 23, 2021 11:17
Install docker cli in amazon linux
#
# Install docker in amazon linux ec2 instance
#
### Docker
sudo amazon-linux-extras install docker -y
sudo yum install docker -y
@gayanvirajith
gayanvirajith / readme.md
Last active September 19, 2021 15:14
mongo db docker

setup mongo on docker

Create bridge network

docker network create mynet

Pull docker and run as a deamon

@gayanvirajith
gayanvirajith / python-beatifulsoup.py
Last active August 17, 2021 07:51
Extract html table column values using python 3 and beautifulsoup4
from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd
html = urlopen("http://localhost:8080")
soup = BeautifulSoup(html, "html.parser")
table = soup.find("table")
files = {'path': []}
@gayanvirajith
gayanvirajith / visual-studio-vim.md
Last active June 22, 2021 00:46
Visual studio vim troubleshoot
@gayanvirajith
gayanvirajith / react-autoformatters.md
Last active June 5, 2021 12:41
React formatters and git hooks

React formatters and git hooks

Note: On visual studio code you should installed Eslint and Prettier plugins

Install dev dependencies.

npm i prettier eslint-config-prettier eslint-plugin-prettier --save-dev
@gayanvirajith
gayanvirajith / sample-command-line.js
Created June 3, 2021 05:42
Node command line arg sample
const commandLineArgs = require("command-line-args");
const commandArgs = commandLineArgs([
{
name: "check",
type: Boolean
},
{
name: "export",
type: Boolean
autonumber

Title: ATM Flow

_: ** Withdraw cash **

USER -> ATM: Insert card

ATM -> BANK: Verify card
@gayanvirajith
gayanvirajith / create-pem.md
Last active March 17, 2021 12:03
create pem for mongo db | robot3t

Create pem for ssh

ssh-keygen -m PEM -t rsa
ssh-keygen -m PEM -t rsa -C "your_email@example.com"
eval "$(ssh-agent -s)"