Skip to content

Instantly share code, notes, and snippets.

View aesmail's full-sized avatar
🇯🇵
日本語を勉強しています

Abdullah Esmail aesmail

🇯🇵
日本語を勉強しています
View GitHub Profile
@aesmail
aesmail / phoenix_channels_nativescript.md
Last active November 8, 2018 12:11
NativeScript + Phoenix Channels

I have been struggling (unnecessarily) to make my NativeScript app work seamlessly with Phoenix Channels.

I'm sure this is not the perfect solution, but after trying a lot of other solutions and none of them worked, this one worked for me like a charm.

I'm using:

  • macOS 10.12.6
  • phoenix 1.3.0
  • NativeScript 3.1.3
defmodule MyModule do
# this is valid sytax. However, you can't access x and my_function inside `def`
x = 2
my_function = fn (x) -> x * 2 end
# this is valid syntax. It will replace @my_variable with 2 anywehre inside the module at compile time.
@my_variable 2
# the following line will not compile
# because only the following values are supported here:
@aesmail
aesmail / control_flow.ex
Created May 29, 2020 16:12
Elixir deciding which control flow to use
# boolean values, use if
if expression, do: this(), else: that()
# non-boolean multi-value single expressions, use case
case expression do
value1 -> one()
value2 -> two()
value3 -> three()
_ -> anything_else()
end
@aesmail
aesmail / email_format_validation.ex
Last active June 25, 2020 03:04
Email format validation helper text
defmodule MyApp.Blog.Author do
use Ecto.Schema
import Ecto.Changeset
schema "authors" do
field :name, :string
field :email, :string
# ...
end