易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
simplepie解析爱范儿的RSS出错

simplepie解析爱范儿的RSS出错

用Simplepie解析爱范的源时,出现如下错误:http://www.ifanr.com/feed is invalid XML, likely due to invalid characters. XML error: Invalid character at line 604, column 37,比较麻烦。

最后在Simplepie的代码的1397行里加入:
$this->raw_data = preg_replace('/[^\P{C}\n]+/u','',$this->raw_data);
说实在的,这种不可见的字符最TMD恶心了!~
spotlight坏了。只能用alfred了

spotlight坏了。只能用alfred了

不知道为什么spotlight突然坏了。重建索引 也没用。现在连做个加法都不OK了。只能。。。。用alfred了!

快捷键设置成一样,感觉好多了。一个星期没法用,感觉效率都降低了很多!

其实以前在windows上,我用的是launchy。就特别觉得好用,然后到了mac后,用spotlight,虽然 很多人一直说alfred好用,但那时候在试用下来,感觉我要的功能其实spotlight一样。而且打开速度还是spotlight更快。。。。

只是这次,突然不能用了。所以。哎~~

jqweui 的 select/picker 控件添加清除

jqweui 的 select/picker 控件添加清除

jqweui是一个偷懒的基于Weui的组件,1.0的时候已经部分支持rem。所以用的还是比较多的。特别是我对它的部分组件有了一些扩展。而且它还有一些奇技淫巧。

1、如何通过函数来动态调整picker的内容。

默认情况下,picker/select在初始化的时候值已经固定了。这时候你其实是没有办法调整的,但不代表没有办法。虽然 API里没有提供,读了源码后你就能发现。其实你可以这样:

$('#xxx').val('').data('weui-select',false).select({
title: "其他值",
items: ["1","2"]
});

记得有一个恶心的地方,items里的值不能是数字!!!

2、添加清除功能,默认的select/picker在选择后就不能清除了(当然你可以在items的第一个值设置为空)。所以我简单的扩展了一下:https://github.com/lihongxun945/jquery-weui/issues/443。

无非就是加个文字,加个清除等等。。

3、picker/select在使用的时候,有时候会显示一个软键盘而无法删除和隐藏。这时候的解决办法其实就是在input上面加上onfocus="this.blur()"即可!

Yii2 PJAX的URL,微信签名错误

Yii2 PJAX的URL,微信签名错误

因为用了pjax,所以URL在请求的时候都是被自动加了?pjax-container=xxxxx,但请求完pjax后,location的pushState又会去掉这个pjax-container。所以要解决签名问题,其实就是在签名的时候把pjax-container去掉

因此jssdk()->config(xxx)的时候,先在前面加入jssdk()->setUrl(Url::to([''],true))->config('')...问题解决!

就是这么简单!

redis 127.0.0.1和localhost的性能区别

redis 127.0.0.1和localhost的性能区别

不多说上图

[2017-10-13 08:52:28]{"router":"site/test","process_time":1.05578303337,"include_files":110}
[2017-10-13 08:52:29]{"router":"site/test","process_time":1.65018391609,"include_files":110}
[2017-10-13 08:52:30]{"router":"site/test","process_time":2.24326276779,"include_files":110}
[2017-10-13 08:52:31]{"router":"site/test","process_time":2.83484601974,"include_files":110}
[2017-10-13 08:52:32]{"router":"site/test","process_time":3.45267605782,"include_files":110}
[2017-10-13 08:52:43]{"router":"site/test","process_time":0.045606136322,"include_files":110}
[2017-10-13 08:52:43]{"router":"site/test","process_time":0.0466020107269,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0419600009918,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0458340644836,"include_files":110}
[2017-10-13 08:52:44]{"router":"site/test","process_time":0.0436880588531,"include_files":110}
因为在框架里面,所以include_files就这么多(没办法,没开始opcache)
前5条是用的localhost后5条是127.0.0.1,瞅瞅,就是这样的区别!
mariadb 用navicat查看 乱码

mariadb 用navicat查看 乱码

navicat是个好软件,mariadb也是,不过,默认的mariadb在查看的时候可能会是乱码(特别是debian 9,默认没有mysql,只有mariadb了)

1、进入console,如果set names utf8,然后select能够看到正常的数据,这证明几件事,client有问题,字符串不对
2、如果是1所说的问题。那么修改my.cnf,修改[mysqld] [mysql] [client]中的数据
[mysqld]下增加character-set-server=utf8
[client]下增加default-character-set=utf8
[mysql] 下增加default-character-set=utf8
如果还是无效。。则尝试在mysqld下再增加:
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
参考 :http://blog.csdn.net/fzq1988215/article/details/48808001
dcloud更新失败的可能原因

dcloud更新失败的可能原因

dcloud更新失败有几个原因:

