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 / 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 / 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 / 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 / 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 / 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 / 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) {