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 / 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')
@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 == '') { //
@vinkrish
vinkrish / list-of-curl-options.txt
Created July 26, 2021 18:20 — forked from eneko/list-of-curl-options.txt
List of `curl` options
$ curl --help
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--alt-svc <file name> Enable alt-svc with this cache file
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
-E, --cert <certificate[:password]> Client certificate file and password
@vinkrish
vinkrish / bash-cheatsheet.sh
Created June 15, 2021 15:27 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
Get fresh ubuntu machine:
vagrant init ubuntu/trusty64
vagrant up --provider virtualbox
SSH into newly built machine:
vagrant ssh
Dispose machine using:
vagrant destroy
@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:
@vinkrish
vinkrish / download-file.js
Created April 2, 2020 08:31 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);