steve lee
Elixir Note - Concurrency
For example, we have a simple module to fetch the price of a given ticker symbol (or stock symbol) from API and parse the results.
defmodule Worker do
def price_of(ticker) do
call_api(location) |> parse_data
end
defp call_api(ticker) do
# function to call api
end
defp parse_data do
end
end
Now we can start making our code concurrent, with two approaches:
1. Use Elixir primitive process:
defmodule Worker do
def loop do
receive do
{sender_pid, ticker} ->
send(sender_pid, {:ok, price_of(ticker)})
_ ->
IO.puts "don't know how to…
busylog
Android-x86 manual install & grub2 boot
required files: kernel, initrd.img, system.sfs under /Android (ext4 filesystem).
optional: data.img (ext4 filesystem), system.img (ext4), system/default.prop (system extracted)
the init will check every block device:
for device in ${ROOT:-/dev/[hmnsv][dmrv][0-9a-z]*}; do
check_root $device && break 2
mountpoint -q /mnt && umount /mnt
done
grub config:
set kd="/Android"
search --no-floppy --set android -f $kd/kernel
set root=$android
linuxefi $kd/kernel root=/dev/ram0 $src SRC=$kd
initrdefi $kd/initrd.img
boot
modified from https://www.android-x86.org/source.html
NoCode
npm postinstall 场景Docker构建优化
有些项目中 npm 会用到postinstall这个配置在安装完依赖做一些事情,这样在Docker 构建的时候,想缓存依赖的话会麻烦点,必须把代码整个复制,不然跑postinstall的就可能失败,可以使用 --ignore-scripts 优化,把postinstall 的逻辑拆开,安装完依赖后跑
比如
{
"name": "dataengine-doc-front",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "NEXT_PUBLIC_APP_ENV=local next dev",
"postinstall": "npm run generate:nav",
"generate:nav": "ts-node -O '{\"module\": \"commonjs\"}' scripts/generate-navigation.ts",
"dev2": "NEXT_PUBLIC_APP_ENV=development next dev",
"build": "npm…