We’ve found 50 gist results

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 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);
netnr / truncate.sql sql
2018-09-21 14:16
truncate清空所有表,mysql数据库
--生成清理所有表语句;
SELECT CONCAT('truncate TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';')
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA IN ( '数据库名' );
netnr / Scaffold-DbContext shell
2018-09-21 11:37
dotnet ef core 生成实体
#公共的依赖
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

#MySQL
Install-Package Pomelo.EntityFrameworkCore.MySql
Scaffold-DbContext -Force "server=localhost;database=db;uid=root;pwd=123456;" Pomelo.EntityFrameworkCore.MySql

#SQLServer
Install-Package Microsoft.EntityFrameworkCore
netnr / install-mysql shell
2018-09-20 14:22
linux安装MySQL
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server

#初始化
mysqld --initialize

#设置权限
chown mysql:mysql -R /var/lib/mysql
netnr / sqlserver.sql sql
2018-09-19 07:23
SQLServer查询所有表总条数、占用空间
--定义表变量
DECLARE @T TABLE
(
	[name]           VARCHAR(max),
	[rows]           INT,
	reserved         VARCHAR(max),
	data_size        VARCHAR(max),
	index_size       VARCHAR(max),
	unused           VARCHAR(max)
)
ˆ