建表

CREATE TABLE [dbo].[ShortUrl](
    [Id] [,) NOT NULL,
    [LongUrl] [nvarchar]() NOT NULL,
    [BaseUri] [int] NOT NULL,
    [ShortToken] [nvarchar]() NOT NULL,
    [Hits] [int] NOT NULL,
    [Creator] [nvarchar]() NULL,
    [CreateTime] [datetime] NOT NULL,
    [LastUpdateTime] [datetime] NULL,
    [LastOperator] [nvarchar]() NULL,
    [Enable] [bit] NOT NULL,
    [IsDelete] [bit] NOT NULL
) ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'长链地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'LongUrl'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短链域名对应数值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'BaseUri'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短链末尾编码串' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'ShortToken'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'url点击量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'Hits'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'Creator'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最近更新时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'LastUpdateTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新操作人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'LastOperator'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'Enable'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrl', @level2type=N'COLUMN',@level2name=N'IsDelete'
GO

ALTER TABLE [dbo].[ShortUrl] ADD  CONSTRAINT [DF_ShortUrl_IsDelete]  DEFAULT (()) FOR [IsDelete]
GO
CREATE TABLE [dbo].[ShortUrlStat](
    [Id] [,) NOT NULL,
    [UrlId] [int] NOT NULL,
    [ShortUrl] [nvarchar]() NOT NULL,
    [UrlRefferer] [nvarchar]() NOT NULL,
    [UserAgent] [nvarchar]() NOT NULL,
    [UserHostAddress] [nvarchar]() NOT NULL,
    [UserLanguage] [nvarchar]() NOT NULL,
    [Browser] [nvarchar]() NOT NULL,
    [MajorVersion] [int] NOT NULL,
    [IsMobile] [bit] NOT NULL,
    [CreateTime] [datetime] NOT NULL
) ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态记录所对应的长链的id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'UrlId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短链地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'ShortUrl'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取Url链接当前客户端的主机部分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'UrlRefferer'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取客户端完整的用户代理字符串' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'UserAgent'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取客户端ip的主机地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'UserHostAddress'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取客户端语言首选项' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'UserLanguage'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取浏览器请求标头中发送的浏览器字符串' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'Browser'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取浏览器主版本号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'MajorVersion'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'获取浏览器是否已标识为移动设备' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'IsMobile'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ShortUrlStat', @level2type=N'COLUMN',@level2name=N'CreateTime'
GO
@model IEnumerable<ShortUrl.ShortUrlModels>
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
<a href="@Url.Action("AddDetail", "ShortUrl")">新增</a>
@if (Model != null && Model.Any())
{
    <table>
        <thead>
            <tr>
                <th style="text-align: center">
                    序号
                </th>
                <th style="text-align: center">短链</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@item.Id</td>
                    <td><a href="@Url.Action("ReirectToken", "ShortUrl", new { id =item.Id})" target="_blank">@item.BaseShortUrl</a></td>
                </tr>
            }
        </tbody>
    </table>
}
@using ShortUrl
@model ShortUrl.ShortUrlModels
@{
    ViewBag.Title = "AddShortUrl";
}
<script src=.min.js")"></script>
<h2>AddShortUrl</h2>

<table style="width: 99%; margin: 5px auto;">
    <tbody>
    <tr>
        <td>长链</td>
        <td>
            <input type="text" value="@Model.LongUrl" id="longurl"/>
        </td>
    </tr>
    <tr>
        <td>短网址后缀</td>
        <td>
            @Html.DropDownListFor(m => m.BaseUri, new KvSelectList(Model.ShortUrl))
        </td>
    </tr>
    <tr>
        <td>
            <input type="button" value="保存" class="sBtn" id="btnSave" style="margin-left: 45%"/>
        </td>
    </tr>
    </tbody>
</table>

