Skip to content

Instantly share code, notes, and snippets.

View marcioalthmann's full-sized avatar

Márcio Fábio Althmann marcioalthmann

View GitHub Profile
@marcioalthmann
marcioalthmann / getauthorizationgroups.cs
Last active August 29, 2015 13:56
Listando grupos de autenticação do usuário no domínio
var contexto = new PrincipalContext(ContextType.Domain);
// Retorna o nome do usuário, ex: DOMINIO\\Usuario
var usuario = WindowsIdentity.GetCurrent().Name;
// Retorna a lista de todos os grupos
var gruposDeAutorizacao = UserPrincipal.FindByIdentity(contexto, usuario).GetAuthorizationGroups();
// Uma forma simples de validar se o usuário faz parte de determinado grupo
var fazParteDoGrupoYYZ = gruposDeAutorizacao.Any(grupo => grupo.Name == "YYZ");
@marcioalthmann
marcioalthmann / objeto.cs
Last active August 29, 2015 14:04
Objeto
public class Objeto
{
public int PrimeiroValor { get;set;}
public int SegundoValor { get;set;}
}
[TestFixture ()]
public class Test
{
[Test ()]
@marcioalthmann
marcioalthmann / objeto2.cs
Last active August 29, 2015 14:04
Objeto2
public class Objeto
{
public int PrimeiroValor { get;set;}
public int SegundoValor { get;set;}
public int ObterSomaDosValores()
{
return PrimeiroValor + SegundoValor;
}
[Test()]
public void Somando_mais_de_uma_propriedade_com_select_mais_sum()
{
var lista = new List<Objeto> ();
lista.Add (new Objeto{ PrimeiroValor = 10, SegundoValor = 20 });
lista.Add (new Objeto{ PrimeiroValor = 30, SegundoValor = 40 });
Assert.AreEqual(100, lista.Select(x => x.PrimeiroValor + x.SegundoValor).Sum());
}
@marcioalthmann
marcioalthmann / table.html
Created August 14, 2014 23:16
cellpadding e cellspacing
<table cellspacing="10px" cellpadding="10px">
<tr>
<td>l1c1</td>
<td>l1c2</td>
</tr>
<tr>
<td>l2c1</td>
<td>l2c2</td>
</tr>
</table>
@marcioalthmann
marcioalthmann / css.css
Last active August 29, 2015 14:05
cellpadding e cellspacing
table{
border-spacing: 10px;
}
td{
padding: 10px;
}
@marcioalthmann
marcioalthmann / constantes.swift
Created August 21, 2014 23:47
Swift - constantes
let pi = 3.14
@marcioalthmann
marcioalthmann / variaveis.swift
Created August 21, 2014 23:52
Swift - variáveis
var nome = "Márcio Fábio Althmann"
var idade = 30
var anoDeNascimento: Int
anoDeNascimento = 1983
var primeiroNome: String
primeiroNome = "Márcio"
var dia = 8, mes = 10, ano = 1983
for i in 1...10{
println(i)
}
for _ in 1...10{
println("Olá")
}