Skip to content

Instantly share code, notes, and snippets.

View madhur's full-sized avatar
🎯
Focusing

Madhur Ahuja madhur

🎯
Focusing
View GitHub Profile
@madhur
madhur / starship.toml
Created July 17, 2023 05:02 — forked from nukopy/starship.toml
Nerd Font Symbols created by Starship. This is a Starship default config.
# Starship default config, extracted from the source
# Configure the format of the prompt
format = """\
$username\
$hostname\
$shlvl\
$singularity\
$kubernetes\
$directory\
@madhur
madhur / codemirror.js
Created December 22, 2020 13:00
codemirror.js
window.addEventListener("load", startLoading, false);
let codeMirror = null;
function startLoading() {
codemirror = document.querySelector(".CodeMirror").CodeMirror;
// console.log(codemirror);
//codeMirror = CodeMirror(document.body);
console.log(codeMirror);
codeMirror.execCommand("selectAll");
}
@madhur
madhur / trafficsplitter.java
Created November 29, 2020 05:02
Taffic splitting algorithm
package trafficsplitter;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Distributor implements IDistributor {
private int nextBucketIndex;
private char[] senderBuckets;
private Random r = new Random();
@madhur
madhur / my2.sql
Last active June 14, 2020 12:05
MySQL Stats collector
-- Create Database, Tables, Stored Routines and Jobs for My2 dashboard
create database IF NOT EXISTS my2;
use my2;
CREATE TABLE IF NOT EXISTS status (
VARIABLE_NAME varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
VARIABLE_VALUE varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
HOST varchar(128) CHARACTER SET utf8 DEFAULT 'MyHost', -- concat(@@hostname, ':', @@port),
TIMEST timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;
@madhur
madhur / javacert.sh
Created March 7, 2020 15:13
Import certificate into java keystore
#!/usr/bin/env bash
# Exit on error
set -e
# Ensure script is running as root
if [ "$EUID" -ne 0 ]
then echo "WARN: Please run as root (sudo)"
exit 1
fi
@madhur
madhur / pmd-rules.xml
Created January 26, 2020 10:17
My PMD Rules
<?xml version="1.0" ?>
<ruleset name="Custom Rules" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Tesseract custom rules
</description>
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" />
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration" />
@madhur
madhur / checks.xml
Created January 26, 2020 05:35
Checkstyle configuration
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
@madhur
madhur / docker-compose.yml
Last active September 11, 2019 05:54
graphite-statsd docker
version: '3'
services:
graphite-statsd:
image: graphiteapp/docker-graphite-statsd
ports:
- 2003-2004:2003-2004
- 2023-2024:2023-2024
- 8125:8125/udp
@madhur
madhur / longestplaindromic.java
Created August 12, 2019 01:54
longestpalindromic
class Solution {
public String longestPalindrome(String str) {
int index1=0;
int index2=0;
boolean isPalin = true;
if(str.length()==0) {
return str;
}
if(str.length()==1) {
@madhur
madhur / mergeinterval.java
Created August 7, 2019 16:59
merge intervals
// java.util.* and java.util.streams.* have been imported for this problem.
// You don't need any other imports.
public static ArrayList<Interval> insertRange(ArrayList<Interval> intervalsList, Interval insert) {
ArrayList<Interval> merged = new ArrayList<Interval>();
if(intervalsList.size() == 0) {
merged.add(insert);