Your gists

We’ve found 74 results

netnr / ToTimestamp.cs csharp
2018-11-03 10:13
将Datetime转换成时间戳,10位,秒
/// <summary>
/// 将Datetime转换成时间戳,10位,秒
/// </summary>
/// <param name="datetime"></param>
/// <returns></returns>
public static long ToTimestamp(this DateTime datetime)
{
    return (datetime.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
}
netnr / ToEncode-ToDecode.cs csharp
2018-11-03 10:12
编码、解码
/// <summary>
/// 编码
/// </summary>
/// <param name="uri"></param>
/// <param name="charset"></param>
/// <returns></returns>
public static string ToEncode(this string uri, string charset = "utf-8")
{
    string URL_ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
netnr / ToDataTable-ToModel.cs csharp
2018-11-03 10:06
实体转表、表转实体
/// <summary>
/// 实体转表
/// </summary>
/// <typeparam name="T">泛型</typeparam>
/// <param name="list">对象</param>
/// <returns></returns>
public static DataTable ToDataTable<T>(this IList<T> list)
{
    Type elementType = typeof(T);
    var t = new DataTable();
netnr / libgdiplus-mkfontscale shell
2018-10-20 09:56
Linux安装字体,asp.net core 验证码
# 安装字体
yum -y install fontconfig
cd /usr/share/fonts
# 创建新的字体文件夹
mkdir cfont
# 修改cfont目录的权限使root用户以外的用户也可以使用
chmod -R 755 /usr/share/fonts/cfont
# 拷贝字体到cfont文件夹
yum install mkfontscale
mkfontscale && mkfontdir
netnr / install-vsftpd shell
2018-10-20 06:22
安装 FTP
#检查是否安装(没任何反应)
chkconfig –list | grep vsftpd

#安装
yum install vsftpd

#创建日志
touch /var/log/vsftpd.log

#自启动
netnr / RequesToModel.cs csharp
2018-09-26 13:08
反射参数为实体
/// <summary>
/// 反射参数为实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="model"></param>
/// <param name="request"></param>
/// <returns></returns>
public static T RequesToModel<T>(this T model, HttpRequest request = null)
{
    if (request == null)
netnr / ToDataTable.cs csharp
2018-09-26 13:04
实体转表
/// <summary>
/// 实体转为表
/// </summary>
/// <typeparam name="T">泛型</typeparam>
/// <param name="list">对象</param>
/// <returns></returns>
public static DataTable ToDataTable<T>(this IList<T> list)
{
    Type elementType = typeof(T);
    var t = new DataTable();
netnr / OfJson.cs csharp
2018-09-26 13:03
JSON字符串转义
/// <summary>
/// 字符串 JSON转义
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string OfJson(this string s)
{
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.Length; i++)
    {
netnr / mysqldump shell
2018-09-21 15:40
mysql备份还原
#备份格式
mysqldump -u 账号 -p 数据库 > 路径

#备份库(表结构及数据)
mysqldump -u root -p netnrdb > /netnr/data/netnrdb.sql
mysqldump -uroot -p123456 netnrdb > /netnr/data/netnrdb.sql

#备份库(表结构)(加 -d 不含数据)
mysqldump -u root -p -d netnrdb > /netnr/data/netnrdb.sql
netnr / drop.sql sql
2018-09-21 14:18
SqlServer删除所有表
--删除所有表
DECLARE @sql VARCHAR(8000);
WHILE EXISTS (SELECT name FROM sysobjects WHERE type = 'U')
BEGIN
    SELECT @sql = 'DROP TABLE ' + name
    FROM sysobjects
    WHERE (type = 'U');

    PRINT (@sql);
ˆ