Skip to content

Instantly share code, notes, and snippets.

@Unix-Code
Unix-Code / Cipher.java
Last active January 29, 2017 23:33
Vigenére Cipher
public class Cipher {
private String regularAlphabet;
private String key;
public Cipher(String keyword, Message message) {
regularAlphabet = "abcdefghijklmnopqrstuvwxyz";
key = this.createKey(keyword, message);
}
public String createKey(String keyword, Message message) {
@Unix-Code
Unix-Code / Cipher.java
Last active January 17, 2017 23:15
Caesar Cipher
public class Cipher {
private String regularAlphabet;
private String cipherAlphabet;
public Cipher() {
regularAlphabet = "abcdefghijklmnopqrstuvwxyz";
cipherAlphabet = "defghijklmnopqrstuvwxyzabc";
}
public Message encrypt(Message message) {
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.Status;
import twitter4j.StatusUpdate;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import java.util.ArrayList;
public class DankBot {
@Unix-Code
Unix-Code / Cipher.java
Created December 24, 2016 17:23
Key String Cipher
public class Cipher {
private String regularAlphabet;
private String cipherAlphabet;
public Cipher(String key) {
regularAlphabet = "abcdefghijklmnopqrstuvwxyz";
cipherAlphabet = this.createCipher(key.toLowerCase(), regularAlphabet);
}
public Message encrypt(Message message) {
import java.util.Date;
public class Encryptor {
public static void main(String[] args) {
String check = "";
for (int i = 0; i < 100000; i++) {
check += (char)(Math.random()*27 + 'a');
}
Date start = new Date();
import java.util.Date;
import java.util.Random;
public class ArrayRepetitionFinder {
public static void main(String[] args) {
//int[] array = new int[100000000];
Random rand = new Random();
long[] times = new long[10];
/*for (int i = 0; i < array.length; i++) {
array[i] = rand.nextInt(9) + 1;
}*/
public class NonConsecArray {
public int sum(int[] array) {
int Sum = 0;
int i = 0;
if (array.length%2 != 0) {
int iTemp = 2;
int tempSum = 0;
while (i < array.length) {
if (i + iTemp >= array.length - 1) {
iTemp++;
@Unix-Code
Unix-Code / Location.java
Created November 10, 2015 14:48
In Class Location and Map
public class Location {
private double x;
private double y;
public Location() {
x = 0.0;
y = 0.0;
}
public Location(double x, double y) {
@Unix-Code
Unix-Code / NewtonMethod.java
Last active November 10, 2015 17:01
[W.I.P] Polynomial Calculator
public class NewtonMethod {
public static void main(String[] args) {
NewtonMethod test = new NewtonMethod();
test.calc("4x^3 + 7x^2 + 5x + 6", -2, 5);
}
public void calc(String polynomial, double firstGuess, int tolerance) {
Polynomial p = new Polynomial(polynomial);
double newGuess;
double oldGuess = firstGuess;
@Unix-Code
Unix-Code / BasetoBaseConverter.java
Last active October 29, 2015 02:18
Convert between bases 2 - 36. (Work in Progress)
import java.util.*;
public class BasetoBaseConverter {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
BasetoBaseConverter Run = new BasetoBaseConverter();
System.out.println("\fWhat number would you like to convert?");
String input = Scan.nextLine();
String start = input;