Skip to content

Instantly share code, notes, and snippets.

View madan712's full-sized avatar

Madan Chaudhary madan712

View GitHub Profile
@madan712
madan712 / dragable_swipeable.js
Last active April 28, 2024 16:13
React native draggable and swipeable list
import DraggableFlatList, { ScaleDecorator } from 'react-native-draggable-flatlist'
import SwipeableItem from 'react-native-swipeable-item'
.
.
.
const itemRefs = React.useRef(new Map())
<DraggableFlatList
activationDistance={15}
data={getCategoriesFromTaskList()}
@madan712
madan712 / ReadWriteExcelFile.java
Created October 18, 2012 14:35
Read / Write Excel file (.xls or .xlsx) using Apache POI
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@madan712
madan712 / WindowsProcessKiller.java
Created October 31, 2013 08:44
Java program to kill a runnning windows process
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WindowsProcessKiller {
// command used to get list of running task
private static final String TASKLIST = "tasklist";
// command used to kill a task
private static final String KILL = "taskkill /IM ";
@madan712
madan712 / export_db_csv.py
Created June 27, 2019 20:12
Python - Export database table to csv file
import mysql.connector
def fetch_table_data(table_name):
# The connect() constructor creates a connection to the MySQL server and returns a MySQLConnection object.
cnx = mysql.connector.connect(
host='localhost',
database='schema',
user='user',
password='password'
@madan712
madan712 / deploy.sh
Created March 18, 2024 21:18
Shell script to manage docker process using pm2
#!/usr/bin/env bash
set -euo pipefail
# Variables
IMAGE_NAME="my_image_name"
CONTAINER_NAME="my_container_name"
TAG="latest"
# Build Docker image
@madan712
madan712 / PopupDiv.html
Last active January 18, 2024 18:23
Open Popup div with disabled background using Javascript
<HTML>
<HEAD>
<TITLE>Popup div with disabled background</TITLE>
<style>
.ontop {
z-index: 999;
width: 100%;
height: 100%;
top: 0;
left: 0;
@madan712
madan712 / export_db.py
Last active January 10, 2024 17:48
Python - export mysql table to excel file
import xlsxwriter
import mysql.connector
def fetch_table_data(table_name):
# The connect() constructor creates a connection to the MySQL server and returns a MySQLConnection object.
cnx = mysql.connector.connect(
host='localhost',
database='schema',
user='user',
@madan712
madan712 / App.js
Last active January 6, 2024 07:17
React simple rich text editor using draft-js
import React, { useState } from 'react';
import { Editor, EditorState, RichUtils } from 'draft-js';
import {
FaBold,
FaCode,
FaHeading,
FaItalic,
FaListOl,
FaListUl,
@madan712
madan712 / .js
Created December 31, 2023 15:26
Node lambda function using AWS SDK javascript v3 to fetch quicksight embed url
const {STSClient, AssumeRoleCommand} = require("@aws-sdk/client-sts");
const {QuickSightClient, GetDashboardEmbedUrlCommand, RegisterUserCommand} = require("@aws-sdk/client-quicksight");
const AWS_REGION = "us-east-1";
const AWS_ACCOUNT_ID = "123456789012";
const QUICKSIGHT_ROLE_ARN = `arn:aws:iam::${AWS_ACCOUNT_ID}:role/QuicksightDashboardViewer`;
const stsClient = new STSClient({
region: AWS_REGION
});
@madan712
madan712 / .js
Created December 31, 2023 15:22
AWS SDK javascript v3 to get quicksight embed url
const getEmbedUrl = async (qsClient, dashboardId) => {
console.log(`Fetching embed url`);
const param = {
AwsAccountId: AWS_ACCOUNT_ID,
DashboardId: dashboardId,
IdentityType: "IAM",
UndoRedoDisabled: true,
ResetDisabled: true
};