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 / Bash script to create user accounts.
Last active January 26, 2023 09:39 — forked from thimbl/script.sh
Shell script to create user accounts
#!/bin/bash
ROOT_UID=0
SUCCESS=0
E_USEREXISTS=70
# Run as root, of course. (this might not be necessary, because we have to run the script somehow with root anyway)
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $E_NOTROOT
@isopropylcyanide
isopropylcyanide / littlechecker.py
Last active January 7, 2024 16:50 — forked from rajarsheem/littlechecker.py
A little code checker tool in python for Java,C,Cpp. Handles compile error, runtime error, accepted, wrong, TLE.
import os
import filecmp
import re
codes = {200: 'success', 404: 'file_name not found',
400: 'error', 408: 'timeout'}
class program:
"""Class that handles all nitty gritties of a user program"""
@isopropylcyanide
isopropylcyanide / ObjectMapperUtil.java
Created June 20, 2018 10:20
Nested Property Object Mapper. Using reflection, takes an object and returns a map<string, string> where key is all the properties (nested inclusive) and value is the object value
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.IntStream;
import org.apache.commons.lang3.ClassUtils;
@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 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
/**
* 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;