Skip to content

Instantly share code, notes, and snippets.

View alexsandro-xpt's full-sized avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
@alexsandro-xpt
alexsandro-xpt / gist:9230438
Created February 26, 2014 14:33
Mapping database to entity
public override IQueryable<TEntity> GetAll()
{
var table = base.Context.ExecutarSQL(Querys[QueryType.GetAll], null);
var i = table.Rows.Cast<object>().Select(row =>
{
var entity = new TEntity();
foreach (var prop in entity.GetType().GetProperties())
{
@alexsandro-xpt
alexsandro-xpt / gist:9251264
Created February 27, 2014 14:35
Liberando sites sem login no hotspot
/ip hotspot walled-garden ip add action=accept disabled=no dst-host=www.site.com
@alexsandro-xpt
alexsandro-xpt / gist:9252718
Last active August 29, 2015 13:56
Configurações para o PHPUnit

tests\phpunit.xml

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="../public/bootstrap.php"
         cacheTokens="true"
         colors="false"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
@alexsandro-xpt
alexsandro-xpt / gist:11048630
Created April 18, 2014 15:01
Delete all tables
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
public override async Task<ClaimsIdentity> CreateAsync(UserManager<IUser, string> userManager, IUser user, string authenticationType)
{
var id = new ClaimsIdentity(authenticationType, UserNameClaimType, null);
id.AddClaim(new Claim(UserIdClaimType, user.Id.ToString(), ClaimValueTypes.Integer));
id.AddClaim(new Claim(UserNameClaimType, user.UserName, ClaimValueTypes.String));
id.AddClaim(new Claim(IdentityProviderClaimType, DefaultIdentityProviderClaimValue, ClaimValueTypes.String));
if (userManager.SupportsUserRole)
{
using System;
using System.Text.RegularExpressions;
namespace NfeXml
{
/// <summary>
/// Usando como CPF do emitente da NF de produtor (v2.0)
/// E tambem usando como Número do CPF do emitente. CPF do transportador.
/// </summary>
public class Cpf : XmlBuilder, IDocumentoPessoa
[TestMethod]
public void QuantoCrioUmaIdentificacaoEmitenteCompleto()
{
var obj = CriarIdentificacaoEmitente();
var cnpj = new Cnpj("14.589.621/0001-67");
var cpf = new Cpf("317.647.094-03");
var nomeEmitente = new Nome("Jose");
var logradouro = new Logradouro("Rua das coves");
@alexsandro-xpt
alexsandro-xpt / gist:64c87a5e328487e91102
Created September 9, 2014 21:23
EF delete Many-To-Many rows at non-mapped entitys tables
public void RemoverCondigoBarra(CodigoBarra codigoBarraa)
{
var set = (((ApplicationDatabaseContext)_context).EfDatabaseContext).Set(typeof(CodigoBarra));
var remove = set.Remove(codigoBarraa);
}
public void RemoverFoto(Foto foto)
{
var set = (((ApplicationDatabaseContext)_context).EfDatabaseContext).Set(typeof(Foto));
#!/bin/bash
if [ $EUID != 0 ]; then
echo 'Você precisa ser root para instalar certificados.'
exit $?
fi
# Diretório onde os certificados serão instalados
cert_path=`openssl version -d|sed 's/.*\"\(.*\)\"/\1/g'`/certs
# Path para o certificado da Cielo
#include <iostream>
using namespace std;
int main()
{
cout << "Digite um numero:" << endl;
int num = 0;