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
Application.put_env(:sample, PhoenixDemo.Endpoint, | |
http: [ip: {127, 0, 0, 1}, port: 8080], | |
server: true, | |
live_view: [signing_salt: "bumblebee"], | |
secret_key_base: String.duplicate("b", 64), | |
pubsub_server: PhoenixDemo.PubSub | |
) | |
Mix.install([ | |
{:plug_cowboy, "~> 2.6"}, |
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
defmodule Mlearning do | |
@moduledoc false | |
def mods(x) do | |
[rem(x, 3), rem(x, 5)] | |
end | |
def fizzbuzz(n) do | |
cond do | |
rem(n, 15) == 0 -> [0, 0, 1, 0] |
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
defmodule Mlearning do | |
@moduledoc false | |
def mods(x) do | |
[rem(x, 3), rem(x, 5)] | |
end | |
def fizzbuzz(n) do | |
cond do | |
rem(n, 15) == 0 -> [0, 0, 1, 0] |
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
##### 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 |
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
// 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) { |
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
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()' |
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
1) Install homebrew if you haven't already | |
https://brew.sh/ | |
2) Install postgres | |
brew install postgresql | |
3) Start the database |
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 { 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(); |
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
@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 |
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
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 |