<script type="text/javascript">
    function necessaryinput() {
        //if ($("#longurl").val() == '' || $("#longurl").val() == undefined || $("#longurl").val().match(/(http[s]?|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/) == null) {
        //    alert("请输入合法的长链地址");
        //    return false;
        //}
        if ($("#longurl").val() == '' || $("#longurl").val() == undefined) {
            alert("请输入长链地址");
            return false;
        }
        return true;
    }
    var model = {};
    $("#btnSave").click(function () {
        model.LongUrl = $.trim($("#longurl").val());
        model.BaseUri = $.trim($("#BaseUri").val());

        if (confirm("你确定保存吗?")) {
            if (necessaryinput()) {
                $.ajax({
                    url: '@Url.Action("Add", "ShortUrl")',
                    type: 'post',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(model),
                    success: function (result) {
                        if (result.DoFlag) {
                            alert(result.DoResult);
                            window.location.href = '@Url.Action("Index", "ShortUrl")';
                        } else {
                            alert(result.DoResult);
                        }
                    }
                });
            }
        }

    })
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using ShortUrl.Models;
using ShortUrlDbEntity;
using ShortUrlUtility;

namespace ShortUrl.Controllers
{
    public class ShortUrlController : Controller
    {
        //
        // GET: /ShortUrl/
        MVCDemoEntities db = new MVCDemoEntities();
        public ActionResult Index()
        {
            List<ShortUrlModels> shortUrlList = new List<ShortUrlModels>();
            shortUrlList.AddRange(db.ShortUrl.OrderByDescending(x => x.Hits).ThenByDescending(x => x.LastUpdateTime).Select(t => new ShortUrlModels()
            {
                Id=t.Id,
                LongUrl = t.LongUrl,
                BaseUri = t.BaseUri,
                ShortToken = t.ShortToken,
                Hits = t.Hits,
                CreateTime = t.CreateTime,

            }));
            return View(shortUrlList);
        }

        //短链跳转
        public ActionResult ReirectToken(int id)
        {
            )
                return RedirectToAction("UrlNotFound", "ShortUrl");
            else
            {
                var shortUrlRecord = db.ShortUrl.FirstOrDefault(t => t.Id == id);
                if (shortUrlRecord == null)
                    return RedirectToAction("UrlNotFound", "ShortUrl");
                else
                {
                    ShortUrlModels shortUrlModel = new ShortUrlModels();
                    shortUrlModel = Mapper.GetMapper.Map<ShortUrlDbEntity.ShortUrl, ShortUrlModels>(shortUrlRecord);

                    ShortUrlStatModels stats = new ShortUrlStatModels(Request);
                    stats.UrlId = id;
                    stats.ShortUrl = shortUrlModel.BaseShortUrl;
                    stats.CreateTime = DateTime.Now;
                    var dbstats = Mapper.GetMapper.Map<ShortUrlStatModels, ShortUrlStat>(stats);
                    db.ShortUrlStat.Add(dbstats);
                    db.SaveChanges();
                    shortUrlRecord.Hits++;
                    shortUrlRecord.LastUpdateTime = DateTime.Now;
                    db.SaveChanges();

                    return Redirect(shortUrlModel.LongUrl);
                }
            }
        }

        public ActionResult UrlNotFound()
        {
            return View();
        }

        public ActionResult AddDetail(ShortUrlModels model)
        {
            ShortUrlModels shortmodels=new ShortUrlModels();
            return View("AddDetail", shortmodels);
        }

