这是我最讨厌大前端的地方

明明一个alert提示框就能搞定的事情,非搞的跟操作系统内核般复杂
静夜思 发布于 2022-11-21 22:54 | 阅读 3179 次 | 评论 1 条

docker把所有的镜像备份到一个文件

备份到一个文件: docker save $(docker images --format '{{.Repository}}:{{.Tag}}') -o allinone.tar 恢复到所有镜像: docker load -i allinone.tar
静夜思 发布于 2022-11-21 21:38 | 阅读 746 次 | 评论 0 条

linux查看端口占用

比如查看5500这个端口被谁占用了: lsof -i:5500
静夜思 发布于 2022-11-21 14:25 | 阅读 756 次 | 评论 0 条

求解! c|c++用栈来描述将十位进制数转换为2,8,16进制 选择使用switch为何不进入switch而直接跳出?

#include<iostream> #include<malloc.h> #include<stdio.h> #define STACKINITSIZE 100 #define STACKINCREMEMT 10 using namespace std; typedef struct{ int *base; //动态存储空间的基地址,栈底 int *top; //栈顶指针,指向真实栈元素的下一个位置 int stacksize; }Sqstack; void InitStack(Sqstack &amp;S){ //创建动态空间 S....
季白的杜衡 发布于 2022-11-20 11:47 | 阅读 762 次 | 评论 0 条

django4.1.3及以上的版本提示“django.db.utils.NotSupportedError: MySQL 5.7 or later is required”的解决办法

网站升级到 django4.1.3 后,连接老版本的数据库(mysql5.5)的时候,时不时出现错误: File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 207, in check_database_version_supported raise NotSupportedError( django.db.utils.NotSupportedError: MySQL 5.7 or later is required (found 5.5.53). 解决...
静夜思 发布于 2022-11-17 03:15 | 阅读 9488 次 | 评论 11 条

ubuntu动态getway4设置静态IP的方法

本来都设置成静态很好 network: ethernets: enp0s3: addresses: [192.168.42.116/24] gateway4: 192.168.42.129 nameservers: addresses: [8.8.8.8, 114.114.114.114] version: 2 可惜魅族手机的便携式热点是动态getway4,每次开启都会随机分配一个,所以不能指定gateway4 可以用下面的dhcp4连接: network: ethernets: ...
静夜思 发布于 2022-11-12 03:29 | 阅读 806 次 | 评论 0 条

mysql报错 2061, "Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection." 的解决办法

原因是mysql 8为了提高安全性,默认使用caching_sha2_password作为密码加密方式,需要加密连接,加密连接需要证书,详见:https://www.jianshu.com/p/d677bb316ab0 这里提供一个更简便的解决办法,使用老的密码加密方式: 在phpmyadmin中管理账户,点进去账户后点上面的“Change password”,重设密码,密码加密方式选择“MySQL自带身份验证”
静夜思 发布于 2022-11-10 15:20 | 阅读 2166 次 | 评论 0 条

django models.FileField 保存文件的几种方式

假设是一个model,名为Attach class Attach(models.Model): file = FileField(upload_to="files/%Y/%m/%d") 保存上传文件,这个最简单: def upload(request): attach = Attach() attach.file = request.FILES.get('file') attach.save() 保存网络上采集的文件: import requests from django.core.files.base import Cont...
静夜思 发布于 2022-11-07 18:15 | 阅读 1042 次 | 评论 0 条

ubuntu20.04中插件hide top bar无效的解决办法

通过以下命令安装后 sudo apt install gnome-shell-extension-autohidetopbar 网上的教程都是用Tweaks打开,如果删除过 gnome-shell-extension-autohidetopbar 这个插件再次安装,可能无效。 解决办法: 用Extensions打开,在应用中搜索“Extensions”,然后在里面打开 hide top bar 即可:
静夜思 发布于 2022-11-04 01:14 | 阅读 1017 次 | 评论 0 条

Python中等同于php中urlencode的函数

是: urllib.parse.quote 而不是 urllib.parse.urlencode
静夜思 发布于 2022-10-31 22:24 | 阅读 912 次 | 评论 0 条

find命令结合ag搜索特殊路径下文件的内容

比如搜索路径名含有“active”的,并且内容中含有“doesn't match”的ruby文件: find . | ag 'active' | xargs ag "doesn't match" --ruby 原需求是在rails框架源代码中搜索“doesn't match”,但是在gems目录下不止rails框架,还是其他gem,而只有rails框架的文件路径中含有“active”,所以就用上面的管道先把rails框架中的文件过滤出来,再从这些文件中搜索关键词
静夜思 发布于 2022-10-28 23:07 | 阅读 1058 次 | 评论 0 条

rails查看某个模型的所有验证规则

比如User模型,则用: User.validators
静夜思 发布于 2022-10-28 20:28 | 阅读 736 次 | 评论 0 条

Virtualbox鼠标不好使不太灵光的解决办法

其实Virtualbox对鼠标和触摸板是有优化的,这就导致,如果你用的是鼠标,Virtualbox却向触摸板方向优化,当然会导致鼠标不太好使,解决办法如下: 打开设置 - 系统,指点设备选择 “PS/2 鼠标”
静夜思 发布于 2022-10-27 22:17 | 阅读 2808 次 | 评论 0 条

修改vscode的鼠标手形为指针(cursor:pointer改为cursor:default)

vscode总让人感觉不像软件像网页,很大一方面原因是鼠标移动到标签等位置的时候,鼠标变成手形,类似网页中鼠标移动到链接上的形状,可以把它改成指针的形状。方法如下: 打开 Microsoft VS Code\resources\app\out\vs\workbench\workbench.desktop.main.css 文件,把所有的“cursor:pointer”替换为“cursor:default”
静夜思 发布于 2022-10-26 22:56 | 阅读 1170 次 | 评论 0 条

rails清空Sprockets缓存

在rails开发中,有时候修改了assets里的静态文件名不生效,可能是Sprockets缓存的问题,可以用下面的命令清空: rake tmp:cache:clear 然后再运行 rails s 即可,初次运行后刷新页面需要很长时间,因为缓存被清空了第一次要建立缓存,后面再刷新就很快了
静夜思 发布于 2022-10-23 00:39 | 阅读 439 次 | 评论 0 条

opal对layer弹层的简单封装

def layer_open(h) type = h[:type] || 1 title = h[:title] skin = h[:skin] || 'layui-layer-rim' area = h[:are] || ['420px', '240px'] content = h[:content] success = h[:success] || proc {} layer_index = ` layer.open({ type: #{type}, title: #{title}, s...
静夜思 发布于 2022-10-22 22:55 | 阅读 806 次 | 评论 0 条

rails使用has_secure_password进行身份验证

生成模型 rails g model User username:string email:string password_digest:string 在user模型加入has_secure_password class User < ApplicationRecord has_secure_password end
静夜思 发布于 2022-10-19 23:43 | 阅读 933 次 | 评论 0 条

opal-jquery对等jquery里面的$(this)

evt.current_target对等$(this),如 Document.find('h1').on :click do |evt| puts evt.current_target.html end 对等jquery的 $('h1').click(function () { console.log($(this).html()) })
静夜思 发布于 2022-10-19 11:59 | 阅读 370 次 | 评论 0 条

Linux服务器瘦身,清理journal日志

查看日志大小 du -sh /var/log/journal/ 只保留一天内的日志 journalctl --vacuum-time=1d
静夜思 发布于 2022-10-18 21:20 | 阅读 822 次 | 评论 0 条

rails的数据库字段类型,migrations中常用到

The ActiveRecord data types available in Rails 5. :primary_key :string :text :integer :bigint :float :decimal :numeric :datetime :time :date :binary :boolean ...
静夜思 发布于 2022-10-16 10:50 | 阅读 864 次 | 评论 0 条