易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
Dcat-Admin with vue

Dcat-Admin with vue

有时候你不得不承认,DCAT-admin / laravel-admin 做后台是属于比较方便的。你硬要说nova之类的,我也无话可说。但毕竟nova要钱,而且文档并没有国内的全。

为什么说dcat-admin,主要还是laravel-admin好久没有大更新了。然后laravel-admin的多应用要钱。虽然我买了,但更新太慢,我现在还是用dcat了。

很多人在github上面问,为什么不支持VUE。其实也能理解 ,vue如果用了, pjax就不太好用了。但我还是得说,如果你只是简单的,不做特别复杂的应用,还是有办法支持vue的。

首先全局引用JS,Admin::js(),这个不用多说,如果不想全局引用,那就在自己的页面里,将它引用出来就行了。

然后用了个简单的demo,

<div id="sign-form">
@{{ form }}
<el-input v-model="input" placeholder="请输入内容"></el-input>

<el-steps :active="active" finish-status="success">
<el-step title="步骤 1"></el-step>
<el-step title="步骤 2"></el-step>
<el-step title="步骤 3"></el-step>
</el-steps>

<el-button style="margin-top: 12px;" @click="next">下一步</el-button>

</div>
<script>
var form = {};
new Vue({
el: '#sign-form',
data() {
return {
form: form,
input: '{{date('Y-m-d H:i:s')}}',
active: 0
};
},
mounted() {
this.request();
},
methods: {
formReset() {
this.form = form;
},
request() {
this.form = {a: 1, b: 2, c: 3, d: 5};
{{--laravel.get('{{api_url('union/bind/check/123')}}', res => {--}}
{{-- console.log(res);--}}
{{--});--}}
},
next() {
if (this.active++ > 2) this.active = 0;
}
}
});
</script>

保存后,点开网页看看。确实不会再加载了。但这种VUE,就只适合单页面用用了(当然,本身也就是为了在复杂的表单上使用它。也够了)

---差点没有保存。。

linux上,非www-data用户如何往www-data组里写文件

linux上,非www-data用户如何往www-data组里写文件

现在买VPS,默认用户都不再是root,都是一些什么:admin之类的。

如果安装了apache2,你会发现,web目录都是www-data的。然后会有各种小问题
1、命令行生成的文件,权限组怎么弄
2、通过WEB生成的文件,命令行怎么读。
以下内容来自overtrue的一篇旧文,只是一小段内容,全文请移步:https://zhuanlan.zhihu.com/p/38112190

服务器端的配置

此部分在目标服务器上操作

虽然说是无侵入的部署工具,但是还是需要我们来做一些微小的配置的,因为出于安全考虑,我们一般不会开发 root 用户的 SSH 登录,而是使用其它用户,比如 Ubuntu 默认的 ubuntu 用户。
我们 Deployer 是用来部署 web 应用的,所以我们也专门创建一个用户来做这件事情比较好:

$ sudo adduser deployer # 密码什么的,按提示操作即可

我们的 web 项目通常需要一些上传,或者缓存写入这样的操作,所以 deployer 还需要有权限对目录进行修改,比如 Laravel 的 storage 目录需要可写权限,这里以 nginx 默认的用户组 www-data 举例,如果你修改过用户或者组名请对应修改下面的命令里的 www 用户组:

$ sudo usermod -aG www-data deployer

我们通常需要将deployer 用户权限分别设置为创建文件 644 与目录 755,这样一来,deployer 用户可以读写,但是组与其它用户只能读:

$ sudo chfn -o umask=022 deployer

接下来要对我们的 web 根目录授权,假设我们的 web 服务的根目录在 /var/www/ 下,那么需要将这个目录的用户设置为 deployer ,组设置为 www 用户 www-data:

$ sudo chown deployer:www-data /var/www/html # 最后这里不要加斜线哦

为了让 deployer 用户在 /var/www/html 下创建的文件与目录集成根目录的权限设定(用户:deployer,组:www-data),我们还需要一步操作:

$ sudo chmod g+s /var/www/html

OK,Deployer 的用户操作就结束了,接着你需要检查以下配置:

----
更多内容,可以查看原文
树莓派还是换成了ubuntu

树莓派还是换成了ubuntu

基于几个小原因,换成了ubuntu

