Skip to content

Instantly share code, notes, and snippets.

@lovromazgon
lovromazgon / Apriori.java
Last active Dec 10, 2015 — forked from monperrus/Apriori.java
Java implementation of the Apriori algorithm for mining frequent itemsets - using multiple threads (default 8)
View Apriori.java
import java.io.*;
import java.util.*;
/** The class encapsulates an implementation of the Apriori algorithm to compute frequent itemsets.
*
* This version uses multiple threads to go through the dataset and is therefore 3x faster than the 1 thread version.
*
* Notice: To enable progress tracking (CLIProgressBar) follow these steps:
* 1. download this class and put it on the classpath: https://gist.github.com/lovromazgon/9c801554ceb56157de30
* 2. uncomment lines 229 and 243
@lovromazgon
lovromazgon / CLIProgressBar.java
Last active Mar 21, 2016
A CLI progress bar in Java and InputStream wrapper around the progress bar for ease of use.
View CLIProgressBar.java
package dap.util;
import java.io.PrintStream;
/**
* The CLIProgressBar outputs a progress bar and the time remaining for completing a task.
* <p>
* To use it you must provide the total size / total number of iterations for your task (e.g. file length)
* and update the current position after each iteration.
* <p>
@lovromazgon
lovromazgon / subtitle-downloader.sh
Last active Oct 8, 2015
Downloads the subtitles for all episodes of one season of a TV series - usage: ./subtitle-downloader.sh -s [season] {-l [ISO 639-1 language code] -e [comma separated episodes]} [TV series title]
View subtitle-downloader.sh
#!/bin/bash
# Downloads the most popular subtitles for all episodes of one season of a TV series
#
# Flags:
# -s : define the season (required if 'u' is missing)
# -u : explicitly define the URL (required if 's' is missing)
# -l : define the language code ISO 639-1 (optional, default: sl)
# -e : define the episodes in a comma separated list (optional, default: all)
# -h : displays this message
@lovromazgon
lovromazgon / Rabbit.java
Last active Feb 9, 2019 — forked from Chase-san/Rabbit.java
Rabbit Stream Cipher
View Rabbit.java
/**
* @see {@link http://tools.ietf.org/rfc/rfc4503.txt}
*/
public class Rabbit {
private static final int[] A = new int[] { 0x4D34D34D, 0xD34D34D3, 0x34D34D34, 0x4D34D34D, 0xD34D34D3, 0x34D34D34, 0x4D34D34D, 0xD34D34D3 };
private static final long MAX_UNSIGNED_INT = Integer.MAX_VALUE * 2l + 2; //2^32
private static final boolean DEBUG = false;
private int[] X;
private int[] C;
You can’t perform that action at this time.