Skip to content

Instantly share code, notes, and snippets.

View wezmag's full-sized avatar
👋
Looking for new opportunities

Wesley Huang wezmag

👋
Looking for new opportunities
  • HsinChu City, Taiwan
View GitHub Profile
@wezmag
wezmag / AspNetIdentitySampleSqlScript.sql
Created June 16, 2017 14:04
ASP.NET Identity Sql Script
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- --------------------------------------------------
-- 建立 AspNetUsers
-- --------------------------------------------------
CREATE TABLE [dbo].[AspNetUsers](
@wezmag
wezmag / GenericExtension.cs
Created April 14, 2017 07:38
Some extensions
public static class GenericExtension
{
public static bool Between<T>(this T value, T from, T to) where T : IComparable
{
return value.CompareTo(from) >= 0 && value.CompareTo(to) <= 0;
}
}
@wezmag
wezmag / jquery.validate.unobtrusive.dynamic.js
Created March 11, 2017 12:55 — forked from joelpurra/jquery.validate.unobtrusive.dynamic.js
$.validator.unobtrusive.parseDynamicContent by XHalent, modified to keep a reference to the jQuery selector/context object
/// <reference path="../jquery-1.7.js" />
/// <reference path="../jquery.validate.js" />
/// <reference path="../jquery.validate.unobtrusive.js" />
// Originally by XHalent, @xhalent
// http://xhalent.wordpress.com/
// http://xhalent.wordpress.com/2011/01/24/applying-unobtrusive-validation-to-dynamic-content/
// Modified by Joel Purra
// http://joelpurra.com/
@wezmag
wezmag / script.js
Last active March 3, 2017 07:00
一些JavaScript function
//是否為正整數
function isPositiveInteger(str) {
var n = Math.floor(Number(str));
return String(n) === str && n >= 0;
}
//是否為合法的Url
function isValidUrl(url) {
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(url);
@wezmag
wezmag / WebFormsBootstrapValidation.aspx
Last active December 14, 2016 05:12 — forked from meziantou/WebFormsBootstrapValidation.aspx
ASP.NET WebForms Validators & Bootstrap
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ASP.NET WebForms Validators & Bootstrap</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" />
@wezmag
wezmag / LDAPService.cs
Last active June 28, 2017 05:03
LDAP Service
using System.DirectoryServices;
public class LDAPService
{
private readonly string _rootStart;
private readonly string _serverName;
public LDAPService(String RootStart, String ServerName)
{
_rootStart = RootStart;