1、配置单网卡路由+WIFI没搞定。每次一折腾就断网(或许有机会,但我没有microHDMI线。所以断了,我就只能重刷机。太累了)
2、ubuntu 20,居然是支持64位的。这里不得不说,人家支持的就是好。。。rasbian现在还是32位的
当然也不是说rasbian就没有超过ubuntu的。比如他的vncserver就比ubuntu好。ubuntu没有,而且装vnc4server也装不上,唯一可以装的居然是xrdp。为了装这个xrdp,居然要1G左右 的下载。
当然最终我还是没有选择桌面,即使这样,下载回来的xz文件。居然也要1.1G左右 。而debian只要400M。
不扯其他的,因为毕竟是两个系统,所以在初始化配置的时候就不太一样。比如rasbian就是创建空ssh文件,和增加wpa_supplicant.conf文件。而ubuntu就不一样,直接改net-config(好象是这个。或者是network-config这个文件)。是一个yml格式的文件,参考一下就OK。【如果你的ssid有空格或者其他的,请用双引号包住】
然后还有一个userdata(或者叫:user-data)文件。里面有一个配置password是不是会过期。。默认是过期的。我开始就是被它折腾。一登录就让我改密码,一改密码就说过期。。。。
其他的都差不多,然后ubuntu装好进去后。居然每次还有提示。让我装microk8s。。。嗯,暂不理他,我还是老规矩:安装pm2 / frp ,更改源为阿里。
树莓查看CPU温度

树莓查看CPU温度

SSH下有两个简单的方法

1、/opt/vc/bin/vcgencmd measure_temp

这个显示的直接就是可视的温度,如:temp=40.0'C

2、cat /sys/class/thermal/thermal_zone0/temp

这个显示的是数字,需要简单的看一下:39920

VNC连上树莓后,显示:Cannot current show this desktop.

VNC连上树莓后,显示:Cannot current show this desktop.

用树莓派,其实就是一个 折腾。看了一下资料,其实现在NUC比树莓大不了多少。但NUC可以直接SSD硬盘啊。而树莓没有。

当然,树莓也有自己的好处,比如,我可以折腾几个SD卡,装上不同的工具。想用哪个的时候插哪个就行了,除了卡一点。

为什么用VNC,就是因为create_ap失败。想看看图形下怎么搞,结果vnc报这个错。

OK,运行:sudo raspi-config,进入Advanced Options,然后选择Resolutions,选择一个你想要的分辨率的。默认的分辨率是300x200,所以不能显示。想想树莓都能 支持4K了。还是选个最大的吧。

点击OK后,提示重启。

然后VNC就可以连接了。

无数据线,通过wifi连接树莓派4

无数据线,通过wifi连接树莓派4

网上很多类似的教程,我刚买了个树莓派4,没有micro hdmi线,没有USB线。没有键盘鼠标。开始很纠结。怎么办呢?

因为,插了有线也搜不到网络。后来google了一下,有一堆文章在说这个:
按照上面的试了一下,但死活连接不上。我以为是用的lite的img文件,开始以为是img的问题。换了full的也这样。
因为开始遇到点小问题,比如。我明明建了空ssh文件和wpa_supplicant.conf,但每次发现wifi打不开的时候。把卡拿出来放到读卡器,这两个文件就不见了。开始以为是卡只读的,后来才知道。。。只是被系统移走罢了
OK,那究竟为什么呢?我就在猜,是不是因为5G的原因?我连接的都是5G的网络。于是换成2.4G的,结果。。。。。通了。
崩溃啊。就因为连接了5G的网络,浪费了我2小时。
mac 如何将img文件写到 SDCard

mac 如何将img文件写到 SDCard

有三篇教程

mac上本来双盘COPY是很简单的,打开diskutil,加载两个磁盘,对着要恢复的盘,右键:选择恢复,可以选择 img/dmg文件,也可以选择已经 mount的磁盘。然而在恢复树莓的时候,一直失败【忘了截图了】
于是找到了教程1,教你怎么在命令下行备份,方法很简单,就2步
1、diskutil list,查看你的SD卡对应的是哪个磁盘,
2、备份:sudo dd if=/dev/rdisk1 of=/path/to/backup.img bs=1m
恢复:sudo dd if=/path/to/backup.img of=/dev/rdisk1 bs=1m
3、如果觉得太大,还可以gzip
备份:sudo dd if=/dev/rdisk1 bs=1m | gzip > /path/to/backup.gz
恢复:gzip -dc /path/to/backup.gz | sudo dd of=/dev/rdisk1 bs=1m
如果你仔细看教程1,你会发现,diskutil list,显示的是当前磁盘,大部分都是直接写的/dev/disk3 之类的,而 上面的备份命令却写的是 rdisk1 。这是什么原因?教程1给了个wiki:https://elinux.org/RPi_Easy_SD_Card_Setup#Copying_an_image_to_the_SD_card_in_Mac.C2.A0OS.C2.A0X_.28command_line.29,有兴趣的话,可以去看看。
如果不想深究原因,那么看教程2,他会教你怎么弄,
1、df -h,看一下自己的SD卡是哪个,你会看到这时候显示的又和 diskutil list 不一样,df -h显示的都是 /dev/disk3s1 之类的
2、用diskutil unmount /dev/disk3s1,将它unmount掉
3、df -h 发现没有 /dev/disk3s1了
4、这时候参考 上面的rdisk方法,写入磁盘 /dev/rdisk[n] , 这个 n,就是刚才你 disk[3]s1 中的3,具体情况看你自己的sd卡是哪个盘
比如我这样:
sudo dd if=/Volumes/documents/2020-05-27-raspios-buster-lite-armhf.img of=/dev/rdisk3 bs=1m
1768+0 records in
1768+0 records out
1853882368 bytes transferred in 24.396307 secs (75990287 bytes/sec)
写入成功。
我就只知其然不知其所以然了,也没有过多深究。有兴趣的话,可以看看上面的教程3
博客迁移准备2步走了

博客迁移准备2步走了

1、在接下来的时间里,尽量不再增加新的图片

2、写脚本,将现有图片全部迁移上云

3、后端先重写,理论上后端重写可以完全不影响前端的显示,而且我发现用到现在,整个后台,其实只用到了内容发布,其他的几乎都已经几年没有动用过了。博客已经成为了纯粹的内容发布平台

4、再重写前端。原来考虑的就是太多。所以到最后啥也没弄成。现在考虑的是后台用dcat-admin,可以少写上千行代码。

5、前台的评论也还是要写的。原来的评论,我还得登录后来进行删除或者怎么怎么样。准备后面直接接入:sandbox的微信,用它来发通知给我。这样就好办多了

6、后台的登录,也准备是用sandbox的微信来嫩,又感觉可以少写很多代码。也防止了别人乱登录。多开心的事情啊~

为什么要这样嫩呢?这样的话,代码就可以放到GIT上了。原来代码没有和附件分离,一搞就是几个G,有点恐怖。现在这样的话,会好很多了应该。

目前数据库也不大,只有20多M,还算好

composer clear-cache

composer clear-cache

看起来这个标题好象没啥,今天被折腾了好久

因为网络不好,所以在更新的时候一直更新不下来。再更新就报zip包出错,多次尝试都是这样。
删除vendor目录,再试也是这样
开始以为是墙的问题,毕竟压缩包都在github上,所以爬了梯子试了下,还是zip包出错
因为发现问题都是出现在load from cache,所以想了下,还是用composer clear-cache清空一下。然后composer global update,再回到本目录,进行composer update
一切OVER

Creating root-level directories and symbolic links on macOS Catalina

这是一篇引用文章,原文来自:https://derflounder.wordpress.com/2020/01/18/creating-root-level-directories-and-symbolic-links-on-macos-catalina/,可能部分用户打不开,毕竟是wordpress.com。。。

我简单的COPY一下:

One of the changes which came with macOS Catalina was the introduction of a read-only root volume for the OS. For users or environments which were used to using adding directories to the root level of the boot drive, this change meant they could no longer do that.

To address this need, Apple added a new method for creating directories at the root level which leverages Apple File System’s new firmlink functionality. Firmlinks are new in macOS Catalina and are similar in function to Unix symbolic links, but instead of only allowing travel one way (from source to destination) firmlinks allow bi-directional travel.

The use of firmlinks is exclusively reserved for the OS’s own use, but Apple has also made available what are called synthetic firmlinks. These synthetic firmlinks are how the OS enables folks to create directories and symbolic links on the read-only boot volume. For more details, please see below the jump.

To create a synthetic firmlink, you need to do the following:

1. Create a file in the /etc directory named synthetic.conf.
2. Make sure /etc/synthetic.conf has the following permissions:

  • root: read, write
  • wheel: read
  • everyone: read

3. In /etc/synthetic.conf, define the name(s) of the empty directory or symbolic link you want to have appear at the root level.

4. After all desired entries have been made, save the /etc/synthetic.conf file.

5. Restart the Mac to apply the changes.

For example, /etc/synthetic.conf may look like this:

# create an empty directory named "foo" at / which may be mounted over
foo

# create a symbolic link named "bar" at / which points to
# "System/Volumes/Data/bar", a writeable location at the root of the data volume
bar System/Volumes/Data/bar

# create a symbolic link named "baz" at / which points to "Users/me/baz"
baz Users/me/baz