        //添加url model.LongUrl = HttpUtility.UrlDecode(model.LongUrl) ?? "";
 public JsonResult Add(ShortUrlModels model) { try {            
                if (string.IsNullOrEmpty(model.LongUrl))
                    return Json(new { DoResult = "请输入Url地址" }, JsonRequestBehavior.AllowGet);
                else
                {
                    if (CheckLongUrlExists(model.LongUrl))
                    {
                        if (!HasHttPProtocol(model.LongUrl))
                            model.LongUrl = "http://" + model.LongUrl;

                        var existingUrl = db.ShortUrl.FirstOrDefault(u => Equals(u.LongUrl.ToLower(), model.LongUrl.ToLower()));
                        if (existingUrl == null)
                        {
                            ShortUrlModels shortUrl = new ShortUrlModels()
                            {
                                LongUrl = model.LongUrl,
                                BaseUri = model.BaseUri,
                                Hits = ,
                                CreateTime = DateTime.Now,
                                LastUpdateTime = DateTime.Now,
                                Enable = true,
                                //ShortToken = GenerateRandomShortUrl()
                                //ShortToken = GenerateRandomString(6)
                                ShortToken = Guid.NewGuid().ToString().Substring(, )
                            };

                            var shortUrlDb = Mapper.GetMapper.Map<ShortUrlModels, ShortUrlDbEntity.ShortUrl>(shortUrl);
                            db.ShortUrl.Add(shortUrlDb);
                            db.SaveChanges();
                            var result = new {DoResult = "新增成功", DoFlag = true};
                            return Json(result, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            var result = new {DoResult = "新增失败,Url已被添加过", DoFlag = false};
                            return Json(result, JsonRequestBehavior.AllowGet);
                        }
                    }
                    else
                    {
                        var result = new { DoResult = "Url地址不存在或已失效,请填写正确的地址", DoFlag = false };
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }

                }
            }
            catch (Exception ex)
            {
                return Json(new { DoResult = "新增异常", DoFlag = false }, JsonRequestBehavior.AllowGet);
            }
        }

        //校验url开头带不带http
        private bool HasHttPProtocol(string url)
        {
            url = url.ToLower();
            )
            {
                if (url.StartsWith(Constants.Protocol.HTTP) || url.StartsWith(Constants.Protocol.HTTPS))
                    return true;
                else
                    return false;
            }
            else
                return false;
        }

        //生成随机的6位串
        public string GenerateRandomShortUrl()
        {
            string number = "";
            int j;
            Random random = new Random();

            ; i < ; i++)
            {
                j = random.Next(, );
                )
                    j += ;
                else
                    j += ;
                number = number + char.ConvertFromUtf32(j);
            }
            return number;
        }

        //生成随机的串(方法二)
        )
        {
            string rand = string.Empty;
            while (rand.Length < len)
            {
                rand += GetCleanRandString();
            }
            , len);
        }
        private static string GetCleanRandString()
        {
            ', '.' };
            return string.Join(string.Empty, System.IO.Path.GetRandomFileName().ToLower().Split(AmbiguousChars));
        }

        //removed 'I', 'l', '1', 'O' and '0'
        const string chars = "23456789abcdefghjkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
        private readonly int theBase = chars.Length;
        public string Encode(int value)
        {
            var hash = "";
            )
            {
                var remainder = value % theBase;
                hash += chars[remainder];
                value = value / theBase;
            }
            hash += chars[value];
            return hash;
        }

        public int Decode(string hash)
        {
            ;
            ; i >= ; i--)
            {
                result += (chars.IndexOf(hash[i]) * (int)(Math.Pow(theBase, i)));
            }
            return result;
        }

        //检测url有没有过期
        public bool CheckLongUrlExists(string url)
        {

            if (!HasHttPProtocol(url))
                url = Constants.Protocol.HTTP + url;
            try
            {
                //Creating the HttpWebRequest
                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                //Setting the Request method HEAD, you can also use GET too.
                request.Method = "HEAD";
                //Getting the Web Response.
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                //Returns TRUE if the Status code == 200
                return (response.StatusCode == HttpStatusCode.OK);
            }
            catch
            {
                return false;
            }
        }

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ShortUrl
{

    public class ShortUrlModels
    {
        public int Id { get; set; }
        public string LongUrl { get; set; }
        public int BaseUri { get; set; }
        public string ShortToken { get; set; }
        public int Hits { get; set; }
        public string Creator { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime LastUpdateTime { get; set; }
        public string LastOperator { get; set; }
        public bool Enable { get; set; }
        public bool IsDelete { get; set; }

        private Dictionary<int, string> _shortUrl;
        public Dictionary<int, string> ShortUrl {
            get
            {
                _shortUrl= new Dictionary<int, string>()
                {
                    {,"t.cn"},
                    {,"dwz.cn"},
                    {,"qq.cn.hn"},
                    {,"jd.cn.hn"},
                    {,"tb.cn.hn"},
                    {,"sina.lt"},
                    {,"tinyurl.com"},
                    {,"qr.net"},
                    {,"goo.gl"},
                    {,"is.gd"},
                    {,"j.mp"},
                    {,"bit.ly"}
                };
                return _shortUrl;
            }
            set { _shortUrl = value; }
        }

        public string BaseShortUrl
        {
            get { return "http://" + ShortUrl[BaseUri]+"/"+ShortToken; }
        }

    }

}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ShortUrl.Models
{
    public class ShortUrlStatModels
    {
        public int Id { get; set; }
        //短链的Id
        public int UrlId { get; set; }
        //短链地址
        public string ShortUrl { get; set; }
        //获取Url链接当前客户端的主机部分
        public string UrlRefferer { get; set; }
        //获取客户端完整的用户代理字符串
        public string UserAgent { get; set; }
        //获取客户端ip的主机地址
        public string UserHostAddress { get; set; }
        //获取客户端语言首选项
        public string UserLanguage { get; set; }
        //获取浏览器请求标头中发送的浏览器字符串
        public string Browser { get; set; }
        //获取浏览器主版本号
        public int MajorVersion { get; set; }
        //获取浏览器是否已标识为移动设备
        public bool IsMobile { get; set; }
        //创建时间
        public DateTime CreateTime { get; set; }

        public ShortUrlStatModels(HttpRequestBase request)
        {
            if (string.IsNullOrEmpty(request.UrlReferrer.Host))
                UrlRefferer = Constants.UNKNOWN;
            else
                UrlRefferer = request.UrlReferrer.Host;

            if (string.IsNullOrEmpty(request.UserAgent))
                UserAgent = Constants.UNKNOWN;
            else
                UserAgent = request.UserAgent;

            if (string.IsNullOrEmpty(request.UserHostAddress))
                UserHostAddress = Constants.UNKNOWN;
            else
                UserHostAddress = request.UserHostAddress;

            ]))
                UserLanguage = Constants.UNKNOWN;
            else
                UserLanguage = request.UserLanguages[];

            if (string.IsNullOrEmpty(request.Browser.Browser))
                Browser = Constants.UNKNOWN;
            else
                Browser = request.Browser.Browser;

            MajorVersion = request.Browser.MajorVersion;
            IsMobile = request.Browser.IsMobileDevice;
        }
    }

}

