Skip to content

Instantly share code, notes, and snippets.

View sagarchauhan005's full-sized avatar
🎯
Focusing

Sagar Chauhan sagarchauhan005

🎯
Focusing
View GitHub Profile
@sagarchauhan005
sagarchauhan005 / start-stop-ebs.sh
Last active February 25, 2020 06:29
Start/Stop/Pause elastic beanstalk environment shell script
#!/usr/bin/env bash
#$1 : Minimum number of instance
#$2 : Maximum number of instance
#<auto-scaling-group-name> : To find this, visit EC2 section in your aws management dashboard and in your left sidebar,
# click on AUTO SCALING GROUPS at the very bottom and it shall display all the scaling groups of your EBS.
# Select your group name from there.
RED="\033[1;31m\n"
NOCOLOR="\033[0m\n"
YELLOW='\033[0;33m'
select * from <table> where
ST_CONTAINS(
ST_GEOMFROMTEXT(
CONCAT(
'POLYGON((
', json_unquote(json_extract(column_name, '$.rectangle.bounds."north-east".lng')), '
', json_unquote(json_extract(column_name, '$.rectangle.bounds."north-east".lat')), ',
', json_unquote(json_extract(column_name, '$.rectangle.bounds."north-west".lng')), '
', json_unquote(json_extract(column_name, '$.rectangle.bounds."north-west".lat')), ',
', json_unquote(json_extract(column_name, '$.rectangle.bounds."south-west".lng')), '
@sagarchauhan005
sagarchauhan005 / demo.php
Last active May 16, 2020 22:53
Codility Binary Gap Demo Test solution
function solution($N) {
// write your code in PHP7.0
if($N!=null){
$bin = decbin($N);
$binArr = str_split($bin);
//print_r($binArr);
$pos = array_keys($binArr,1);
//print_r($pos); return;
$diff = [];
if(sizeof($pos)>1){
(function (window, document) {
window.domEventsHandler = (function (window, document) {
let srcElement;
/*
* Options value for the highlighter
* */
const opt = {
ignoreElem: ['head', 'meta', 'link', 'style', 'title', 'script'], // elements to ignore
queryElem : 'img, a, button, input, textarea', // elements to track on click
@sagarchauhan005
sagarchauhan005 / deployer.sh
Last active January 19, 2021 10:33
deployer.sh
#!/usr/bin/env bash
RED="\033[1;31m\n"
NOCOLOR="\033[0m\n"
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
if [[ $EUID -ne 0 ]]; then
printf "${RED}This script must be run as root${NOCOLOR}"
exit 1
@sagarchauhan005
sagarchauhan005 / search.js
Last active December 1, 2021 11:19
Kartmax Search Integration Axios Call with Analytics
//Building Origin Search Payload
let form=null;
form.collection = "K50qtol4isMqmdFjz6xnWCFz5oAc3s";
form.query = this.$route.query.q;
var authOptions = {
method: "get",
url: `https://ai.kartmax.in/api/{{enter_your_app_id_here}}/search-get/v1/plp-special`,
headers: {
"Content-Type": "application/json",
@sagarchauhan005
sagarchauhan005 / mysql-get-each-table-size.sql
Created September 23, 2021 06:07
Mysql get size of each table in MB in a column.
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "$table_name"
ORDER BY (data_length + index_length) DESC;
#Method 1 (https://stackoverflow.com/questions/879327/quickest-way-to-delete-enormous-mysql-table)
CREATE TABLE new_foo LIKE foo;
RENAME TABLE foo TO old_foo, new_foo TO foo;
DROP TABLE old_foo;
#Method 2 (https://stackoverflow.com/questions/2300396/force-drop-mysql-bypassing-foreign-key-constraint)
SET foreign_key_checks = 0;
Truncate table foo;
@sagarchauhan005
sagarchauhan005 / google-fonts-extracted.json
Created January 19, 2022 07:08
Google Fonts List JSON
[
{
"value":"ABeeZee",
"name":"ABeeZee"
},
{
"value":"Abel",
"name":"Abel"
},
{