laravel dcat-admin multipleSelectTable options 自定义内容

按照官方文档给 multipleSelectTable options 设置自定义内容始终无效,研究了底层代码,才发现需要和value匹配,才能正常显示。

$form->multipleSelectTable('company_ids', '出品方')
        ->title('选择出品方')
        ->from(ProductionCompanyTable::make(['id' => $form->getKey()]))
        ->value(function(){
            return '1,2,3'; 
            //注意:此处返回option里的key值才能正常加载options方法中返回的内容!!此处的字符串主要是显示在前端hidden元素中, 用于表单提交参数用的,所以必须返回。
        })
        ->options() {
            return [1 => '选项A', 2 => '选项B', 3 => '选项C']; 
            //需要加载时显示的选项,key与上面value()中的值对应,如果value中不存在options()中的某个key,则该key对应的选项不会显示出来。
        }
    }
    return [];
});

底层SelectTable处理option的主要逻辑:

iptables add IP and del IP

在Linux下,使用iptables来维护IP规则表。要封停或者是解封IP,其实就是在IP规则表添加规则。

要禁止指定IP地址的网络连接,可以使用以下两种方法来快速实现。

1.禁止特定IP的连接
要禁止一个IP,使用下面这条命令:

iptables -I INPUT -s ***.***.***.*** -j DROP

要解封一个IP,使用下面这条命令:

iptables -D INPUT -s ***.***.***.*** -j DROP

参数:
-I是表示 Insert (添加)
-D表示 Delete (删除)
后面跟的是规则, INPUT 表示入站,***.***.***.*** 表示要封停的IP, DROP 表示放弃连接。

查看:

iptables -L -n

Mac iTerm2 设置代理

1.前提已经有socks5的翻墙代理
2.安装:

brew install privoxy

3.配置

listen-address 127.0.0.1:8087  #转换http代理后的监听的端口
forward-socks5 / 127.0.0.1:1080 . #需要转换http代理的socks5代理

forward 192.168.*.*/ .
forward 10.*.*.*/ .
forward 127.*.*.*/

4.启动

privoxy /usr/local/etc/privoxy/config

lsof -i:8087 #查看端口是否启动

#设置环境变量后,当前终端页即可使用代理
export http_proxy=http://127.0.0.1:8087
export https_proxy=$http_proxy

#删除环境变量
unset http_proxy https_proxy

vim

,e = open file (like the original :e) but with recursive and fuzzy file name matching. Example: if you type “mopy” it will find a file named “models.py” placed on a subdirectory. And allows you to open the selected file on a new tab with Ctrl-t!
,g = fuzzy symbol finder (classes, methods, variables, functions, …) on the current file. Example: if you type “usr” it will find the User class definition on the current file. ,G does the same but on all opened files.

tn or Ctrl-Shift-Right = next tab.
tp or Ctrl-Shift-Left = previous tab.

Ctrl+w+方向键——切换到前/下/上/后一个窗格
Ctrl+w+h/j/k/l ——同上
Ctrl+ww——依次向后切换到下一个窗格中

wordpress 更换域名

wordpress 更换域名

UPDATE wp_options SET option_value = replace(option_value, 'www.mydomain.com','www.newdomain.com') ;
UPDATE wp_posts SET post_content = replace(post_content, 'www.mydomain.com','www.newdomain.com') ;
UPDATE wp_comments SET comment_content = replace(comment_content, 'www.mydomain.com', 'www.newdomain.com') ;
UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'www.mydomain.com', 'www.newdomain.com') ;

How to fix: MySQL not starting on MAMP (Pro)

How to fix: MySQL not starting on MAMP (Pro)
I recently had to install MAMP Pro, in order to do some separate work from my Laravel Homestead VM.

After a weird Mac crash, MAMP would no longer start the MySQL server. This was the data from the logs:

To fix this, go to MAMP, File > Edit Template > MySQL > [version] and add the line highlighted below.

# The MySQL server
[mysqld]
innodb_force_recovery = 1

The restart the server. After this you can comment out that line. Hopefully you will now be able to run the server again.

Source:http://blog.ign.uy/2017/how-to-fix-mysql-not-starting-on-mamp-pro

如何解决 fatal: cannot exec ‘git-br’: Permission denied

不知道谁动了环境变量导致git alias无效

#找到git执行程序所在的目录
$ which git
/usr/bin/git

#查看一下当前的环境变量,的确没有/user/bin
$ echo $PATH
/home/magic/.composer/vendor/bin/:/usr/local/webserver/php/bin:/usr/local/node/bin:/usr/local/webserver/mysql/bin:/usr/local/mongodb/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/ffmpeg:/usr/local/go/bin:/gocode/bin:/home/magic/bin

#添加/user/bin进环境变量
$ PATH="$PATH:/usr/bin"
$ echo $PATH
/home/magic/.composer/vendor/bin/:/usr/local/webserver/php/bin:/usr/local/node/bin:/usr/local/webserver/mysql/bin:/usr/local/mongodb/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/ffmpeg:/usr/local/go/bin:/gocode/bin:/home/magic/bin:/usr/bin

成功解决 fatal: cannot exec ‘git-br’: Permission denied

隐藏http头里的X-Powered-By php版本号

1.找到php.ini

$ php -i | grep "Loaded Configuration File"
Loaded Configuration File => /usr/local/php/etc/php.ini
$ vim /usr/local/php/etc/php.ini

2.修改 expose_php 将 On 改成 Off
3.重启php
4.打开浏览器检测,顺便用lynx在命令行中看下

$ lynx -head -mime_header http://localhost 
或者
$ lynx -head -mime_header http://server-address