Skip to content

Instantly share code, notes, and snippets.

@spotco
spotco / gist:4988755
Last active December 13, 2015 22:59
JABBA PASSWORD CRACKER STUB
import java.util.ArrayList;
import java.util.List;
public class PasswordGen {
public static void main(String[] args) {
List<Character> cs = new ArrayList<Character>();
cs.add('a');
cs.add('b');
@spotco
spotco / gist:4989318
Last active December 13, 2015 23:09
password cracker solution
import java.util.ArrayList;
import java.util.List;
public class PasswordGen {
public static void main(String[] args) {
List<Character> cs = new ArrayList<Character>();
cs.add('a');
cs.add('b');
@spotco
spotco / gist:5003017
Last active December 14, 2015 00:59
Sentence solver problem code
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
public class SentenceSolver {
public static Set<String> EnglishDictionary;
static {
EnglishDictionary = new HashSet<String>(Arrays.asList(new String[] {
@spotco
spotco / gist:5009464
Last active December 14, 2015 01:49
sentencesolver solution
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.Stack;
public class SentenceSolver {
public static Set<String> EnglishDictionary;
static {
isSorted(root,Integer.MIN_VALUE,Integer.MAX_VALUE);
public static boolean isSorted(Node cur, int min, int max) {
if (cur==null) {
return true;
} else if (cur.val < min || cur.val > max) {
return false;
} else {
boolean sorted = true;
if (cur.left != null && cur.left.val > cur.val) {
@spotco
spotco / gist:5317556
Created April 5, 2013 08:26
Sound file note detection using JTransforms (java)
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
@spotco
spotco / gist:5318082
Last active December 15, 2015 20:19
mathematica include
(*GENERAL PURPOSE*)
ee[m_, e_] := m*10^ e;
sci[x_] := ScientificForm[x]; // N
getr[rules_, r_] := Replace[r, rules];
(*Complex*)
imag[a_, b_] := a + I*b;
imagpol[i_] := {Abs[i], ArcTan[Re[i], N[Im[i]]]};
FactorC[p_, x_] := Times @@ Cases[Roots[p == 0, x, Cubics -> False], u_ == v_ -> x - v];
PartialFractionsC[p_, x_] := (Apart[Numerator[#1]/FactorC[Denominator[#1], x], x] &)[Together[p]];
@spotco
spotco / gist:5451224
Created April 24, 2013 10:35
JAVRPG
import java.io.*;
import java.util.Random;
//so unoptimized it isnt even funny
public class JavRPG {
public static void main(String args[]) {
//Intro
int level = 1;
int gold = 0;
int health = 10;
@spotco
spotco / gist:5480134
Last active December 16, 2015 18:49
ls | grep .txt | xargs cat IN C
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
@spotco
spotco / gist:5703542
Created June 4, 2013 04:19
mathematica graphs and shit
Clear[a, b, c, x]
data = {{1, 0.679}, {5, 0.684}, {10, 0.642}, {20, 0.635}, {40,
0.622}, {80, 0.614}, {200, 0.611}, {500, 0.605}, {1000,
0.598}, {5000, 0.604}, {10000, 0.605}};
range = {{0, 6000}, {0.55, 0.66}};
v2 = ListPlot[data, PlotRange -> range];
Fit[data, {1, Log[x]}, x]
dotandfit = Plot[%, {x, 0, 10000}, PlotRange -> range];
v1 = Plot[0.6, {x, 0, 10000}, PlotStyle -> {Red}];
Show[v2, dotandfit];