生成随机串其它参考:

/// <summary>
    /// 短网址应用 ,例如QQ微博的url.cn   http://url.cn/2hytQx
    /// </summary>
    /// <param name="url"></param>
    /// <returns></returns>
    public static string[] ShortUrl(string url)
    {
        //可以自定义生成MD5加密字符传前的混合KEY
        string key = "fooo_2016";
        //要使用生成URL的字符
        string[] chars = new string[]{
        "a","b","c","d","e","f","g","h" ,"i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
        ",
        "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T" ,"U","V","W","X","Y","Z"
        };

        //对传入网址进行MD5加密
        string hex = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(key + url, "md5");
        ];
        ; i < ; i++)
        {
            //把加密字符按照8位一组16进制与0x3FFFFFFF进行位与运算
            , ), );
            string outChars = string.Empty;
            ; j < ; j++)
            {
                //把得到的值与0x0000003D进行位与运算,取得字符数组chars索引
                int index = 0x0000003D & hexint;
                //把取得的字符相加
                outChars += chars[index];
                //每次循环按位右移5位
                hexint = hexint >> ;
            }
            //把字符串存入对应索引的输出数组
            resUrl[i] = outChars;
        }
        return resUrl;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string[] Shor = ShortUrl(this.TextBox1.Text);

        // Response.Write( );  //得到值fAVfui
        //ShortUrl(http://www.jb51.net)[1];  //得到值3ayQry
        //ShortUrl(http://www.jb51.net)[2];  //得到值UZzyUr
        //ShortUrl(http://www.jb51.net)[3];  //得到值36rQZn

        ; i < Shor.Length; i++)
        {
            Response.Write("<br/>" + i + ">>" + Shor[i]);
        }
    }

