View softwareengineering
%
Simple things should be simple, complex things should be possible.
The Wiki Way: Quick Collaboration on the Web, Bo Leuf, Ward
Cunningham
%
Simplicity is the soul of efficiency.
Austin Freeman
%
I have yet to see any problem, however complicated, which, when you
looked at it in the right way, did not become still more complicated.
View softwareengineering
%
Simple things should be simple, complex things should be possible.
The Wiki Way: Quick Collaboration on the Web, Bo Leuf, Ward
Cunningham
%
Simplicity is the soul of efficiency.
Austin Freeman
%
I have yet to see any problem, however complicated, which, when you
looked at it in the right way, did not become still more complicated.
View findandreplace.sh
find . -type f -exec sed -i -e 's/world/universe/g' {} \;
View gist:fe908ca121cd0783e6f25ce341874bc6
awk 'FNR==1{print "%"}{print}' quote* > softwareengineering
View PermutationGenerator1.java
import java.util.ArrayList;
import java.util.Scanner;
public class PermutationGenerator1 {
private static String inputWithoutC(String input, char c) {
String inputWithoutC = "";
char[] temp = input.toCharArray();
for(char d : temp) {
if(d !=c ) {
inputWithoutC += d;
View NullSafe.scala
implicit class NullSafeOption[A,B](val a: Option[A]) extends AnyVal {
def mapNullSafe(f: A => B): Option[B] = { a.flatMap(x => Option(x).map(f)) }
}
implicit class NullSafe[A,B](val a: A) extends AnyVal {
def ?(f: A => B): B = { if(a == null) null.asInstanceOf[B] else f(a) }
}
//Examples with Option + Map
scala> val s: String = null
View gist:a2e76d98bb86ed054c0fb8317c2117ce
implicit class NullSafe[A, B](val a: A) extends AnyVal {
def ?(f: A => B): B = { if(a == null) null.asInstanceOf[B] else f(a) }
}
//example
val s = "Hello, World!"
s?(_.reverse)?(_.reverse) //returns "Hello, World!"
val sNull: String = null
sNull?(_.reverse)?(_.reverse) //returns null
View CountTo99WithoutNumbers.scala
object CountTo99WithoutNumbers extends App {
object PrimaryNumber extends Enumeration {
val zero, one, two, three, four, five, six, seven, eight, nine = Value
}
object StrangeNumber extends Enumeration {
val eleven, twelve, thirteen = Value
}
View gist:66f3eac5feaff22bda1d1bf8b722844e
//1. create the interface with a different method than toString
interface Loggable {
String toLogString();
}
//2. Create an abstract class that forwards toString() to this other method
abstract class LoggerBase implements Loggable {
public String toString() {
return toLogString();
View DailyAllowance.scala
object DailyAllowance extends App {
val DaysInMonth = 30
val MonthlyNet = USD("$5000.00")
val MonthlyFixedExpenses = USD("$3000.00")
case class Money(rate: Int)
class USD(val dollars: Int, val cents: Int) extends Money(100) {