Skip to content

Instantly share code, notes, and snippets.

View vithalreddy's full-sized avatar
🔥

Vithal Reddy vithalreddy

🔥
View GitHub Profile
@vithalreddy
vithalreddy / rules_of_trade.md
Last active March 22, 2024 06:18
Rules of Trade -> FnO Options selling

✨ Rules of Trade ✨

  • Entry is free, Exit is not 🙅‍♂️
    • Don't enter, if you do enter follow the rules of engagement
    • Wait for SL and TP
    • One sec away from screen can blow your account 💯
  • Strike Selection and RR ratio Matters📊
    • Before entering any trade, please check it's strike price, delta and RR ratio
  • RRR: Your Key to Success🔑
    • Only Risk management is the real edge, everything else is just the smoke
/*
JSON-to-Go
by Matt Holt
https://github.com/mholt/json-to-go
A simple utility to translate JSON into a Go type definition.
*/
function jsonToGo(json, typename) {
let data;
let scope;
@vithalreddy
vithalreddy / cursortable.js
Created May 6, 2022 10:10 — forked from nmoinvaz/cursortable.js
Antd Cursor Paginated Table Component
import React, { useEffect, useState } from "react";
import { Table, Button, Space, Row, Col } from "antd";
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
const CursorPagination = ({ lastEvaluatedKey, onChange, size }) => {
/* Use stack to keep track of which evaluated keys have been previously seen */
const [ prevEvaluatedKeys, setPrevEvaluatedKeys ] = useState([]);
/* Keep track of the current evaluated key */
const [ currentEvaluatedKey, setCurrentEvaluatedKey ] = useState(null);
@vithalreddy
vithalreddy / mysql - kill all sleeping connections
Created January 11, 2022 07:33 — forked from lucashungaro/mysql - kill all sleeping connections
MySQL - kill command for all idle queries
SELECT GROUP_CONCAT('kill ',id SEPARATOR '; ') AS kill_list
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE command='Sleep';
@vithalreddy
vithalreddy / cloudwatch_log_insights_mysql_slow_query_examples.md
Created November 8, 2021 12:15 — forked from grocky/cloudwatch_log_insights_mysql_slow_query_examples.md
CloudWatch Log Insights query examples for MySQL slow query log.

Filtering queries

Find slowest write queries

parse @message /Query_time: (?<queryTime>.*?) Lock_time: (?<lockTime>.*?) Rows_sent: (?<rowsSent>.*?) Rows_examined: (?<rowsExamined>.*?)\s(?<query>.*?)$/
  | filter @message like /(?i)insert/
  | sort queryTime desc
  | limit 10
@vithalreddy
vithalreddy / verifyPasswordStrength.js
Created May 7, 2020 09:49
Password Strength Validation function for Javascript/Typescript with configurable options
const passwordConfig = Object.freeze({
minLength: 8,
atleaseOneLowercaseChar: true,
atleaseOneUppercaseChar: true,
atleaseOneDigit: true,
atleaseOneSpecialChar: true,
});
function verifyPasswordStrength(password) {
if (
@vithalreddy
vithalreddy / Javascript settimeout in promise chain.js
Last active January 6, 2020 07:58
Javascript settimeout in promise chain
// example code for blog post
// https://stackfame.com/javascript-settimeout-promise-chain
makeHttpCall("https://api.stackfame.com/1")
.then(function(data) {
return makeHttpCall("https://api.stackfame.com/2");
})
.then(function(data) {
return loadScript("https://api.stackfame.com/3");
})
.then(function(data) {
@vithalreddy
vithalreddy / TaylorSeries.js
Created November 13, 2019 06:23
Taylor Series using Horner's Rule in Javascript
function ex(x, n, s = 1) {
if (n === 0) return s;
s = 1 + (x * s) / n;
return ex(x, n - 1, s);
}
console.log(ex(1, 10)); // 2.7182818011463845
console.log(ex(5, 10)); // 146.38060102513225

Keybase proof

I hereby claim:

  • I am vithalreddy on github.
  • I am vithalreddy (https://keybase.io/vithalreddy) on keybase.
  • I have a public key whose fingerprint is 6293 F1F2 EC2D DC04 FD04 A909 8259 DCE2 BE2F C760

To claim this, I am signing this object:

@vithalreddy
vithalreddy / pandas.py
Created August 4, 2019 05:52
Inverse of pandas json_normalize or json_denormalize – python pandas
# more at https://stackfame.com/inverse-of-pandas-json_normalize-or-json_denormalize-python-pandas
def make_formatted_dict(my_dict, key_arr, val):
"""
Set val at path in my_dict defined by the string (or serializable object) array key_arr
"""
current = my_dict
for i in range(len(key_arr)):
key = key_arr
if key not in current: