自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 资源 (9)
  • 问答 (1)
  • 收藏
  • 关注

原创 ASP.NET MVC中使用JS实现不对称加密密码传输

ASP.NET MVC中登录页面中点击登录后,用户名、密码将被明文传输到Controller中,使用Fiddler等工具可以轻松截获并获取密码, 这是不安全的。 使用对称加密,如AES,密钥将被暴露前端代码,也是不安全的。使用不对称加密能够较好解决这个问题。本文以RSA不对称加密的形式,在JS端通过公钥对密码进行加密,将密文传输到后端后通过密钥进行解密。

2017-07-14 05:25:44 4388 2

原创 ASP.NET HttpModule的使用说明

摘要:HttpModule可以用于全局身份验证、url重写、异常处理等场景。本文以身份验证为场景,介绍HttpModule的使用。 包括在IIS7.0及以后版本如何配置web.config文件才能使得HttpModule生效;

2017-05-18 02:17:03 703

原创 什么是CSRF攻击,如何在ASP.NET MVC网站中阻止这种攻击?

本文介绍什么是CSRF攻击,及如何在ASP.NET MVC网站应用程序中阻止CSRF攻击。

2017-05-12 02:28:13 1635

原创 使用存储过程和反射获取从多个数据表所需信息

本文介绍如何使用存储过程和读取范式化数据库获取所需信息的技术,使用到的技术有:存储过程,反射。 此技巧适用于与多处连表(大量JOIN)的场景。 对于单表操作,建议使用UnitOfWork+Repository的设计模式的EF操作方法,该方法并非本文描述重点。

2017-03-16 10:40:13 766

原创 算法-- 2分查找 Binary Search

思路:当数据量很大适宜采用该方法。采用二分法查找时,数据需是排好序的。主要思想是:(设查找的数组区间为array[low, high])(1)确定该区间的中间位置K(2)将查找的值T与array[k]比较。若相等,查找成功返回此位置;否则确定新的查找区域,继续二分查找。区域确定如下:a.array[k]>T 由数组的有序性可知array[k,k+1,……,high]>T

2017-02-26 01:41:02 293

原创 算法--动态规划篇

Dynamic Programming(动态规划)简介:1)需要辅助空间,记录子问题解决结果。2)明确各个子问题之间的关系,避免重复计算3)通常对数组和字符串的高难度面试题有效。与分治算法比较类似,但不同的是分治算法把原问题划归为几个相互独立的子问题,从而一一解决,而DP则是针对子问题有重叠的情况的一种解决方案。思路:利用recursive method

2017-02-22 08:56:01 364

原创 int MaxWindowTotal(int[] values, int windowSize)

原题:MaxWindowTotal will take an array of integers and a windowSize, and return the maximum total of any consecutive sequence of integers of length windowSize.For example, given (array =  [5, 12, 

2017-02-21 04:40:28 491

原创 JS 日期格式转换

后端DateTime类型JSON序列化以后,传到前端变成这样,怎么办?   "/Date(1485493200000)/"格式分析:这其实是1970 年 1 月 1 日至今的毫秒数;1391141532000/1000/60/60/24/365=44.11年,44+1970=2014年,按这种方法可以得出年月日时分秒和毫秒。这种格式是一种可行的表示形式但不是普通人可以看懂的友好格式,怎

2017-01-21 05:52:09 532

原创 算法--全排列、全子集、DFS\BFS问题

排列组合子集合 subset(medium)输入一个含有不同数字的序列,输出所有可能的集合(含空集)。要求1 集合里元素有序排列;2 输出结果不含有重复集合;举例:输入{1,2,3], 输出{},{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}原题:https://leetcode.com/problems/subsets/思路图:Amor

2017-01-18 11:18:53 2546 1

原创 算法-两根指针类问题

1 有序数组去重给出有序数组,就地移除重复元素,保证无重复,并返回新数组长度;举例:已知:A=[1,1,2,3,3]  输出长度3,  A=[1,2,3]思路图: public static int RemoveDuplicate(int[] arr) { if (arr == null || arr.Length ==

2017-01-16 07:06:29 647

原创 字符串String 算法题

1 字符判重 isUniqueChar(string str)要求:输入字符串,判断该串是否不含有重复字符需要确认问题:encoding是UTF-8还是ASCII码?思路:使用hashtable记录字符出现情况;如果已经存在,就说明有重复;如果是ASCII,使用256位数组即可;UTF8(万国码)编码的解释:http://baike.baidu.com/item/UTF

2017-01-06 09:03:13 674

原创 LinkedList 合并、环的长度、翻转等问题

LinkedList 总结

2017-01-01 08:20:16 2244

翻译 使用FluentSecurity加密ASP.NET MVC

本文总结如何使用FluentSecurity加密ASP.NET MVC

2016-11-18 11:11:18 422

原创 17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st

2016-10-23 00:33:08 294

原创 242. Valid Anagram

原题链接:https://leetcode.com/problems/valid-anagram/Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat

2016-10-19 09:56:00 252

原创 206. Reverse Linked List

原题:https://leetcode.com/problems/reverse-linked-list/内容:Reverse a singly linked list.A linked list can be reversed either iteratively or recursively. Could you implement both?总思路图:

2016-10-19 04:46:46 298

原创 204. Count Primes

题目:https://leetcode.com/problems/count-primes/题目要求:输出比一个非负数字N小的prime的个数;质数,百度百科:http://baike.baidu.com/view/10626.htm素数: 是只有两个正因子(1和自己)的自然数;最小的素数是2;合数: 比1大但不是素数的数称之为合数;0和1不是素数也不是合数;IsPrime

2016-10-17 06:18:48 204

原创 Leetcode 102 Binary Tree Level Order Traversal

题目:https://leetcode.com/problems/binary-tree-level-order-traversal/九章算法答案:http://www.jiuzhang.com/solutions/binary-tree-level-order-traversal/思路:Queue使用时要尽量避免Collection的add()和remove()方

2016-10-15 07:48:28 238

原创 Leetcode 155 Min Stack

链接:https://leetcode.com/problems/min-stack/题目要求:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stac

2016-10-14 10:39:38 313

原创 Leetcode Longest Substring Without Repeating Characters

原题:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters.Examples:Given "abca

2016-10-13 23:59:26 240

原创 Leetcode 21. Merge Two Sorted Lists

原题链接:https://leetcode.com/problems/merge-two-sorted-lists/思路:0  处理边界条件1  两个输入链表可能为空,采用dummy节点,使得dummy.next指向新链表的第一个节点。2  初始化时,使用两个指针指向两个链表的表头,两个指针同时不为空时,取较小的节点放入新链表的尾部。3  然后把链表

2016-10-13 10:16:05 238

原创 Leetcode 20. Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid bu

2016-10-12 06:28:12 194

原创 Leetcode 15 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain

2016-10-12 05:45:18 276

原创 Leetcode2 Add Two Numbers

原题链接:https://leetcode.com/problems/add-two-numbers/给出两个整数,每个整数由一个链表表示。其中链表每个节点保存数的数位,这些数位反序存在链表中,即高位在最后,低位在最前面。返回一个链表代表这两个数之和。举例,如图:思路:由于反序存储在链表中,可以从表头开始顺序相加;两个链表长度不同,如何相加链表而没有剩余

2016-10-10 23:47:29 220

原创 Leetcode 236. Lowest Common Ancestor of a Binary Tree

原题:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/题目大意:已知一个BT,找到BST中的节点p+q的最小公共祖先;例子:        _______3______       /              \    ___5__          ___1__   / 

2016-10-10 04:02:54 285

原创 Leetcode 235. Lowest Common Ancestor of a Binary Search Tree

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/题目大意:已知一个BST,找到BST中的节点p+q的最小公共祖先;思路:递归1 boundary conditions: tree, p, q任意为null, 返回null2 如果p.va, q.val均小于root.val ->

2016-10-10 03:24:30 230

原创 CC150 4.6 Successor

Successor: write an algorithm to find the "next" node(i.e. in-order successor) of a given node in a binary search tree. you may assume that each node has a link to its parent已知BST中的一个node, 写算法找到下一个节

2016-10-10 01:38:46 255

原创 Leetcode 98. Validate Binary Search Tree

https://leetcode.com/problems/validate-binary-search-tree/Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a

2016-10-09 11:37:02 275

原创 CC150 4.4 Check Balanced; Leetcode 110. Balanced Binary Tree

Leetcode link: https://leetcode.com/problems/balanced-binary-tree/Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined asa bin

2016-10-09 09:38:55 508

原创 CC150 Mimimal Tree 生成最小高度树

4.2 Minmal TreeGiven a sorted(increasing order ) array with unique integer elements write an algorithm to create a binary search tree with an algorithm to create a vinary search tree with minimal he

2016-10-09 06:39:36 689

原创 CC150 3.4 Queue via Stacks

queue via stacks: implement a my Queue class which implements a queue using 2 stacks.通过2个stack实现 MyQueue类public class MyQueue { Stack stackNew, stackOld; public MyQueue

2016-10-08 04:59:39 422

原创 CC150 3.1 Three in one: describe how you could use a single array to implement 3 stacks.

fixed Division思路:1 把数组等分;2 允许stack在其中增长;stack0 [0,n/3)stack1 [n/3,2n/3)stack2 [2n/3,n)class FixedMultiStack { int numberOfStacks = 3; int stackCapacity;

2016-10-06 05:08:48 435

原创 Leetcode 10. Regular Expression Matching

Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cov

2016-10-06 04:05:40 222

原创 "IQueryable and IEnumerable"区别

Answer: "IQueryable" 有延时加载机制;而且从数据库中筛选数据;IEnumerable 从数据库中选择所有的数据,在内存中做筛选var 默认等效于IEnumerable C#范例代码:class Program { static void Main(string[] args) { Lis

2016-10-04 07:21:34 304

原创 Leetcode 160. Intersection of Two Linked Lists/CC150 2.7

https://leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two lin

2016-10-04 03:34:14 310

原创 CC150 2.6/Leetcode Palindrome LinkedList

判断 Linked List是否属于回文思路:迭代法+快慢指针快指针是慢指针速度的两倍;1 while循环,fast到tail,slow只到一半;2 slow内容均迭代放入stack3 如果linkedlist元素个数是奇数(fast!=null), slow需要前移1 位4 然后对比stack 的顶元素与slow指针指向的内容;  不等-> 返回false; 相等

2016-10-03 22:45:25 344

原创 Last K elements in LinkedList(CC150 2.2)

https://www.hackerrank.com/contests/infinitum15/challenges/k-element-sequences实现一个算法,发现singly linked list中倒数第k个元素;思路1 如果已知linked list 长度length, kth个元素为(length-k); 通过这种方式可以找到这个元素;这种解法明显不是interv

2016-09-30 23:42:43 626

原创 CC150 2.8&&Linked List Cycle dection 判断循环LinkedList

https://leetcode.com/problems/linked-list-cycle/《进军硅谷》类似题目:环的长度题目:给出一个单向链表头指针,如果有环,判断环的长度,否则返回0;思路:1 判断链表是否有环。 使用快慢指针,如果快指针已经到尾部,而且他们没有相遇,则无环;如果他们相遇,则有环2 上图为例:慢指针:9->8->7->1;

2016-09-30 13:39:22 372

原创 CC150 1.7 ROTATE MATRIX 旋转矩阵

1.7 Rotate MatrixGiven an image represented by an N*N matrix, where each pixel(像素) in the image is 4 bytes, write a method to rotate te image by 90 degrees. Can you do this in place?思路1:1 分层

2016-09-30 00:28:28 453

原创 HackRank Stacks: Balanced Brackets;/Leetcode valid-parentheses; 括号匹配

A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs

2016-09-29 23:05:21 757

Jquery Ajax 跨域调用asmx类型 WebService范例代码

摘要:Ajax 在 Web 2.0 时代起着非常重要的作用,然而有时因为同源策略 (SOP)(俗称:跨域问题(cross domain)) 它的作用会受到限制。在本文中,将学习如何克服合作限制。本文以asmx方式搭建webservice作为测试用后端,给出完整的前后端调用解决方案、范例代码。 本资源为代码部分。 博文请见:http://blog.csdn.net/fanrong1985/article/details/51345436

2016-05-08

支持取消操作和暂停操作的Backgroundworker示例

Backgroundworker是默认支持取消功能的,但是默认不支持暂停。本文通过ManualResetEvent来实现一个暂停功能,并给出其相关的范例。

2014-11-08

SqlBulkCopy代码

摘要:使用.NET相关技术向数据库中插入海量数据是常用操作。本文对比ADO.NET和LINQ两种技术,分别使用SqlBulkCopy()和InsertAllOnSubmit()方法进行操作。得出结论:相同插入工作量(1w条数据)插入效率相差200倍之巨! 本文件给出了完整的测试代码和mssql数据库备份文件(bak格式)

2014-11-07

获取目标机器MAC地址、公网IP、所在城市信息

通过类库NetWorkSystemInfoClass来搜集目标机器相关信息 主要包括:MAC地址、公网IP、所在城市信息 方法名称: /// /// 获得当前机器的活动中Mac地址,若无联网则返回空"" /// /// mac地址,例如:18:03:73:AE:38:0D public static string GetActivatedAdaptorMacAddress() /// /// 获取本机的公网IP /// /// public static string GetPublicIP() /// /// 获取当前IP所在地、运营商,是网速可能为耗时操作。 /// /// 返回内容“浙江省湖州市 电信”;如遇异常,则返回:“string.Empty” public static string GetIpLocation() 详见代码

2014-08-19

aspose.words help

aspose.words 自动化操作离线帮助文档 aspose能够实现自动化的文档操作,并且可以实现客户端机器不安装word的操作

2013-03-06

RegexTextBox 正则 textBox 控件 可复用

相信很多刚入门的VS下的程序员会有一种困惑: 当希望一个textBox中只能输入非负的整数应该怎么办? 临时写一个正则来验证当然是个好思路 这里给你提供一个现成的可复用控件:RegexTextBox 原思路来自于codeProject,经过改写。 现在可以实现如下功能: 1、正常控件属性中填写正则表达式 2、不符合正则表达式,textBox边框变红 3、当TextBox的Leave事件发生时,检查TextBox内容是否符合正则,不符合就会报错,要求重新输入

2011-11-30

已知经纬度,球地球上两点之间距离(考虑地球曲率)

已知经纬度,球地球上两点之间距离(考虑地球曲率) 某些科研项目和常规项目,已经知道经纬度,需要计算两点之间距离 如果把地球当成平面来计算,随着经纬度跨度增大,误差会增加 这里采取gogole earth计算经纬度的算法。用C# 编写成dll。静态类,可以方便的直接调用

2011-09-16

C#系列教程.pdf

C#系列教程.pdf 系统学习c#技术的一本好书

2009-01-16

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除