生成短链(网址) ShortUrlLink的更多相关文章

  1. php生成短网址的思路与方法

    生成短网址的思路以及使用php生成短网址的实现方法. 生成短网址的思路:如果把短网址还原了,你知道是个什么样子的吗?比如:http://www.jbxue.com/sitejs-17300-1.htm ...

  2. C#:生成短网址

    /// <summary> /// 短网址应用 ,例如QQ微博的url.cn http://url.cn/2hytQx /// </summary> /// <param ...

  3. 仿微博php生成短网址

    html code <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  4. PHP 自动生成导航网址的最佳方法 v20130826

    经常制作开发不同的网站的后台,写过很多种不同的后台导航写法. 最终积累了这种最写法,算是最好的吧.附上截图和代码如下(PHP+HTML) <?php $linkArr = array( 'ind ...

  5. 动态生成WebService的客户端

    给定了WebService地址和调用接口后动态的生成DLL,第二次再请求时会先判断DLL是否存在,以提高执行效率 核心代码下: /// <summary> /// 动态生成WebServi ...

  6. PHP 生成PDF

    一个项目中需要用到网页生成PDF,就是将整个网页生成一个PDF文件, 以前也用过HTML2PDF,只能生成一些简单的HTML代码,复杂的HTML + css 生成的效果惨不忍睹, 百度了一下,发现有个 ...

  7. mongodb:短网址项目

    短网址项目概述 1.短网址项目,是将给定的长网址,转换成短网址. 如 新浪 http://t.cn/zQd5NPw ,其中zQd5NPw就是短网址 前段页面如下

  8. C#如何实现url短地址?C#短网址压缩算法与短网址原理入门

    c# url短地址压缩算法与短网址原理的例子,详细介绍了短网址的映射算法,将长网址md5生成32位签名串,分为4段,每段8个字节,然后生成短网址,具体见文本实例. 短网址映射算法: 将长网址md5生成 ...

  9. Vagrant 基础全面解析

    这篇 Vagrant 入门文章将带你创建一个 Vagrant 项目,这个过程将会用到 Vagrant 所提供的主要基本特性.如果想了解 Vagrant 能为你带来哪些好处,可以阅读 Vagrant 官 ...

随机推荐

  1. ★Kali信息收集~ 5.The Harvester:邮箱挖掘器

    官网:http://www.edge-security.com 安装:apt-get install theHarvester 运行:终端输入 theharvester (小写) 用法+参数:(返回邮 ...

  2. Shuffling Machine和双向链表

    1. 双向链表 https://github.com/BodhiXing/Data_Structure 2. Shuffling Machine https://pta.patest.cn/pta/t ...

  3. 基于AQS的锁

    锁分为独占锁和共享锁,它们的主要实现都是依靠AbstractQueuedSynchronizer,这个类只提供一系列公共的方法,让子类来调用.基于我了解不深,从这个类的属性,方法,和独占锁的获取方式去 ...

  4. C语言中的回调函数(Callback Function)

    1 定义和使用场合 回调函数是指 使用者自己定义一个函数,实现这个函数的程序内容,然后把这个函数(入口地址)作为参数传入别人(或系统)的函数中,由别人(或系统)的函数在运行时来调用的函数.函数是你实现 ...

  5. GitHub for Windows 2.0使用教程

    Git是目前最先进的分布式版本控制系统,作为一个程序员,我们需要掌握其用法. 一:下载GitHub for Windows 2.0 二:安装GitHub  下载之后点击进行安装过程,安装之后桌面上会有 ...

  6. yii2 如何在页面底部加载css和js

    作者:白狼 出处:www.manks.top/article/yii2_load_js_css_in_end 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接 ...

  7. Aspect Oriented Programming (AOP)

    切面”指的是那些在你写的代码中在项目的不同部分且有相同共性的东西.它可能是你代码中处理异常.记录方法调用.时间处理.重新执行一些方法等等的一些特殊方式.如果你没有使用任何面向切面编程的类库来做这些事情 ...

  8. EasyUI中在表单提交之前进行验证

    使用EasyUi我们可以在客户端表单提交之前进行验证,过程如下:只需在onSubmit的时候使用return  $("#form1").form('validate')方法即可,E ...

  9. NOIP200406合并果子

    试题描述 在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆.多多决定把所有的果子合成一堆.    每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之 ...

  10. Oracle数据库--SQL

    1.事务(Transaction ) 1)命名事务 set transaction name ‘transaction_name ’; 2)查看事务是否存在 select name from v$tr ...