客户端 vs web
轻量级应用,web永远是使用最方便的
React vs NextJs
需要后端持有数据库密钥,选NextJs,前后一把梭
Mongo
轻量级数据完全可以满足,有free tier
用Material UI搭积木
代码参看 github
媳妇儿看了下,媳妇儿表示很喜欢,表示还是excel更香(doge
]]>
以上是官网首页的代码片段,用一个方法实现了一个带图片和动画的卡片。满满的flutter/swift UI既视感,熟悉的嵌套,熟悉的kotlin的lambda表达式,第一印象,熟悉,简洁!
再一看,几行代码涵盖了layout,style,animation,image asset,state处理这些UI基本元素,UI用到的元素都有了,可以实战了。框架完成度,高!
把一个Kotlin方法加上@Composable注解,就是一个compose方法了。多个compose方法嵌套组合下,就可以实现复杂的UI,compose=组合。注解隐藏了实现细节,使用者可以更加focus在UI本身的实现上了。
1 | ├── android //生成的android包装工程 |
下载源码
注意手机支持的分支,直接检出
1 | repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r47 |
查看repo当前检出分支
git –git-dir .repo/manifests/.git/ branch -a
失败了不要紧,重新sync就好,之前下载的有缓存不会重头开始的
下二进制文件(vendor的驱动)
注意驱动对应的build number,而build bumber和之前检出的分支对应 OPM7.181005.003android-8.1.0_r47
对应关系查看https://source.android.com/setup/start/build-numbers
华为的和高通的两个文件都要下载 解压后运行对应的sh文件,会在aosp的根目录生成vendor目录
下载地址:https://developers.google.com/android/drivers
改环境,使用openjdk
1 | export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 |
编译源码
1 | build/envsetup.sh |
刷机
1 | export ANDROID_PRODUCT_OUT=your-aosp-path/out/target/product/angler |
ninja: build stopped: subcommand failed ninja failed with: exit status 1
解决:可能是本地环境问题 export LC_ALL=C
ref:https://stackoverflow.com/questions/51324238/aosp-build-stopped-subcommand-failedhttps://www.programering.com/a/MDM3UzNwATQ.html
LC_ALL=C is to remove all localized settings, make the correct execution.
/bin/bash: xmllint: command not found
解决:安装xmllint
sudo apt-get install libxml2-utils
Build with Jack …. Out of memory error GC overhead limit exceeded. Try increasing heap size with java option ‘-Xmx’.
解决:修改jack-server的配置文件ref:http://www.2net.co.uk/blog/jack-server.html
vim ~/.jack-settings
添加一行:
JACK_SERVER_VM_ARGUMENTS=”-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m”
重启下jack-server:
prebuilts/sdk/tools/jack-admin kill-server
prebuilts/sdk/tools/jack-admin start-server
flash完后不断重启
可能原因:
kotlin版的协程,比线程更轻量的异步任务操作实现。语言级别模拟实现“多线程”效果。
线程属于系统级概念,由系统调度执行
协程属于语言级概念,由应用自己管理调度/挂起/执行协程。
某些场景下协程反复使用同一格线程,多核处理器优势没有发挥
可以 refer this
The current version of kotlinx.coroutines is designed for production use. It is pretty well covered with tests, lots of things are already optimized, all the changes are made considering the issues of backwards compatibility with previously compiled code.
It certainly does serve as a test-bed for various coroutine-based things, so there are some parts that are clearly marked as “work in progress” or “unstable” in the documentation of the corresponding funs/classes. However, by default, all the public APIs in kotlinx.coroutines are considered to be stable.
Coroutine context: 协程的运行上下文,每个协程都运行在一个CoroutineContext中。上下文是一个比较泛泛的概念,可以是一个环境,可以是一个容器,提供各种运行时资源和状态。这里Coroutine context包含两个概念:CoroutineDispatcher和job(都是CoroutineContext的子类…),
CoroutineDispatcher提供job执行时使用的线程,job顾名思义定义了一个具体可执行的任务。这两个加起来就构成了cotoutine上下文
原文:
Coroutines always execute in some context which is represented by the value of CoroutineContext type, defined in the Kotlin standard library.
The coroutine context is a set of various elements. The main elements are the Job of the coroutine, which we’ve seen before, and its dispatcher, which is covered in this section.
launch:开一个协程,返回一个job引用 Launches new coroutine without blocking current thread and returns a reference to the coroutine as a Job. The coroutine is cancelled when the resulting job is cancelled.
async:开一个协程,返回一个deffered引用(带future结果的特殊job)async is just like launch. It starts a separate coroutine which is a light-weight thread that works concurrently with all the other coroutines. The difference is that launch returns a Job and does not carry any resulting value, while async returns a Deferred.
UI:安卓的主线程上下文
1 | val UI = HandlerContext(Handler(Looper.getMainLooper()), "UI") |
Deferred:轻量级、非阻塞的 future,可以通过await()来获得结果 a light-weight non-blocking future that represents a promise to provide a result later. You can use .await() on a deferred value to get its eventual result, but Deferred is also a Job, so you can cancel it if needed.
**await()**:启动一个新的协程,挂起当前coroutine直到新协程执行完并返回值
suspend function: 只能运行在coroutine中,在新的coroutine中执行时挂起当前coroutine
1 | //创建新的UI协程 |
线程上下文切换
即使是单核CPU也支持多线程执行代码,CPU通过给每个线程分配CPU时间片来实现这个机制。时间片是CPU分配给各个线程的时间,因为时间片非常短,所以CPU通过不停地切换线程执行,让我们感觉多个线程时同时执行的,时间片一般是几十毫秒(ms)。
CPU通过时间片分配算法来循环执行任务,当前任务执行一个时间片后会切换到下一个任务。但是,在切换前会保存上一个任务的状态,以便下次切换回这个任务时,可以再次加载这个任务的状态,从任务保存到再加载的过程就是一次上下文切换。
git config --global user.name "username"
git config --global user.email "mailbolx@163.com"
git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.proxy 'socks5://127.0.0.1:1080'
git config --global --unset http.proxy
git config --global color.ui true
git branch -u origin/master dev
git checkout -
git branch -vv
git checkout -t origin/dev //-t参数, 创建和远程分支一样名字的本地分支
git push [远程名] :[分支名]
git push origin :serverfix
git merge-base commit1 commit2
git stash/git stash pop
git diff HEAD~2..HEAD > my-patch.diff git format-patch HEAD~2..HEAD --stdout > changes.patch git format-patch -x --stdout > patch-ddmmyyy.patch git diff tag1 tag2 > the-patch.diff
git diff tag1 tag2 --stat
git log -- "some file/dir"
git diff tag1 tag2 -- some/file/name
git tag -a v1.4 -m "v1.4"
git tag -a v1.2 9fceb02
git push origin --tags
git push origin 标签名
git tag -d 标签名
git push origin :refs/tags/标签名
git submodule add https://github.com/hexojs/hexo-theme-light.git themes/light git commit -am "add submodule" git submodule init git submodule update
adb shell wm size/density
adb shell am start -W -n "packagename/absoluteMainActivityname"
adb shell dumpsys activity activities|grep -i focus
adb shell setprop log.tag.Email VERBOSE
adb shell dumpsys meminfo packagename
adb shell dumpsys package packagename
adb shell input text "dddd"
adb shell pm list packages -f |grep Email
adb shell monkey -p com.android.email --throttle 150 -v -s 3500 300000
adb shell netcfg
1 | adb disable-verity |
aapt dump badging app-release.apk
aapt dump permissions app-release.apk
aapt d --values resources ~/temp/EmailRes.apk >~/temp/email_string.txt
emulator -list-avds
emulator -avd xxx -shell
emulator -avd 3.7_WVGA_Nexus_One_API_23 -writable-system
android list sdk
android update sdk --no-ui --filter 2 --proxy-host mirrors.neusoft.edu.cn --proxy-port 80 -s
1 | adb reboot bootloader |
keytool -list -printcert -jarfile app.apk
/data/local/tcpdump -p -vv -s 0 -w /sdcard/capture.pcap
1 | -w 表示抓取的包保存的文件路径 |
shift + v, 然后上下左右移动。
使用github page + hexo搭建博客最佳实践。md文件和生成的博客网站文件分开管理,推送到各自的仓库保存。三步即可完成博客创建到发布并留档。
hexo new "new blog title"
写md文件hexo g -d
生成静态博客网站文件并部署到github pagegit commit -am "save" && git push
推送md文件到github1 | npm install -g hexo-cli |
注意repo name必须为你的用户名+.github.io(eg: gnehz972.github.io)
1 | hexo init hexoblog |
1 | hexo new "new blog" |
INFO Validating config
INFO Created: ~/dev/blog/hexoblog/source/_posts/new-blog.md
1 | hexo generate |
1 | hexo server |
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
1 | deploy: |
1 | hexo g -d |
1 | cd hexoblog |
1 | npm install hexo-theme-next |
1 | theme: next |