Skip to content

Instantly share code, notes, and snippets.

View vinkrish's full-sized avatar
🎯
Focusing

Vinay Krishna vinkrish

🎯
Focusing
View GitHub Profile
@vinkrish
vinkrish / bash_command.md
Last active July 2, 2023 16:10
Linux Commands

clear
sudo apt=get update && sudo apt-get upgrade

whoami
hostname
ls
ls -l
@vinkrish
vinkrish / git-commands.md
Last active May 1, 2023 01:27
Git Handy Commands

Setting up a repo

$ git init
will initialize git repository in current directory
(or)
$ git clone ssh://vinay@example.com/path/to/my-project.git
$ cd my-project

$ git remote -v
to know about remote repos

@vinkrish
vinkrish / javacmd.txt
Last active April 16, 2022 17:19
Commands for building java application
vi ~/.bash_profile
vi /Users/vinkrish/.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
source ~/.bash_profile
echo $JAVA_HOME
/usr/local/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home
earlier JAVA_HOME:
LEARN KUBERNETES BASICS:
Create a Cluster:
minikube version
minikube start
kubectl version
kubectl cluster-info
kubectl get nodes
@vinkrish
vinkrish / query_builder.js
Created February 12, 2022 22:20
NodeJS implementation to generate condition for Query Builder used in frontend. eg: https://github.com/zebzhao/Angular-QueryBuilder, https://github.com/ukrbublik/react-awesome-query-builder
let findAndOrCondition= (obj) => Object.entries(obj).filter(([key, value]) => key === 'condition' && value === 'and' || value === 'or');
const constructCondition = (conditionString, rule_object) => {
if(findAndOrCondition(rule_object).length > 0) {
conditionString.val += '('
let rules = rule_object.rules
console.log('rules', rules)
for(var i=0; i<rules.length; i++) {
let rule_obj = rules[i]
if(findAndOrCondition(rule_obj).length > 0) {
@vinkrish
vinkrish / extract_sql_excel.py
Created February 12, 2022 21:16
Extract SQL from excel
from os.path import join, dirname, abspath
import xlrd
xlrd.xlsx.ensure_elementtree_imported(False, None)
xlrd.xlsx.Element_has_iter = True
fname = join(dirname(dirname(abspath(__file__))), 'dir_name', 'file_name.xlsx')
xl_workbook = xlrd.open_workbook(fname)
@vinkrish
vinkrish / excel_import.py
Created February 12, 2022 21:11
Import data directly from google sheets
from os.path import join, dirname, abspath
import psycopg2
import psycopg2.extras
import xlrd
xlrd.xlsx.ensure_elementtree_imported(False, None)
xlrd.xlsx.Element_has_iter = True
fname = join(dirname(dirname(abspath(__file__))), 'dir_name', 'file_name.xlsx')
Visual Studio Code:
Ctrl+' = Toggle Terminal
Cmd + P = Go to File
Cmd + o = Opens file in finder
Cmd + Shift + k = Delete Line
Shift + Alt + F = Format with Indentation
Shift + Cmd + L = multi-word selection
Cmd + Alt + Up/Down = Selects in a column directly up or down from the cursor's position
Ctrl + k + 0 = Fold all section
Ctrl + k + j = Unfold all section
@vinkrish
vinkrish / Designing Event-Driven Systems links.md
Created January 7, 2022 22:33 — forked from giampaolotrapasso/Designing Event-Driven Systems links.md
List of links from Designing Event-Driven Systems by Ben Stopford
@vinkrish
vinkrish / find-in-json.js
Created October 20, 2021 08:43 — forked from iwek/find-in-json.js
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //