laravel 的 $request 改值操作

// 合并输入,如果有相同的key,用户输入的值会被替换掉,否则追加到 input
$request->merge(['foo' => 'bar', ....]);

// 替换所有输入
$request->replace([..])

// 设置某参数,如果存在则替换,否则新增
$request['foo'] = 'bar';

// 移除某参数
unset($request['foo'])

laravel 的表单验证

使用 request 注入验证时,获取路由中的参数:

// 获取当前需要排除的id,这里的 user 是 路由 {} 中的参数
$id = $this->route('user');

字段唯一性同时排除指定ID验证:

// unique:表名,字段,需要排除的ID
'user' => 'required|unique:users,user,' . $id

匹配字段验证(如输入两次密码是否一致):

'password' => 'required|min:8|confirmed',
'password_confirmation' => 'required' // 可选验证规则,但名称一定要使用 +_confirmation 方式命名

配置ssh登录别名

在使用 ssh 或 scp 时,通常使用 ssh -p 22 -i /path/to/pem user@hostname,如果主机名太长,或是 pem 文件太深,输入时很不方便,其实可以配置别名来简化输入。

编辑或创建文件 ~/.ssh/config,输入以下内容:

Host server
 User user
 HostName ipaddress_or_hostname
 IdentityFile /path/to/pem
 port 22

不需要的参数(例如 IdentityFile)可以不写,允许添加多个别名配置

使用方法:

# 登录到服务器
ssh server
# 复制文件
scp ~/file server:~/

debian系安装fcitx输入法

$ sudo apt-get install fcitx fcitx-ui-classic fcitx-config-gtk2 fcitx-frontend-gtk* fcitx-frontend-qt* fcitx-table-wbpy fcitx-sunpinyin fcitx-module-cloudpinyin

安装完后默认云拼音使用 google 方案,但是国内可能不能用,可以选用 baidu 方案。

linux中mariadb安装后phpmyadmin 无法连接的问题怎么解决

There are 2 ways to solve this:

  1. You can set the root user to use the mysql_native_password plugin
  2. You can create a new db_user with you system_user (recommended)

Option 1:

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Option 2: (replace YOUR_SYSTEM_USER with the username you have)

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

账号初始化:

$ sudo mysql_secure_installation

默认root密码为空;然后设置root密码和其他选项:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

登陆MariaDB命令行:

$ sudo mysql -u root -p

安卓上怎么安装第三方exchange同步服务

在没有自带exchange服务的安卓手机上(很少见,很奇葩,比如一加5T),无法通过exchange同步日历、联系人、邮件等数据(我只需要同步日历),只能安装第三方同步软件,推荐使用 Exchange+ Mail Client (其实也没有更多选择)管理同步,Google Play 地址。安装后与正常手机一样操作。

wine运行windows软件

ubuntu 用户可以使用 deepin 提供的方案,简单稳定,去看看

[toc]

安装 winehq

官网安装

# 如果是 64 位系统
sudo dpkg --add-architecture i386
wget -nc https://dl.winehq.org/wine-builds/Release.key
sudo apt-key add Release.key
# ubuntu
sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
# mint 18.x
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'
# mint 19
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
sudo apt-get update
sudo apt-get install --install-recommends winehq-stable

使用 winetricks-zh (推荐)

下载 winetricks-zh,解包,在命令行运行其中的 winetricks-zh 即可开始安装。如需安装 32位 程序,使用 WINEARCH=win32 winetricks-zh

  • TIM WINEARCH=win32 winetricks-zh tim
  • 微信 WINEARCH=win32 winetricks-zh wechcat

使用 palyonlinux

# 先安装 winehq
sudo apt install playonlinux

常见软件要用的库

微信
msls31 ole32 riched20 riched30

迅雷极速版
mfc42 riched30 vbrun6 vcrun6

百度网盘
riched20 wininet

QQ任务栏图标不显示

ubuntu 12.04系统

# 执行下列命令
sudo apt-get install libappindicator1
sudo apt-add-repository ppa:gurqn/systray-trusty
sudo apt-get update
sudo apt-get install unity
# 重启系统,或 logout/login

ubuntu 14.04以及以上系统

# 执行下列命令
sudo apt-add-repository ppa:fixnix/indicator-systemtray-unity
sudo apt-get update
sudo apt-get install indicator-systemtray-unity
# 重启系统,或 logout/login

中文显示与字体设置

Windows支持字体链接:当一种字体中不存在某个字时,可以尝试从另一个字体文件中寻找相应的字形。所以只要把当前系统中的中文字体设为”fallback”字体,汉字通常就能正确显示了。方法也很简单,只需创建一个文本文件,如 chn_font.reg ,内容如下:

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Lucida Sans Unicode"="wqy-microhei.ttc"
"Microsoft Sans Serif"="wqy-microhei.ttc"
"MS Sans Serif"="wqy-microhei.ttc"
"Tahoma"="wqy-microhei.ttc"
"Tahoma Bold"="wqy-microhei.ttc"
"SimSun"="wqy-microhei.ttc"
"Arial"="wqy-microhei.ttc"
"Arial Black"="wqy-microhei.ttc"

注意请将wqy-microhei.ttc替换为你系统中的字体文件名,如文泉驿正黑是wqy-zenhei.ttc(请在/usr/share/fonts及其子文件夹中寻找相应字体文件)。
如果想使用其它字体,也可直接将相应的ttf或ttc文件复制到~/.wine/drive_c/windows/Fonts/,再用其文件名替换上面的wqy-zenhei.ttc即可。

打开注册表 wine regedit,导入上面的注册表文件即可。

参考资源:

  1. http://blog.csdn.net/ddk3001/article/details/47213087
  2. http://linux-wiki.cn/wiki/zh-hans/Wine%E7%9A%84%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E4%B8%8E%E5%AD%97%E4%BD%93%E8%AE%BE%E7%BD%AE

怎么在linux下安装office

linux版本:ubuntu xenial
office版本:office 2010

安装 playonline

sudo apt install playonlinux

安装 winbind

sudo apt install winbind

安装 office
挂载 office 安装盘后,启动 playonlinux,点击 安装,(首次运行需要等待刷新列表),选择 办公office 2010(只支持32位),按提示安装。

输入法
在Office的 选项高级里,取消掉 输入法处以激活状态 的勾,再重启office就好了。