易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
vue-nprogress-pjax 插件

vue-nprogress-pjax 插件

基于昨天写的vue+blade+(vue-pjax-adapter),发现没有任何进度提示,感觉比较不直观,但vue-pjax-adapter不能注入方法(或许是我不会)。

在app.js里引入了nprogress后。在axios请求前尝试注入,比如:
window.axios.interceptors.request.use((config) => {
console.log(before);
NProgress.configure({easing: 'ease', speed: 1000, showSpinner: true});
NProgress.start();
return config;
});
window.axios.interceptors.response.use((response) => {
NProgress.done();
console.log(after);
return response;
}, (error) => {
return Promise.reject(error);
});
但是没有看到有任何需求。才尝试修改了一下vue-pjax-adapter插件
用法和vue-pjax-adapter完全一样:
import nPjaxAdapter from 'vue-nprogress-pjax';
window.Vue.use(nPjaxAdapter);
/**
* 如果不是标准的pjax-container,就是这样使用
* // window.Vue.use(nPjaxAdapter, {
// targetSelector: '#my-custom-target',
// });
*/
就这样简单。现在切换页面有进度条了
代码在这里:https://www.npmjs.com/package/vue-nprogress-pjax
搞定:Yii2+blade+vue+pjax

搞定:Yii2+blade+vue+pjax

如题,利用laravel-mix进行开发。HTML页面的blade,基本上只含主体结构 。具体的页面全部用vue加载(当成一个个的component)

这样就真正完全利用了vue的各种组件,然后也能享受PHP的变量开发,只是这样就得一个个的加载页面了(每次都得加载app.js,一个app.js可是将近2M的)
所以,加载vue-pjax-adapter。利用pjax的特性。少加载很多内容。但这个插件,原来也是for laravel的。用了之后,发现网址不会变了。看了下代码。他的pushState的更换居然是利用response.headers中的x-pjax-url,于是在Yii的controller->afterAction中增加:response->headers->set('x-pjax-url',url::current),一切都搞定
在开发的时候,使用mix文件的browseSync+webpack的watch。改动后自动刷新页面。也是一个不算爽的爽功能了
减轻不少压力。在没有专业前端的情况下也能享受VUE的开发乐趣(其实就是不用vuex,vue-router等)
测试数据库升到MYSQL5.7

测试数据库升到MYSQL5.7

测试了一下,将MYSQL升到了5.7的RDS,但该RDS因为不支持MYISAM,所以将表结构调整为INNODB,同时,因为PHP版本是7.2,可能带来了不少问题。

先这样尝试了。后续有问题我再调整。可能会慢上好多(很纠结)

报了很多异常。估计后续真的要转成Yii2了。其实5年前转过一次。那时候是用Yii1的,但因为中间要改的东西非常多,在写了2/3左右 的时候处理掉了。现在可能真的要重操起来了。(话说,现在PHP的博客好象也就只剩那几个了,什么Wordpress,Typecho还坚挺 的活着。)

是不是要坚持还真是一说。

将表结构转成gorm struct

将表结构转成gorm struct

在网上找了半天,找到两个项目与此相关

1、chrome的插件:https://github.com/mikemintang/sql2struct ,
2、go 程序:https://github.com/Shelnutt2/db2struct
1、chrome插件的Readme中所引用的crx文件,可能由于cdn的问题,无法下载,其实git里就有一个crx文件,点击查看详情,然后下载到本地。启用chrome extension的开发者模式,加载进来就OK了,使用方法很简单,直接将table 的ddl内容复制 到输入框里,就能够生成相应的struct。当然表前缀的问题是没法解决了,但至少你不用手写了。不是吗?
详细 教程看这个:http://idoubi.cc/2017/11/06/SQL2Struct%EF%BC%9A%E4%B8%80%E6%AC%BE%E6%A0%B9%E6%8D%AEsql%E8%AF%AD%E5%8F%A5%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90golang%E7%BB%93%E6%9E%84%E4%BD%93%E7%9A%84chrome%E6%8F%92%E4%BB%B6/,主要是这个有图,github里面没图
2、用官方Readme中的说法:Structures are created by querying the INFORMATION_SCHEMA.Columns table and then formatting the types, column names, and metadata to create a usable go compatible struct type.。
用法其实也很简单:【Example below uses guregu's null package, but without the option it procuded the sql.NullInt64 and so on.】
db2struct --host localhost -d example.com -t users --package example --struct user -p --user exampleUser --guregu --gorm
有这两个工具,生成struct就方便了。如果再配合这个:https://github.com/MohamedBassem/gormgen,那就更方便了(虽然也不一定会这样使用)
go mod 快速使用

go mod 快速使用

我自己的用法,不知道别人是不是这样的

