Skip to content

Instantly share code, notes, and snippets.

View prmichaelsen's full-sized avatar
🌚

Patrick Michaelsen prmichaelsen

🌚
  • Phoenix
  • 23:43 (UTC -07: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.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;
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;
@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
[email protected]
[email protected]
[email protected]
A fun little code I made to see if I could sort an array with just two variables.
//************************************************************************//
// one_var_bubble_sort.c //
//************************************************************************//
//
// AUTHOR: Patrick Michaelsen
// EMAIL: [email protected]
// [email protected]
// WEBSITE: PatrickMichaelsen.com
//
// DESCRIPTION: This algorithm bubble sorts an array of
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 ]