Skip to content

Instantly share code, notes, and snippets.

View portal7's full-sized avatar

Alfredo Severo portal7

  • Buenos Aires, Argentina
View GitHub Profile
@portal7
portal7 / ApplicationUser.cs
Created March 18, 2016 19:22
Granular permissions with certain requirements for an MVC site
public class ApplicationUser : IPrincipal
{
private readonly RoleSet roles;
public ApplicationUser(RoleSet roles)
{
this.roles = roles;
}
public bool IsInRole(string role)
@portal7
portal7 / gist:773710d8309a8028bb08
Created March 22, 2016 16:29 — forked from rXc3NtR1c/gist:ce24e8a3667e50993f1c
October CMS Web.Config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="themes/.*/(layouts|pages|partials)/.*.htm" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
@portal7
portal7 / DataTableResultSet.cs
Last active August 22, 2016 14:00 — forked from OllieJones/DataTableResultSet.cs
C# code for handling Ajax calls for the DataTables.net client table-rendering plugin.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
/// <summary>
/// Resultset to be JSON stringified and set back to client.
/// </summary>
///
namespace DataTables
{
var navProps = new Expression<Func<Beer, object>>[]
{
a => a.Ingredients,
a => a.Sizes,
a => a.Hangovers
});
@portal7
portal7 / text.html
Created August 24, 2016 14:20
No seleccionable
<style>
html {
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@portal7
portal7 / MonthToString.cs
Created October 20, 2016 15:36
Month to String with Culture Spanish / Mes a partir de una Fecha en C# con cultura Español
public string MonthName(int month)
{
DateTimeFormatInfo dtinfo = new CultureInfo("es-ES", false).DateTimeFormat;
return dtinfo.GetMonthName(month);
}
// Use
DataTime fecha = Convert.ToDateTime("16/04/2010");
@portal7
portal7 / ConvertNumberToString.cs
Created November 9, 2016 13:43
Convierte Numero a Texto en Español / Convert Number to Text in Spanish (could be English tooo....)
using System;
/// <summary>
/// Convierte un Numero en Letras
/// </summary>
public class ConvertToNumber
{
public string EnLetras(string num)
{
string res, dec = "";
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Unit Test</Title>
<Author>Rusty Divine</Author>
<Description>Unit Test Template with 3 Parts</Description>
<HelpUrl>https://msdn.microsoft.com/en-us/library/ms165394.aspx</HelpUrl>
<SnippetTypes />
<Keywords />
@portal7
portal7 / demo.html
Last active October 4, 2022 01:46
jQuery Validator Email Domain
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<form id="myForm" name="myForm" action="#" method="POST"> <style>#email-error { display: block; color: red; }</style>
<label for="email">Email: </label>
<input id="email" name="email" type="email" minlength="6"/><br>
<input type="submit" value="Submit">
</form>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA