Some good resources:
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
defmodule Manager do | |
use GenServer | |
def start_link(_) do | |
GenServer.start_link(__MODULE__, :ok, name: __MODULE__) | |
end | |
def init(_) do | |
Process.flag(:trap_exit, true) | |
worker = Process.whereis(Worker) |
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
defmodule IOList do | |
@base62_alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |> String.graphemes() | |
def random_chars(n) do | |
Enum.take_random(@base62_alphabet, n) |> Enum.join() | |
end | |
def with_iolist(input), do: with_iolist(input, []) | |
def with_iolist("", acc), do: acc |> Enum.reverse() |> :erlang.iolist_to_binary() | |
def with_iolist(<<first::utf8, rest::binary>>, acc) do |
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
diff --git a/CHANGELOG.md b/CHANGELOG.md | |
index e515143..36a412c 100644 | |
--- a/CHANGELOG.md | |
+++ b/CHANGELOG.md | |
@@ -24,6 +24,19 @@ Note the websocket/longpoll configuration given to socket/3 will only apply afte | |
The old APIs for building transports are also deprecated. The good news is: adapting an existing transport to the new API is a less error prone process where you should mostly remove code. | |
+## 1.4.10 (2019-09-05) | |
+ |
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
@alphabet_lower ?a..?z | |
@alphabet_upper ?A..?Z | |
@spec rotate(text :: String.t(), shift :: integer) :: String.t() | |
def rotate(text, shift) do | |
text | |
|> String.to_charlist() | |
|> Enum.map(&(rot(&1, shift))) | |
|> List.to_string() | |
end |
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
export const setIn = (obj: Object, key: string, value: string): Object => { | |
const levels = key.split('.'); | |
const innerMostKey = levels.pop(); | |
const innerMost = { [innerMostKey]: value }; | |
const m = levels.reverse().reduce( | |
(acc, curr) => ({ | |
[curr]: acc, | |
}), |
Java and C# are great at forcing you to do the right thing. JavaScript is not. It requires discipline.
This means choosing good and informative variable names, creating a clear and understandable architecture, and a flow of code that makes sense.
Why this is a terrible, terrible design choice.
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
(def combinations | |
(for [x (range 1 98) y (range 1 98) | |
:when (>= 98 (+ x y))] | |
(let [z (- 100 x y)] | |
{:x x :y y :z z}))) | |
(defn winner? [{:keys [x y z]}] | |
(== 100 (+ (* 15 x) (* 1 y) (* 0.25 z)))) | |
(defn find-winner [] |
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
// Throttle from underscore.js, simplified and deattached | |
var throttle = function(func, wait) { | |
var context, args, result; | |
var timeout = null; | |
var previous = 0; | |
var later = function() { | |
previous = Date.now(); | |
timeout = null; | |
result = func.apply(context, args); |
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
/** | |
* Set the "data-placeholder" attribute on your input fields. | |
* The script is only run if placeholders are not supported. | |
* Depends on jQuery >= 1.8 | |
**/ | |
(function (window, $) { | |
var e = document.createElement('input'); | |
if (!('placeholder' in e)) { | |
$('input[data-placeholder]').each(function (idx, element) { | |
$(element).val($(element).attr('data-placeholder')); |
NewerOlder