Skip to content

Instantly share code, notes, and snippets.

@ericlemerdy
ericlemerdy / DecimalFormat.js
Last active January 7, 2019 16:08 — forked from EtienneMiret/DecimalFormat.js
Javascript number formatter (Java DecimalFormat Implemented in Javascript)
/**
* @class DecimalFormat
* @constructor
* @param {String} formatStr
* @author Oskan Savli
*/
export default function DecimalFormat(formatStr) {
this.decimalSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
this.groupSeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ',';
/**
@ericlemerdy
ericlemerdy / gist:1721193
Created February 2, 2012 03:15
Cannot decide: guava or plain old for loop
public Boolean hasStraightFlush_plainJava() {
Suit expectedSuit = cards.get(0).getSuit();
int minValue = cards.get(0).getValue().ordinal();
for (int i = 1; i < 5; i++) {
Card card = cards.get(i);
if (card.getValue().ordinal() != minValue + i) {
return false;
}
if (card.getSuit() != expectedSuit) {
return false;