感觉用了go mod ,gopath可以不用设置了。
老方法:src/pkg/bin,建三个目录,然后GOPATH设置在这个外层(因为感觉go get的时候好象还是会往pkg里扔,只是pkg多了一个目录叫:mod)
在src下建一个目录,比如:blog,在blog目录里go mod init
然后就是正常的用法了。比如你要引入啥,go get 就行 了。如果是你手动写的一个路径。你引入后,还得执行go mod tidy 。
只是这样我老是不能正常。所以我每次都选择 go mod tidy && go mod vendor,会在blog里生成Vendor的目录。然后就一切OK了。
go mod对我来说最方便的应该就是Replace了。比如我准备要放个代码上github(或者其他),但中途可能会改,总不可能一直先commit,再go get 吧?
所以replace github.com/xxx/xxx 0.0.1 => /Users/gouki/go/xxx/xxx ,切换到本地。。那边代码有更新。我这边go mod tidy && go mod vendor就完事儿了。
总感觉这样目前还不是最佳的。但先弄一下吧。至少我目前够用了
go install go-sqlite3时,报错:#include nested too deeply

go install go-sqlite3时,报错:#include nested too deeply

安装sqlite3的时候,报:

/usr/local/include/stdint.h:2:10: error: #include nested too deeply
#include <stddef.h>
^
/usr/local/include/stdint.h:59:11: error: #include nested too deeply
# include <stdint.h>
^
/usr/local/include/stdint.h:72:11: error: #include nested too deeply
# include <sys/types.h>
^
/usr/local/include/stdint.h:76:10: error: #include nested too deeply
#include <limits.h>
^
/usr/local/include/stdint.h:82:11: error: #include nested too deeply
# include <inttypes.h>
^
5 errors generated.
开始的时候以为cgoenabled=0结果 。go env的时候发现有打开。
又以为可能是xcode-select 没装,于是执行xcode-select --install 进行工具安装 。症状依然。最后找到这里:https://github.com/SOHU-Co/kafka-node/issues/881,看来有不少人有这个问题。只是有人说,brew doctor一下就行了。光执行,并没啥用
最后有一个人提出:
mkdir /tmp/includes
brew doctor 2>&1 | grep "/usr/local/include" | awk '{$1=$1;print}' | xargs -I _ mv _ /tmp/includes
一下子全解决了!
Q: Problems upgrading to macOS Mojave on MacBook Pro 2018

Q: Problems upgrading to macOS Mojave on MacBook Pro 2018

有人说重置SMC可以解决这个问题,然而我没有试。最后看LOG,居然一堆连网错误,难道要校验checksum?

再到苹果官网上看到这个:
Hi,

Had the same problem, but for me it worked by

removing all DNS search domains
untick the automatic proxy configuration


for the Wifi adapter.

good luck.
果然尝试。果然有效(最终发现还是有问题,终于。。重置NVRAM,安装完成)
节选
Next, let’s try out the basic NVRAM reset (or PRAM for older Macs) on your computer.
Follow these steps if you are not sure about how to do the NVRAM reset
Shut down your Mac
Turn it on and immediately press and hold these four keys together: Option, Command, P, and R macOS Could Not Be Installed, How-To Fix
Release the keys after about 20 seconds, during which your Mac might appear to restart
Open System Preferences and check (and adjust, if necessary) any settings that reset, like volume, display resolution, startup disk selection, or time zone
说白了,就是启动的时候 cmd+option+P+R,等20秒。放开,再重启
一切都清静 了。只是感觉这一版,没什么变动的
gorm的一些Callback

gorm的一些Callback

要知道gorm的callback看代码就可以知道了:

func init() {
DefaultCallback.Create().Register("gorm:begin_transaction", beginTransactionCallback)
DefaultCallback.Create().Register("gorm:before_create", beforeCreateCallback)
DefaultCallback.Create().Register("gorm:save_before_associations", saveBeforeAssociationsCallback)
DefaultCallback.Create().Register("gorm:update_time_stamp", updateTimeStampForCreateCallback)
DefaultCallback.Create().Register("gorm:create", createCallback)
DefaultCallback.Create().Register("gorm:force_reload_after_create", forceReloadAfterCreateCallback)
DefaultCallback.Create().Register("gorm:save_after_associations", saveAfterAssociationsCallback)
DefaultCallback.Create().Register("gorm:after_create", afterCreateCallback)
DefaultCallback.Create().Register("gorm:commit_or_rollback_transaction", commitOrRollbackTransactionCallback)
}
类似:beginTransactionCallback 的一共有9个,事务和创建等等。一般事务的话会用的比较多一点,还有就是针对时间的beforecreate等
当然更多的还得看官方的文档:http://gorm.io/zh_CN/docs/hooks.html。默认会执行什么,应该执行什么,这里都有写,可以看一下下的
mac 修改 ulimit

mac 修改 ulimit

下述是指在mac下面。linux 8 是这样的

ulimit -n 运行一下,看看是多少,如果是65536就算了。不是的话,如果有需要就自己改一下。常见的ulimit -n 65536,直接运行就行了,但这只是临时的

其实以下内容是COPY来的。我没有细究。
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -n
256
$ ulimit -n 1048576
$ ulimit -n
1048576
一步一步学gin

一步一步学gin

从13年之后就再也没有碰过GO,当时遇到的问题都很妖,所以后来就再也没碰过(为什么我的需求都那么怪?)

重操GO,准备花上1~2周温习,直接上项目吧,这个网址不错:https://github.com/EDDYCJY/blog,简单的教程,等我看完先