Skip to content

Instantly share code, notes, and snippets.

View chetanppatil's full-sized avatar

Chetan Patil chetanppatil

View GitHub Profile
@chetanppatil
chetanppatil / install-postman.sh
Last active June 10, 2023 17:11
Install Native Postman On Linux
#!/bin/bash
# Download Postman
cd /tmp || exit
echo "Downloading Postman..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
# Extract and install Postman to /opt
echo "Extracting and installing to /opt..."
sudo tar -xzf postman.tar.gz -C /opt/
@chetanppatil
chetanppatil / get_all_depending_functions.sql
Created April 24, 2018 11:07
Get all functions depending on specified table in postgre
/* HERE
table name is "my_table"
\m and \M mark the beginning and end of a word in the regexp match.
*/
SELECT n.nspname AS schema_name
,p.proname AS function_name
,pg_get_function_arguments(p.oid) AS args
,pg_get_functiondef(p.oid) AS func_def
FROM (SELECT oid, * FROM pg_proc p WHERE NOT p.proisagg) p
@chetanppatil
chetanppatil / regex.js
Created April 30, 2018 05:50
Most commonly used regex, ES6
const phoneRegx = RegExp(/^[0]?[789]\d{9}$/)
const emailRegx = RegExp( /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)
let phoneNumber = '9999999999'
let email = '[email protected]'
console.log('PHONE REGX:= ', phoneRegx.test(phoneNumber));
console.log('EMAIL REGX:= ', emailRegx.test(email));
@chetanppatil
chetanppatil / get_json_key_value.sql
Last active May 11, 2018 10:31
Get/Select values from array of json in PostgreSQL
SELECT ele->>'partCode' FROM json_array_elements('[{"partCode": "sdvsv", "partName": "sdvfv", "problemCatagory": "Dock Related"}]'::json) AS ele
@chetanppatil
chetanppatil / get_values_as_column_from_json.sql
Created May 11, 2018 10:26
Select data from json and insert it into single row and multiple column
CREATE TABLE my_table(col text, col2 text)
/* SELECT DATA FROM JSON */
SELECT * FROM json_each('{"a":"foo", "b":"bar"}') AS e
/* INSERT INTO TABLE */
INSERT INTO my_table(col, col2)
SELECT * FROM json_to_record('{"a":"foo", "b":"bar"}') AS x(col text, col2 text) -- as can have different column name
SELECT * FROM my_table
@chetanppatil
chetanppatil / install-sonar-scanner.sh
Last active December 28, 2023 04:31
Install sonar-scanner in linux mint, ubuntu...
#!/bin/bash
cd /tmp || exit
echo "Downloading sonar-scanner....."
if [ -d "/tmp/sonar-scanner-cli-4.7.0.2747-linux.zip" ];then
sudo rm /tmp/sonar-scanner-cli-4.7.0.2747-linux.zip
fi
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
echo "Download completed."
@chetanppatil
chetanppatil / teminate-connection-postgres.sql
Created July 26, 2018 06:04
Terminate connection/session in PostgreSQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = '<db-name-here>';
@chetanppatil
chetanppatil / set-dbeaver-timezone-to-UTC.md
Last active December 19, 2023 01:34
Set dbeaver timezone to UTC (default timezone)

For Linux Users

  1. Go to directory: /usr/share/dbeaver
  2. Edit dbeaver.ini file
  3. In that file add -Duser.timezone=UTC this line under -vmargs tag
  4. Save it and restart dbeaver.
  5. Enjoy with correct date without any date conversion.

Finally your dbeaver.ini file will look like this:

@chetanppatil
chetanppatil / Robo3T-Installation-Menu.sh
Last active May 10, 2023 03:54
Robo mongo 3t installation and creating shortcut
#!/bin/bash
set -e
ROBO_VERSION="1.2.1"
ROBO_FILE="robo3t-$ROBO_VERSION-linux-x86_64-3e50a65.tar.gz"
ROBO_URL="https://download.robomongo.org/$ROBO_VERSION/linux/$ROBO_FILE"
ROBO_DIR="/opt/RoboMongo"
echo "Downloading Robomongo..."