/// <summary>
/// 获取最后一天
/// </summary>
/// <returns>当月最后一天日期</returns>
public static DateTime GetMonthLastDay(DateTime date)
{
return date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1);
}
月度归档: 2019年7月
C# .NET 获取日期是第几周
/// <summary>
/// 获取日期是第几周
/// </summary>
/// <param name="date">日期</param>
/// <returns>第几周</returns>
public static int GetWeekOfYear(DateTime date)
{
//确定此时间在一年中的位置
int dayOfYear = date.DayOfYear;
//当年第一天
DateTime tempDate = new DateTime(date.Year, 1, 1);
//确定当年第一天
int tempDayOfWeek = (int)tempDate.DayOfWeek;
tempDayOfWeek = tempDayOfWeek == 0 ? 7 : tempDayOfWeek;
//确定星期几
int index = (int)date.DayOfWeek;
index = index == 0 ? 7 : index;
//当前周的范围
DateTime retStartDay = date.AddDays(-(index - 1));
DateTime retEndDay = date.AddDays(7 - index);
//确定当前是第几周
int weekOfYear = (int)Math.Ceiling(((double)dayOfYear + tempDayOfWeek - 1) / 7);
if (retStartDay.Year < retEndDay.Year)
{
weekOfYear = 1;
}
return weekOfYear;
}
WordPress 5.x自定义上传路径 和 生成文件的URL地址
WordPress 3.5以上的版本,隐藏了后台的媒体(Media)设置页面 上传路径(upload_path)和文件 URL 地址(upload_url_path)的设定。
将下面的代码添加到主题的 functions.php 即可恢复设置界面:
if(get_option('upload_path')=='wp-content/uploads' || get_option('upload_path')==null) {
update_option('upload_path',WP_CONTENT_DIR.'/uploads');
}
CentOS 7 安装 p11-kit 0.23.16
CentOS 7 源码安装 p11-kit,解决 configure: error: p11-kit >= 0.23.1 was not found. To disable PKCS #11 support
错误。
1、下载并解压
wget https://github.com/p11-glue/p11-kit/releases/download/0.23.16/p11-kit-0.23.16.tar.gz
tar -zxvf p11-kit-0.23.16.tar.gz
cd p11-kit-0.23.16
备用下载地址: https://down.24kplus.com/linux/p11-kit-0.23.16.tar.gz
2、编译安装
./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/p11-kit \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/p11-kit
make
make install
如果出现 configure: error: libtasn1 not found. Building without it results in significant loss of functionality. To proceed use --without-libtasn1
错误,执行:
yum install -y libtasn1-devel
如果出现 configure: error: Package requirements (libffi >= 3.0.0) were not met: No package 'libffi' found
错误,执行:
yum install -y libffi-devel
CentOS 7 安装 libidn2 最新版
CentOS 7 源码安装 libidn2 最新版,解决 error while loading shared libraries: libidn2.so.4: cannot open shared object file: No such file or directory
错误
1、下载并解压
wget https://ftp.gnu.org/gnu/libidn/libidn2-latest.tar.gz
tar -zxvf libidn2-latest.tar.gz
cd libidn2*
2、编译安装
./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/libidn2 \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/libidn2 \
--with-packager \
--with-packager-version \
--with-packager-bug-reports
make
make install
CentOS 7 安装 openpts 0.2.6
CentOS 7 源码安装 openpts 0.2.6。
1、下载并解压
wget https://mirrors.xtom.com/osdn/openpts/54410/openpts-0.2.6.tar.gz
tar -zxvf openpts-0.2.6.tar.gz
cd openpts-0.2.6
备用下载地址:https://down.24kplus.com/linux/openpts-0.2.6.tar.gz
2、编译安装
./bootstrap.sh
./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/openpts \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/openpts \
--with-tss \
--with-aru \
--enable-tnc
make
make install
如果出现 /include/openpts.h:50:17: fatal error: tss.h: No such file or directory
错误,安装:
yum install trousers-devel
如果出现 fatal error: uuid.h: No such file or directory
错误,安装:
yum install e2fsprogs-devel uuid-devel libuuid-devel
CentOS 7 安装 tpm-tools
CentOS 7 源码安装 tpm-tools 1.3.9.1
1、下载并解压
mkdir tpm-tools
cd tpm-tools
wget https://nchc.dl.sourceforge.net/project/trousers/tpm-tools/1.3.9.1/tpm-tools-1.3.9.1.tar.gz
tar -zxvf tpm-tools-1.3.9.1.tar.gz
备用下载地址:https://down.24kplus.com/linux/tpm-tools-1.3.9.1.tar.gz
2、编译安装
./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/tpm-tools \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/tpm-tools
make
make install
如果出现 configure: error: tss lib not found: libtspi.so
错误:
yum install trousers-devel
如果出现 configure: error: openssl lib not found: libcrypto.so
错误:
yum install openssl-devel
C# .NET 输出格式化的 Xml
默认输出的 InnerXml 显示在一行,看起来非常痛苦,特别是复杂XML文档,输出格式化后的 InnerXml 可以方便快速的查看。
public string GetFormattedInnerXml(XmlDocument doc)
{
StringBuilder builder = new StringBuilder();
using (StringWriter sw = new StringWriter(builder))
{
using (XmlTextWriter xtw = new XmlTextWriter(sw))
{
xtw.Formatting = Formatting.Indented;
xtw.Indentation = 1;
xtw.IndentChar = '\t';
doc.WriteTo(xtw);
}
}
return builder.ToString();
}
解决 WordPress imagick 未安装警告
解决 WordPress 5.x 站点健康( Site Health )检查提示 The optional module, imagick, is not installed, or has been disabled.
问题。
输入以下命令安装 imagick:
pecl install imagick
此时会提示 Please provide the prefix of ImageMagick installation [autodetect]
输入:
/usr
如果 php 是自行源码编译安装的请输入 php 安装目录,如:/usr/local
如果出现 configure: error: not found. Please provide a path to MagickWand-config or Wand-config program
错误,执行:
yum install ImageMagick-devel
在php.ini文件中加入一行:
extension=imagick.so
重启 php-fpm 服务
systemctl restart php-fpm