Skip to content

Instantly share code, notes, and snippets.

View vishichoudhary's full-sized avatar
🌴
On vacation

Vishal Choudhary vishichoudhary

🌴
On vacation
View GitHub Profile
@vishichoudhary
vishichoudhary / delete_all_kafka_topics.sh
Created April 7, 2020 06:46
delete all kafka topics
#!/bin/bash
kT='/Users/vishalchoudhary/confluent-5.3.0/bin/kafka-topics'
TOPICS=$($kT --zookeeper localhost:2181 --list )
echo $TOPICS
for T in $TOPICS
do
if [ "$T" != "__consumer_offsets" ]; then
$kT --zookeeper localhost:2181 --delete --topic $T
@vishichoudhary
vishichoudhary / psql-error-fix.md
Created March 13, 2020 19:22 — forked from AtulKsol/psql-error-fix.md
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@vishichoudhary
vishichoudhary / time_format.go
Created September 29, 2019 14:37
10 minute of hard work
--------------- + ------------ + ------------
Type | Placeholder | Example values
--------------- + ------------ + ------------
Year | 2006 | 1609
Year | 06 | 09
Month | 01 | 09
Month | 1 | 9
Month | Jan | Sep
Month | January | September
Day | 02 | 12
Cassandra need jdk8
Install it with
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
brew cask install won't work see https://stackoverflow.com/questions/24342886/how-to-install-java-8-on-mac
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
@vishichoudhary
vishichoudhary / fetchSingleColumn.sh
Created July 12, 2019 11:50
Command to fetch a single column from csv
awk -F "\"*,\"*" '{print $2}' pincodes.csv
python -c "import random, sys; x = open(sys.argv[1]).readlines(); random.shuffle(x); print ''.join(x)," shuffle_mylines.txt
@vishichoudhary
vishichoudhary / openvpn-install.sh
Created June 19, 2019 15:10
open vpn isntallation file
#!/bin/bash
#
# https://github.com/Nyr/openvpn-install
#
# Copyright (c) 2013 Nyr. Released under the MIT License.
# Detect Debian users running the script with "sh" instead of bash
if readlink /proc/$$/exe | grep -q "dash"; then
echo "This script needs to be run with bash, not sh"
@vishichoudhary
vishichoudhary / generateRandomLatLng.py
Created June 18, 2019 07:07
generate random lat and long
from random import randint
n = int(input())
for i in range(n):
print("{")
value = str(randint(-180, 180))
factor = ("%0.6f" % (randint(1,80)*1.0 / randint(1,80)) ).split('.')[1]
lat = value+"."+factor
value = str(randint(-180, 180))
factor = ("%0.6f" % (randint(1,80)*1.0 / randint(1,80)) ).split('.')[1]
@vishichoudhary
vishichoudhary / red_knight_problem.cpp
Created November 14, 2018 18:42
red knight problem
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ulli unsigned long long int
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
import abc
from plugin import PluginFunctions, PluginPriority
class PluginBasic(metaclass=abc.ABCMeta):
@abc.abstractmethod
def activate(self):
"""
Will activate the plugin, this function will be trigrred by enabling the plugin.
Every plugins need to inherit this.