Skip to content

Instantly share code, notes, and snippets.

@anvinjain
anvinjain / index.html
Created July 5, 2017 14:52
FkProf Policy Calculator // source https://jsbin.com/wumoqif
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<title>FkProf Policy Calculator</title>
</head>
<body>
<table>
@anvinjain
anvinjain / BasicAuthenticationFilter.java
Created July 7, 2017 09:09 — forked from neolitec/BasicAuthenticationFilter.java
HTTP Basic authentication Java filter
package com.neolitec.examples;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@anvinjain
anvinjain / incognito_check_disable.js
Last active April 30, 2018 18:55
TamperMonkey Script: Disable Incognito Mode check by websites in Chrome
// ==UserScript==
// @name Disable detection of incognito mode in browser by HOTSTAR website
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prevent sites detecting if you're in incognito by calling the success callback of webkitRequestFileSystem even if it's failing.
// @author You
// @run-at document-start
// @match *://www.hotstar.com/*
// @grant none
// ==/UserScript==
@anvinjain
anvinjain / torrent_unhealthy_detection
Created June 22, 2018 06:36
torrent unhealthy detection
int dls_mark = x kbps; //download speed threshold
int dlt_mark = x secs; //download speed observation window
int dpt_mark = x secs; //connected peers observation window
int cpt_mark = x secs; //discovered peers observation window
if dl_speed > dls_mark { dl_ts = now(); return true; }
if now() - dl_ts > dlt_mark { return false; }
if connected_peers > 1 { cpt_ts = now(); return true; }
if now() - cpt_ts > cpt_mark { return false; }
if discovered_peers > 1 { dpt_ts = now(); return true; }
@anvinjain
anvinjain / bytes_arr_test.go
Created July 4, 2018 05:53
Golang Byte Array creation: append vs bytes.Join Benchmark
package main
import (
"testing"
"bytes"
)
func TestBytesAppendIsEquivalentToJoin(t *testing.T) {
prefix := []byte("announce")
sep := "/"
@anvinjain
anvinjain / libt_settings
Last active January 5, 2021 06:58
tuning libtorrent settings
local_service_announce_interval -> 30s
strict_end_game_mode -> false
low_prio_disk -> false
smooth_connect -> false
tick_interval -> 200
torrent_connect_boost -> 25
request_timeout -> reduce to say 10
peer_timeout -> set to 20
peer_connect_timeout -> 10
@anvinjain
anvinjain / gist:8800dfc38ac28248d33c38694a26444d
Created March 23, 2020 10:01
cert error in docker container
curl -o /dev/null -v https://github.com/gin-contrib/sse
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 13.234.210.38...
* TCP_NODELAY set
* Connected to github.com (13.234.210.38) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
@anvinjain
anvinjain / gist:6ff1775ed20297febfe5721ec8f14b72
Last active July 21, 2020 07:59
pulsar topic stats - one partition not consumed from sub-a
{
"msgRateIn" : 0.0,
"msgThroughputIn" : 0.0,
"msgRateOut" : 0.0,
"msgThroughputOut" : 0.0,
"bytesInCounter" : 0,
"msgInCounter" : 0,
"bytesOutCounter" : 189222399654,
"msgOutCounter" : 182595766,
"averageMsgSize" : 0.0,
@anvinjain
anvinjain / gist:d9c9b9dade58a48beae96a7e9f08746a
Created July 21, 2020 07:59
pulsar broker internal stats - one partition not consumed from sub-a
{
"metadata" : {
"partitions" : 6
},
"partitions" : {
"persistent://public/d4a1/p6-1-partition-0" : {
"entriesAddedCounter" : 0,
"numberOfEntries" : 569444,
"totalSize" : 33071397061,
"currentLedgerEntries" : 0,
@anvinjain
anvinjain / SharedConsumeWithDLQ.java
Last active February 9, 2021 07:31
Deadlock in Pulsar client, does not shutdown when DLQ messages are produced while client.close is called
package examples.pulsar.gist;
import org.apache.pulsar.client.api.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;