This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.stream.*; | |
import java.util.Comparator; | |
import java.util.Collections; | |
import java.util.Optional; | |
import java.util.Random; | |
class Java8Demo { | |
private static final String[] poolOfFirstNames = { "Joe", "Paul", "John", "Samantha", "Amanda", "Karen" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :ip-interfaces) | |
(defun ip-as-string (interface) | |
(format nil "~{~A~^~.~}" (map 'list (lambda (x) x) (ip-interfaces:ip-interface-address interface)))) | |
(defun print-interface-ip (interface) | |
(format t "~A: ~A~%" (ip-interfaces:ip-interface-name interface) (ip-as-string interface))) | |
(loop for interface in (ip-interfaces:get-ip-interfaces) | |
do (print-interface-ip interface)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
module JavaPropsToEnvVars where | |
import Data.List (break, stripPrefix) | |
type PropertyName = String | |
type PropertyValue = String | |
type Property = (PropertyName, PropertyValue) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Colors | |
BACKGROUND=black | |
FOREGROUND=white | |
setw -g status-bg $BACKGROUND | |
setw -g status-fg $FOREGROUND | |
setw -g window-status-current-bg $FOREGROUND | |
setw -g window-status-current-fg $BACKGROUND | |
set -g pane-active-border-bg default | |
set -g pane-active-border-fg $FOREGROUND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StringSet = Set.Make(String) | |
let addr_to_string = function | |
| Unix.ADDR_UNIX s -> s | |
| Unix.ADDR_INET (iaddr, _) -> Unix.string_of_inet_addr iaddr | |
let get_local_ips () = | |
Unix.getaddrinfo "localhost" "" [] | |
|> List.map (fun x -> x.Unix.ai_addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype plugin indent on | |
syntax on | |
set autoindent | |
set expandtab | |
set shiftwidth=4 | |
set tabstop=4 | |
set smarttab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let person = filter (\x -> name x == "John Smith") people | |
age dob = getCurrentTime >>= return . (\now -> (diffDays now dob) `div` 365) . utctDay | |
in | |
[name person, dob person, age (dob person)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
Name, DoB, (current_date - DoB) as Age | |
FROM | |
People | |
WHERE | |
Name = 'John Smith' | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BAD: | |
List<PersonEntity> pes = someFetcherFunction.findByAgeGreaterThan(18); | |
if (pes.contains(currentPE)) { return "Hello, sir/madam."; } | |
else { return "This method is for adults only!"; } | |
// GOOD: | |
static Integer LEGAL_ADULTHOOD_AGE = 18; // in class PersonEntity | |
//... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<PersonEntity> attendees = conference.getAttendees(); | |
Collections.sort(new Comparator<PersonEntity> { | |
@Override | |
public int sort(PersonEntity person1, PersonEntity person2) { | |
Date person1ArrivalDate = person1.getArrivalDate(), | |
person2ArrivalDate = person2.getArrivalDate(); | |
if (person1ArrivalDate == null) person1ArrivalDate = DEFAULT_ARRIVAL_DATE; | |
if (person2ArrivalDate == null) person2ArrivalDate = DEFAULT_ARRIVAL_DATE; | |
int comparisonByArrivalDateResult = person1ArrivalDate.compareTo(person2ArrivalDate); | |
if (comparisonByArrivalDateResult == 0) { |
OlderNewer