View nx_fizzbuzz.ex
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 Mlearning do | |
@moduledoc false | |
def mods(x) do | |
[rem(x, 3), rem(x, 5), rem(x, 15)] | |
end | |
def fizzbuzz(n) do | |
cond do | |
rem(n, 15) == 0 -> [0, 0, 1, 0] |
View fizzbuzz.ex
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 Mlearning do | |
@moduledoc false | |
def mods(x) do | |
[rem(x, 3), rem(x, 5), rem(x, 15)] | |
end | |
def fizzbuzz(n) do | |
cond do | |
rem(n, 15) == 0 -> [0, 0, 1, 0] |
View leex_to_heex.ex
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
##### phx live view 0.16 with leex | |
def render(assigns) do | |
~L""" | |
<button class="<%= if @foo && @bar && @baz do %>text-blue-600<% else %>text-red-600<% end %>">hello</button> | |
""" | |
end | |
##### phx live view 0.16 with heex -inline edition |
View app.js
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
// Code handling the card payment | |
const payWithCard = function (stripe, card, clientSecret, liveView) { | |
stripe | |
.confirmCardPayment(clientSecret, { | |
payment_method: { | |
card: card, | |
}, | |
}) | |
.then(function (result) { | |
if (result.error) { |
View jedi-for-python.txt
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
pip install jedi | |
then -in your vimrc | |
``` | |
nmap <Leader>j :call InvokeJumpToByType()<CR> | |
function! InvokeJumpToByType() | |
let filetype=&ft | |
if filetype == 'python' | |
exe ':call jedi#goto_definitions()' |
View postgres.txt
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
1) Install homebrew if you haven't already | |
https://brew.sh/ | |
2) Install postgres | |
brew install postgresql | |
3) Start the database |
View wait-for-redux.js
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 { Promise } from 'rsvp'; | |
import { next } from '@ember/runloop'; | |
import { registerWaiter } from '@ember/test'; | |
import { getContext } from '@ember/test-helpers'; | |
export async function waitForRedux(key, value) { | |
return new Promise(async (resolve) => { | |
let counter = 1; | |
registerWaiter(() => counter === 0); | |
const { owner } = getContext(); |
View hydrate_state_from_filesystem.ex
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
@impl GenServer | |
def handle_call({:all}, _timeout, _state) do | |
{:ok, files} = :file.list_dir(@database) | |
state = | |
Enum.map(files, fn (key) -> | |
value = | |
case File.read(file_name(@database, key)) do | |
{:ok, contents} -> :erlang.binary_to_term(contents) | |
_ -> nil | |
end |
View verbose-some.exs
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 MyEnum do | |
def some([], _func), do: [] | |
def some([head | tail], func) do | |
case func.(head) do | |
true -> | |
true | |
false -> | |
case some(tail, func) do | |
true -> | |
true |
View functions-in-elixir.exs
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 Foo do | |
def my_func({name}) do IO.puts("#{name}") end | |
def my_func({name, number}) do IO.puts("#{name} #{number}") end | |
end |
NewerOlder