Skip to content

Instantly share code, notes, and snippets.

View netdragoon's full-sized avatar

NetDragoon netdragoon

  • NetDragon
  • Brazil
View GitHub Profile
@netdragoon
netdragoon / CreditCardAttribute.cs
Created June 28, 2016 01:02 — forked from bjcull/CreditCardAttribute.cs
Credit Card Validator Attribute for ASP.NET MVC 3
/// ASP.NET MVC 3 Credit Card Validator Attribute
/// by Ben Cull - 4 November 2010
///
/// With special thanks to:
/// Thomas @ Orb of Knowledge - http://orb-of-knowledge.blogspot.com/2009/08/extremely-fast-luhn-function-for-c.html
/// For the Extremely fast Luhn algorithm implementation
///
/// And Paul Ingles - http://www.codeproject.com/KB/validation/creditcardvalidator.aspx
/// For a timeless blog post on credit card validation
@netdragoon
netdragoon / bin-cc.md
Created June 28, 2016 01:00 — forked from erikhenrique/bin-cc.md
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
@netdragoon
netdragoon / validate.cs
Created June 27, 2016 19:38
Validate.js_e_ValidationAttribute_IClientValidatable
/// <summary>
/// Validação customizada para CPF
/// </summary>
public class CustomValidationCPFAttribute : ValidationAttribute, IClientValidatable
{
/// <summary>
/// Construtor
/// </summary>
public CustomValidationCPFAttribute() { }
<!DOCTYPE html>
<html ng-app="app">
<head>
<title></title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.js"></script>
<style>
.hide {
display: none;
@netdragoon
netdragoon / slug.js
Created May 11, 2016 02:20 — forked from bentruyman/slug.js
JavaScript Slug Generator
// Generates a URL-friendly "slug" from a provided string.
// For example: "This Is Great!!!" transforms into "this-is-great"
function generateSlug (value) {
// 1) convert to lowercase
// 2) remove dashes and pluses
// 3) replace spaces with dashes
// 4) remove everything but alphanumeric characters and dashes
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
};
@netdragoon
netdragoon / url_slug.js
Created May 11, 2016 01:04 — forked from sgmurphy/url_slug.js
URL Slugs in Javascript (with UTF-8 and Transliteration Support)
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
@netdragoon
netdragoon / QuerableExtensions.cs
Created January 19, 2016 20:58 — forked from carlhoerberg/QuerableExtensions.cs
Dynamic LINQ OrderBy extension method
public static class QuerableExtensions
{
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property, bool asc)
{
return ApplyOrder<T>(source, property, asc ? "OrderBy" : "OrderByDescending");
}
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property)
{
return ApplyOrder<T>(source, property, "OrderBy");
}
@netdragoon
netdragoon / gist:5ced78d23923f3b1fa80
Created November 19, 2015 18:14 — forked from danesparza/gist:973923
Gravatar in C# - creating the hash
using System.Security.Cryptography;
/// Hashes an email with MD5. Suitable for use with Gravatar profile
/// image urls
public static string HashEmailForGravatar(string email)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
@netdragoon
netdragoon / Metodo.cs
Created October 18, 2015 02:40
Metodo Extension GetValues
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
namespace System.Web.Mvc.Html
{
public static class HH