Skip to content

Instantly share code, notes, and snippets.

View prmichaelsen's full-sized avatar
🌚

Patrick Michaelsen prmichaelsen

🌚
  • Phoenix
  • 12:32 (UTC -06:00)
View GitHub Profile
@prmichaelsen
prmichaelsen / PassGen.java
Last active September 9, 2015 17:00
Takes command line arguments length and number and generates passwords (alphanumeric and special characters)
//*******************************************************************
// Java compiler created in PHP to quickly and safely test code.
// NOTE: please read the 'More Info' tab to the right for shortcuts.
//*******************************************************************
import java.lang.Math; // header stuff MUST go above the first class
import java.util.Random;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
public class Roads {
public static final int TILE_SIZE = 32;
public static final int ROOM_HEIGHT = 1024+512;
public static final int ROOM_WIDTH = 1024+512;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Stack;
@prmichaelsen
prmichaelsen / git-info
Created November 15, 2015 08:04 — forked from Hamatti/git_stuff.sh
Added some alias stuff to display git branch description everytime I do git status (or gs as it's aliased for me). That helps me keep on track with branches that are named like issue-[nro] or fix-[nro].
#!/bin/sh
function parse_git_branch_name {
git rev-parse --abbrev-ref HEAD
}
function parse_git_description {
git config branch.$(parse_git_branch_name).description
}
/**
two var sort
by Patrick Michaelsen
patrickmichaelsen@patrickmichaelsen.com
prmichaelsen@github.com
michaelsenpatrick@gmail.com
A fun little code I made to see if I could sort an array with just two variables.
WHILE no swaps performed
FOR pair of elements
IF pair is out of order
swap pair
int maxProfit(int* prices, int n) {
int previous_delta = 0;
int delta = 0;
int max_profit = 0;
for ( int i = 1 ; i < n ; i ++ )
{
previous_delta = delta;
delta = prices[ i ] - prices [ i - 1 ];
def maxProfit ( self, prices ):
previous_delta = 0
delta = 0
max_profit = 0
for i in range( 1 , len ( prices ) ) :
previous_delta = delta
delta = prices[ i ] - prices [ i - 1 ]
#!/bin/bash
let count0=0
for f in $(ls ./tests/*.txt); do
./a.out 0 < $f > ./tests/`basename $f .txt`.output;
diff -Bw ./tests/`basename $f .txt`.output ${f}.expected > ./tests/`basename $f .txt`.diff;
done;
for f in $(ls tests/*.txt); do
echo "========================================================";