Note: In those cases where you’re creating a symbolic link and are including a path, the start point for the directory path is not /. Instead, it is the next directory level down.

To show how this works, I’ve created a directory containing installer packages located at /Users/Shared/installers.

Screen Shot 2020 01 17 at 10 46 06 PM

To create a symbolic link at the root level named installers which points to /Users/Shared/installers, I would do the following:

1. Create the /etc/synthetic.conf file if it didn’t already exist.
2. Add the following entry to the /etc/synthetic.conf file:

1
installers Users/Shared/installers

Screen Shot 2020 01 17 at 10 32 45 PM

3. Reboot the Mac.

Note: Whomever designed this came down on the “tabs” side of the “tabs vs. spaces” debate. When creating the separation between installers and Users/Shared/installers in the /etc/synthetic.conf file, you need to use tabs. If you use spaces instead, the synthetic firmlink won’t be created.

After the reboot, you should see a symbolic link named installers at the root level of the boot volume. When you navigate to it, you should see the contents of /Users/Shared/installers.

Screen Shot 2020 01 17 at 10 33 30 PM

To remove the symbolic link, remove the relevant entry from /etc/synthetic.conf and then restart. After the reboot, the installers symbolic link should be missing from the root level of the boot volume.

Screen Shot 2020 01 17 at 10 46 15 PM

For more information, please see the synthetic.conf man page. This is available by entering the following command in Terminal on macOS Catalina:

man synthetic.conf,可以看到内容大致这样:

SYNTHETIC.CONF(5) BSD File Formats Manual SYNTHETIC.CONF(5)

NAME
synthetic.conf

SYNOPSIS
synthetic.conf -- synthetic symbolic link and directory manifest

DESCRIPTION
synthetic.conf describes virtual symbolic links and empty directories to
be created at the root mount point. Because the root mount point is read-
only as of macOS 10.15, physical files may not be created at this loca-
tion. All writeable paths must reside on the data volume, which is
mounted at /System/Volumes/Data.

synthetic.conf provides a mechanism for some limited, user-controlled
file-creation at /. The synthetic entities described in this file are
synthesized by the kernel during early system boot. They are not physi-
cally present on the disk, but when the system is booted, they behave as
if they were within certain parameters.

synthetic.conf is intended to be used for creating mount points at /
(e.g. for use as NFS mount points in enterprise deployments) and symbolic
links (e.g. for creating a package manager root without modifying the
system volume). synthetic.conf is read by apfs.util(8) during early sys-
tem boot.

FORMAT
synthetic.conf specifies a single synthetic entity per line. Each line
may have one or two columns, separated by a tab character. If a line has
a single column, it denotes a virtual empty directory to be created at /.
If a line has two columns, it denotes a symbolic link at / whose link
target is given in the second column.

In either case, the first column denotes the name of the entity to be
created at /.

A line beginning with the # character indicates a comment that is not
parsed.

SYNTHETIC ENTITIES
Synthetic entities may not be deleted at runtime. In order to delete a
synthetic entity, it must be removed from synthetic.conf, and the host
must be rebooted.

New files and directories may not be created within a synthetic empty
directory.

EXAMPLES
# create an empty directory named "foo" at / which may be mounted over
foo

# create a symbolic link named "bar" at / which points to
# "System/Volumes/Data/bar", a writeable location at the root of the data volume
bar System/Volumes/Data/bar

# create a symbolic link named "baz" at / which points to "Users/me/baz"
baz Users/me/baz

FILES
/etc/synthetic.conf

SEE ALSO
apfs.util(8) shutdown(8) reboot(2)

Darwin/macOS 2 July 2019 Darwin/macOS
参考 一下上面的内容,可以简单的试用一下。其实还行吧。(如果图片看不到。。就忍忍吧。)
---------
说白了就是几个事
1、在/etc目录下建一个 synthetic.conf 文件
2、设定的权限是:root 读写 wheel 读 everyone 读 ,权限值为:644
3、每行一条记录,目录名和目标引用的目录
比如你要在根目录下映射 一个 server,对应的是 /Users/gouki/Desktop,那就直接: server /Users/gouki/Desktop 就完事了
4、重要:改完得重启。。。。
--EOF
说白了,现在不支持根目录下的ln了。只能通过这个办法。如果有特别需要就试试吧。。。
----
::划重点::
1、权限是644
2、两个目录之间的间隔用tab,不是空格。原例子里用的是nano编辑 ,我用vim编辑的时候,tab居然无法输入(崩溃 )
3、对应的目录前好象不需要 /
4、多测试几次吧。我重启了三次才搞定