Skip to content

Instantly share code, notes, and snippets.

@sp0rus
sp0rus / microfortnightsleep.java
Created April 20, 2011 01:23
Class contains a method that calls java's sleep, approximates for microfortnights instead of seconds.
public class microFortnightSleep
{
public static void mfsleep(int num)
{
int time = num * 1209;
try
{
Thread.sleep(time);
}
catch( InterruptedException e )
@sp0rus
sp0rus / ArrayExample.java
Created April 20, 2011 00:53
Code compares performance of row-by-row copying to column-by-column. Used in a blog post
class ArrayExample{
static int size = 10240;
static int A[][] = new int[size][size];
static int B[][] = new int[size][size];
static void copyij(){
for( int i = 0; i < size; i++){
for( int j = 0; j < size; j++){
B[i][j] = A[i][j];
@sp0rus
sp0rus / arrayexample.c
Created April 20, 2011 00:51
Code compares performance of Row-by-Row copying in an array to Column-by-Column. Used in a blog post.
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#define DIM 10240
int A[DIM][DIM];
int B[DIM][DIM];
void copyij( int *src, int *dst ){
@sp0rus
sp0rus / PasswordStrength.java
Created April 20, 2011 00:45
Program asks user for password, assumes password is random and all symbols were produced independently. The program then calculates the entropy of the password based on number of possible characters and length of the password.
import java.util.*;
public class PasswordStrength {
final static double POSSIBLECHARS = 62; //Upper and Lower Alphebet (52), Arabic Numberals (10)
public static void main( String[] args ){
double entropy = 0;
int pwlength = 0;
String password;