This file contains hidden or 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
# is it assignment? | |
all_systems = :go | |
# not quite | |
:go = all_systems | |
# alas age is but a number | |
tom = %{name: "Tom", age: 25} | |
%{age: num} = tom # 25 |
This file contains hidden or 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
Enum.join(Enum.reverse(String.split(String.upcase("war"), "")), "") |
This file contains hidden or 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
"war" |> String.upcase |> String.split("") |> Enum.reverse |> Enum.join("") |
This file contains hidden or 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
"war" | |
|> String.upcase | |
|> String.split("") | |
|> Enum.reverse | |
|> Enum.join("") |
This file contains hidden or 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
"war".toUpperCase().split("").reverse().join(""); |
This file contains hidden or 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 static TemporalAdjuster LAST_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(lastDayOfMonth -> { | |
int daysToSubtract = Math.max(0, lastDayOfMonth.getDayOfWeek().getValue() - DayOfWeek.FRIDAY.getValue()); | |
return lastDayOfMonth.minusDays(daysToSubtract); | |
}); | |
// Example Usage | |
LocalDate.now().with(LAST_WORKING_DAY); |
This file contains hidden or 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.stream.*; | |
import java.util.Arrays; | |
// O(n) solution to the Trapped Water Problem | |
// @see https://techdevguide.withgoogle.com/paths/advanced/volume-of-water/ | |
public class TrappedWater { | |
public static void main(String args[]) { | |
int[] sampleTopography = { 1,3,2,4,1,3,1,4,5,2,2,1,4,2,2 }; | |
int trappedWaterVolume = getTrappedWater(sampleTopography); |
This file contains hidden or 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.stream.IntStream; | |
import java.util.Arrays; | |
// O(n^2) solution to the Trapped Water Problem | |
// @see https://techdevguide.withgoogle.com/paths/advanced/volume-of-water/ | |
public class TrappedWater { | |
public static void main(String args[]) { | |
int[] sampleTopography = { 1,3,2,4,1,3,1,4,5,2,2,1,4,2,2 }; | |
int trappedWaterVolume = getTrappedWater(sampleTopography); |
This file contains hidden or 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 timeouts = []; | |
let intervals = []; | |
const _setTimeout = window.setTimeout; | |
const _setInterval = window.setInterval; | |
const _clearTimeout = window.clearTimeout; | |
const _clearInterval = window.clearInterval; | |
window.setTimeout = (func, delay) => { |
This file contains hidden or 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
// Trie.js - super simple JS implementation | |
// https://en.wikipedia.org/wiki/Trie | |
// From https://gist.github.com/tpae/72e1c54471e88b689f85ad2b3940a8f0 | |
// Modified to support key -> value mapping for quick object retrieval, | |
// using an ES6 Map instead of plain JS object, and optional case insensitivity. | |
// Values are automatically converting to arrays to support multiple values | |
// mapped to a single tree leaf. | |
// Example: |