Skip to content

Instantly share code, notes, and snippets.

View charusat09's full-sized avatar

Mayurkumar charusat09

View GitHub Profile
@charusat09
charusat09 / gist:bfc3c10d160323ef75b5fb2ed54b5e5b
Created September 1, 2021 12:55
Add Puma service to systemctl for Puma v5+
cd /etc/systemd/system
sudo vim puma.service
# add the follwing code to the above file:
---------------------------------------------------------------------------------------
[Unit]
Description=Puma HTTP Server
After=network.target ??
[Service]
Type=simple
import json
import boto3
connect = boto3.client("connect")
def lambda_handler(event, context):
destinationNo = event['destinationNo']
response = connect.start_outbound_voice_contact(
DestinationPhoneNumber=destinationNo,
ContactFlowId="5bcb4f57-0d7a-4ff0-9147-34134b74efd2",
#!/bin/bash
USEDMEMORY=$(free -m | awk 'NR==2{printf "%.2f\t", $3*100/$2 }')
TCP_CONN=$(netstat -an | wc -l)
TCP_CONN_PORT_80=$(netstat -an | grep 80 | wc -l)
USERS=$(uptime |awk '{ print $6 }')
IO_WAIT=$(iostat | awk 'NR==4 {print $5}')
aws cloudwatch put-metric-data --metric-name memory-usage --dimensions AutoScalingGroupName=RailsAlpha --namespace "Custom" --value $USEDMEMORY --region us-west-2
@charusat09
charusat09 / ex1TrainingSet.txt
Last active December 25, 2018 17:07
Predict House Price based on Area in feet, Locality, No of Bed Rooms. I have created this demo project while completing my ML course
850,3,3,4500000
1000,4,4,3500000
585,3,3,3100000
801,4,4,5500000
729,4,3,4200000
776,4,3,4500000
700,2,3,7100000
800,4,3,4400000
1500,3,5,10000000
1800,3,4,7500000
@charusat09
charusat09 / share_db._with_multiple_apps_on_heroku.txt
Created July 25, 2018 06:41
Share one db across multiple apps on Heroku
heroku addons:destroy heroku-postgresql
heroku addons:attach DB_ADDON_NAME -a appname
# DB_ADDON_NAME may looks like postgresql-silhouetted-xxxxx
@charusat09
charusat09 / user-data for ruby on rails setup on ubuntu 16.04 OS
Created July 18, 2018 06:14
This will make system ready by installing all necessary packages and ruby 2.4
apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_8.x | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update
apt-get install -y libmysqlclient-dev
apt-get install -y mysql-client
apt-get install -y imagemagick
apt-get install -y imagemagick-common
class Rotator
attr_accessor :id, :values
BASE = 10
def initialize(id, values)
@id = id
@values = values
end
def rotate
@charusat09
charusat09 / csv_parser.rb
Created May 3, 2018 11:00
This script will read data from provided file and also use master data file to map ids to data from it.
require "csv"
require "byebug"
class ParseCSV
attr_reader :file, :store, :table
def initialize(file_path)
@file = CSV.read(file_path, headers: true, row_sep: :auto)
@table = CSV.read("table.csv", headers: true, row_sep: :auto)
@store = []
PER_1 = 20
PER_2 = 35
PER_3 = 45
POOL_SIZE = 10
ids = [*(1..1000)]
a1 = (PER_1 / POOL_SIZE).ceil
a2 = (PER_2 / POOL_SIZE).ceil
a3 = POOL_SIZE - a1 - a2
@charusat09
charusat09 / zlib_test.rb
Last active May 1, 2018 12:50
Zlib CRC32 alogorithm test
require "zlib"
# total percentage = 100
PER_1 = 20
PER_2 = 30
PER_3 = 50
ids = [*(1..1000)].map(&:to_s)
libs = []