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
# Rails customer validation | |
#http://blog.arkency.com/2014/04/mastering-rails-validations-contexts/ | |
# giving context to the validation | |
validates_length_of :slug, minimum: 3, on: :user | |
## editing , giving context when saving the record | |
def edit | |
@user = User.find(params[:id]) |
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
run_query = fn(query_def) -> | |
:timer.sleep(2000) | |
"#{query_def} result" | |
end | |
#after 2 seconds -> "query 1 result" | |
run_query.("query 1") | |
# after 10 seconds result returns | |
1..5 |> Enum.map(&run_query.("query #{&1}")) |
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
## Kernel.send/2 function | |
send(pid, { :an, :arbitary, :term } ) | |
receive do | |
pattern_1 -> do_something | |
pattern_2 -> do_something_else | |
## Example to be executed in IEX | |
send(self, "a message") |
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 DatabaseServer do | |
def start do | |
spawn(&loop/0) | |
end | |
# public API | |
def run_async(server_pid, query_def) do | |
send(server_pid, {:run_query, self, query_def}) | |
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
defmodule Calculator do | |
def start do | |
spawn( fn -> loop(0) end) | |
end | |
defp loop(current_value) do | |
new_value = receive do | |
{sender_pid, :value} -> | |
IO.puts("current value is #{current_value}") |
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 CamelCase do | |
def to_camel_case(word) do | |
words = String.codepoints(word) | |
convert("-", words) |> Enum.join("") | |
end | |
def convert(a, []) do | |
[] | |
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
Github Battle v2 | |
Step 1 | |
// Setting up package.json, this is done through npm install | |
Step 2 | |
// I guess the next step, is to get something to run?!! app.js? index.js? | |
// npm install --save-dev @babel/core @babel/preset-env @babel/preset-react webpack webpack-cli webpack-dev-server babel-loader css-loader style-loader html-webpack-plugin | |
Step 3 |
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
// Here i am trying to render a list into my React component | |
// obviously start with an array | |
// Apparently this code does not work, because the code block is not wrapped inside a Div | |
render() { | |
const languages = ['All', 'Ruby', 'Javascript'] | |
return ( | |
{languages.map((language) => ( | |
<h1>language</h1> | |
))} |
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
19 June 2019 | |
1. Create ReposGrid Component | |
2. For every object found in repos , create a list which displays the content | |
3. Also use font-awesome, to create the labels | |
A few questions: | |
1. Does the ul, and React Fragment still stay inside Popular component? or should be moved to RepoGrid? | |
Basically using composition / or whatever that means. |
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
// 18 June 2019 | |
1. Create Vietnam Retailer in Postco.xyz | |
2. Test Vietnam Return Flow, make sure label is there. | |
3. | |
Testing result | |
1. ParcelReturn.last.country = ‘VIETNAM’, why?? . | |
I think it’s because Agent’s country is ‘VIETNAM’ | |
pdf.js |
OlderNewer