Assumes you have brew installed.
Install pyenv.
brew install pyenv
Check what versions of python are available.
Assumes you have brew installed.
Install pyenv.
brew install pyenv
Check what versions of python are available.
While installing some formula I get:-
The formula built, but is not symlinked into /usr/local
Running brew as root is not allowed.
sudo brew install awscli
if (tweeted || facebooked) { | |
gratitude += 1; | |
} | |
if (githubStarred) { | |
karmaBalance = true; | |
} else { | |
$('we').say('ok'); | |
} |
import org.joda.time.LocalTime; | |
public class Timer { | |
public static void main(String[] args) { | |
LocalTime start = LocalTime.now(); | |
// some event to be timed | |
LocalTime end = LocalTime.now(); | |
int delta = end.getMillisOfDay() - start.getMillisOfDay(); | |
System.out.println("Time took: " + Double.valueOf(delta)/1000 + " seconds"); | |
} |
import java.time.LocalTime; | |
import java.util.concurrent.TimeUnit; | |
public class Timer { | |
public static void main(String[] args) { | |
LocalTime start = LocalTime.now(); | |
// some event to be timed | |
LocalTime end = LocalTime.now(); | |
long delta = TimeUnit.NANOSECONDS.toMillis(end.toNanoOfDay() - start.toNanoOfDay()); | |
System.out.println("Time took: " + Double.valueOf(delta)/1000 + " seconds"); |
We have a method to test which iterates over some List. The example is a validator service which iterates over a List of validators applying each one and returning when one fails ie. it returns an Optional
containing an error message (this is just a concrete example to demonstrate Mockito and is not important to understand).
public class SomeValidationService implements ValidationService {
/* List of validators which all encapsulate some different business validation logic */
/* This gets injected say via Spring */
private List<Validator> validators;
public Optional<ErrorMessage> validateAction(final ObjectToValidate obj) {
Scenario: We have an interface that defines an operation.
public interface Validator {
Optional validate(String subject, String subject2);
}
Some Validators only have 1 String to validate
so we can extend the interface with a simpler one.
Return the max value of a List[Int]
if unique, otherwise return -1.
def maxIfUnique(li: List[Int]) = li.groupBy(_.intValue).maxBy(_._1)._2 match {
case x if x.size == 1 => x.head
case _ => -1
}
scala> val list = List(1, 2, 1) // 2 is max and is unique
Check out Adobe Fonts.
brew tap caskroom/fonts && brew cask install font-source-code-pro