1、manifest.json在打包的时候不对
2、checkversion的时候用数字和字符串比较
3、版本小于当前版本,但判断的时候没判断好
4、wgt文件不是zip压缩的
5、网络原因,没下载好文件
基于以上几个原因。除了网络原因。其他可以一试(下次我试一下直接打包成zip,然后改名成wgt试一下看看)
将原数据库从latin1改为utf8

将原数据库从latin1改为utf8

原来的数据库是N年前的,默认字符集是latin1,但是有一些旧代码中,连接参数写的是UTF8,于是就这样。。。DB字符集为latin1,连接UTF8,存到数据库也是UTF8,wj但查看的时候显示是???

为了标准统一,于是使用mysqldump -uxx -p database a b c d e > dump.sql,将部分表先导出来

然后修改导出sql的charset=latin1;改为charset=utf8;

至此,操作完成。简单粗暴

-------EOF--

deeka说,如果有200G呢。目前我是停机处理的。因为要处理的数据也不是很多。如果不是因为升级换库的时候出现不能访问我也不会这么做。

但好象也没有特别好的方案。因为直接alter的时候也是各种不正常。才dump的

New user help: columns vs. columnDefs for client side rendering of AJAX data

New user help: columns vs. columnDefs for client side rendering of AJAX data

说实话,在datatables里,我觉得这个回复挺重要的!https://datatables.net/forums/discussion/33723/new-user-help-columns-vs-columndefs-for-client-side-rendering-of-ajax-data

提问:
Hi,

I'm a beginner with DataTables. I'm trying to use DataTables AJAX to pull records from the server (an ASP.NET MVC app.) Each record coming from the server has name, address line 1, address line 2, city, state, zip. I want my table to combine and format all those fields into one column on the client.

My questions are:
1. Would I use columns.render, or columnDefs.render?
2. Do I need both columns and columnDefs?
3. Do I need to specify either the table column name (e.g., NameAndAddress) in "columns", or do I need to list each field coming back from the server?
4. How do I use "targets"? Does "targets" refer to the column in the displayed table, or the column under "columns"?

Thanks for your help. I've been though the documentation a few times and I'm still confused about columns vs. columnDefs.
回答:

"columns" & "columnsDefs" ultimately serve the same purpose.

The differences being:

  1. "columns" requires you to provide a configuration or null for all columns. "columnDefs" requires you to only proved configuration for columns that have "special" configurations
  2. I have found "columns" best used if handling array of strings as your rows. I have found "columnDefs" best used if handling objects as your rows

"targets" takes a single string or int value, or array of previous two to denote which columns this configuration is for. I suggest using column class instead of column # in the event you want to use ColReorder extension.

Here are examples of how I have configured columns in my application.

HTML:
<th class="actionsCol no-print">Actions</th>
<th class="StatusCol">Status</th>
<th class="IsFinalCol">Final<br>Plan</th>
<th class="VrsnCol">Vrsn</th>
<th class="CutCntCol">Cut<br>Cnt</th>
<th class="CarCntCol">Car<br>Cnt</th>
JS关键代码:
"columnDefs": [
{
// This is for the Action column icons
"targets": 'actionsCol',
"sorting": false,
"orderable": false,
"type":"html",
"width": "8%",
className: "dt_nowrap_col no-print",
"render": function (data, type, row) {
return $.jqote(yv.templates.action_icons, data);
}
},
{
"targets": ['IsFinalCol','CutCntCol','CarCntCol','VrsnCol','StatusCol'],
"width": "5%"
},
etc
]
看到这些定义,估计你应该能够想得出如何更好的应用了吧?
----EOF---
其他参考 :
datatables的一些常用的玩意

datatables的一些常用的玩意

datatables现在也开始逐步用的多了。虽然用起来复杂了一点,但好歹还能减少一些开发量

1、语言包,这个就不用说了,直接找个中文语言包即可(就是有些用插件的要注意一下,还是多写)
2、表格居中居右,这些不太好控制 ,但可以在每个columns里定义一个:sClass,这时候你就想怎么样就行了。例
{data:"xxx",sClass:"text-right"}
然后你加一个样式.text-right{text-align:right}
轻轻松松
3、POST,默认datables的数据是用GET请求,如果你参数过多,会造成GET参数过长的问题,这时候就只能用POST了。只是用了POST,数据就没有缓存了(可以用cache自己处理,但是麻烦)
4、columns的render可以写自定义事件。能封装起来一起用是最好的,毕竟每个页面的每个表格的Render都有可能会复用,要是每个地方都写同一份就太累了
5、事件,这一块说容易 也容易 也麻烦也麻烦。还是根据实际情况吧。反正你只要 保持你在Render的时候将每行数据的主键写出来,到时候想怎么处理都OK