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
public interface Mappable<A> { | |
public <B> Mappable<B> map(Function<A, B> f); | |
} |
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 Html exposing (div, text) | |
import Html.Attributes exposing (style) | |
import Html.Events exposing (onClick) | |
import StartApp as StartApp | |
import Signal as Signal | |
import Mouse as Mouse | |
import Effects as Effects | |
app = StartApp.start | |
{ init = (init, Effects.none) |
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
#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
(defn fold_ [f initial [head & the-rest :as arr]] | |
(cond | |
(empty? arr) initial | |
:else (recur f (f initial head) the-rest))) | |
(defn map_ [f arr] | |
(let [applyF (fn [previous current] (conj previous (f current)))] | |
(fold_ applyF [] arr))) | |
(defn filter_ [predicate arr] |
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
(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
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
/* Again, the assumption: arrayOfElements is an array of DOM nodes created from a template or otherwise. */ | |
/* We can set our targetNode to "display:none", change it, and then reset it, making it into a poor man's DocumentFragment */ | |
var targetNode = document.getElementById('target'); | |
var previousDisplayValue = targetNode.style.display; | |
targetNode.style.display="none"; /* 1 reflow */ | |
var appendToNode = targetNode.appendChild.bind(targetNode); | |
arrayOfElements.forEach(appendtoTargetNode); /* 0 reflows */ |
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
/* Assumption: arrayOfElements is an array of DOM nodes created from a template or otherwise. */ | |
/* Don't do this! This reflows the DOM a *lot* */ | |
var targetNode = document.getElementById('target'); | |
var appendToTargetNode = targetNode.appendChild.bind(targetNode); | |
arrayOfElements.forEach(appendToTargetNode); | |
/* Instead, use a DocumentFragment */ |