Skip to content

Instantly share code, notes, and snippets.

@isopropylcyanide
isopropylcyanide / apriori.cpp
Last active June 21, 2018 06:58
Data Mining : Apriori Frequent Pattern Identification using C++
#include <bits/stdc++.h>
using namespace std;
#define inputFile "apriorinput"
#define _MIN_SUPPORT 2
vector<set<int> > inputVec;
set<int> allItems;
/*
@isopropylcyanide
isopropylcyanide / flink-cancel-all.sh
Created November 2, 2018 07:56
This bash script cancels all the Flink jobs that are submitted to the cluster sequentially.

Method 1

sudo /usr/local/McAfee/AntiMalware/VSControl stopoas

alternatively

sudo defaults write /Library/Preferences/com.mcafee.ssm.antimalware.plist OAS_Enable -bool False
sudo /usr/local/McAfee/AntiMalware/VSControl stop
sudo /usr/local/McAfee/AntiMalware/VSControl reload
@isopropylcyanide
isopropylcyanide / concurrent_cmd_bash.sh
Created March 21, 2020 15:06
Generic function that utilises function arguments to fire commands for a total of `N` times in `M` jobs at a parallel
# Generic function that utilises function arguments to fire commands for a total of `N` times in `M` jobs at a parallel
set -o xtrace
function conc(){
cmd=("${@:3}")
seq 1 "$1" | xargs -n1 -P"$2" "${cmd[@]}"
}
# $ conc N M cmd
@isopropylcyanide
isopropylcyanide / docker-disk-prune.sh
Created June 3, 2020 06:58
Docker Disk Prune Cron Script
#!/bin/bash
# =====================================================================================================================
# This script helps prune docker disk for dangling images, unused containers or images. Use this in a cron tab for
# automatic disk maintenance. While this alone cannot clear most of the fragmented disk which are cleared by restaring
# the daemon, it only delays the point in time where we have to eventually restart the daemon and clear i-nodes
# Usage $ chmod +x docker-disk-prune.sh
# Recommended cron expression (every 3 hours)
# * */3 * * * sh /docker-prune.sh
/**
* This class delays the logging of request and response events.
* @implNote This class uses a thread local to cache request serialization in the form of a builder
* If the response received from service passes the supplied predicate, then both request and response
* will be logged or else nothing will be logged.
*/
public class DelayedRequestResponseLoggingFilter implements ContainerRequestFilter, ContainerResponseFilter, WriterInterceptor {
private final ResponseCondition responseCondition;
/**
* This logging filter helps exclude logging requests and responses for URIs that match a set of excluded URIs
*/
public class WhitelistedServerLoggingFilter implements ContainerRequestFilter, ContainerResponseFilter, WriterInterceptor {
private final RequestResponseBuilder requestResponseBuilder;
private final Logger logger;
/**
* A get of paths for which the server request and response logging will not be performed
public enum ResponseCondition implements Predicate<Integer> {
ON_RESPONSE_4XX_5XX {
@Override
public boolean test(Integer responseCode) {
return responseCode >= 400 && responseCode <= 599;
}
},
ON_RESPONSE_4XX_5XX_NON_NOT_FOUND {
@Override
@isopropylcyanide
isopropylcyanide / mysql_query_optimizer_steps.json
Last active January 3, 2021 19:28
MySQL Query Tracer Optimiser Steps (Redacted response)
{
"steps": [
{
"join_preparation": {
"select#": 1,
"steps": [
{
"IN_uses_bisection": true
},
{
@isopropylcyanide
isopropylcyanide / connector-hostname-death.json
Last active February 5, 2021 19:53
connector-hostname-death.json
{
"state": "FAILED",
"trace": "org.apache.kafka.connect.errors.ConnectException: The connector is trying to read
binlog starting at binlog file 'my-database-bin.000004', pos=654822673, skipping 20 events
plus 1 rows, but this is no longer available on the server. Reconfigure the connector to
use a snapshot when needed.",
"worker_id": "10.33.10.196:8083",
"generation": 121