Skip to content

Instantly share code, notes, and snippets.

View jfbueno's full-sized avatar
🏠
Working from home

Jéf Bueno jfbueno

🏠
Working from home
View GitHub Profile
public class FormMain : Form
{
private void btLupa_Click(object sender, EventArgs e)
{
var form = new FormPesquisa(umaListaComOsDados);
form.ShowDialog();
if(!string.IsNullOrEmpty(form.Retorno))
textBox.Text = form.Retorno;
}
@jfbueno
jfbueno / lista.py
Last active February 28, 2016 15:07
values = [1, 4, 5, 2, 3, 6, 9, 7, 8]
for i in sorted(values):
print(i)
#[print(v) for v in sorted(values)] ou assim usando compreensão
soma = sum(values)
print('soma %d' % soma)
@jfbueno
jfbueno / Pessoa.cs
Created April 15, 2016 19:09
Teste-Pessoa-Com-EAV
[Table("Pessoas")]
public class Pessoa
{
[Key]
public int Id { get; set; }
public string NomePrincipal { get; set; }
public string Nome { get; set; }
public bool Ativo { get; set; }
public virtual List<PessoaAtributoValor> Atributos { get; set; }
public static class DatabaseLogger
{
public static void Log(string query)
{
var words = query.Split(' ');
if (words.FirstOrDefault()?.ToUpper() == "UPDATE")
{
//aqui salva o log de update
}
public class CamelCaseControllerConfigAttribute : Attribute, IControllerConfiguration
{
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
{
var formatter = controllerSettings.Formatters.OfType<JsonMediaTypeFormatter>().Single();
controllerSettings.Formatters.Remove(formatter);
formatter = new JsonMediaTypeFormatter
{
SerializerSettings = { ContractResolver = new CamelCasePropertyNamesContractResolver() }
@jfbueno
jfbueno / Customer.cs
Created June 1, 2016 12:54
Relação pro mesmo model
[Key, ForeignKey("Entity")]
public int EntityId { get; set; }
public virtual Entity Entity { get; set; }
[ForeignKey("Headquarter")]
public int HeadquarterId { get; set; }
public virtual Customer Headquarter { get; set; }
public virtual List<Customer> Branches { get; set; }
protected static T GetFromEntityModel<T>(Entity entityModel) where T : EntityBaseViewModel, new()
{
var derivedTypes = GetDerivedClasses<T>().ToList();
var typeToConvert = (from type in derivedTypes
let properties = type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(SpecificInfoPerCountryAttribute)))
where properties != null
where entityModel.SpecificInfoPerCountry.Count > 0 &&
entityModel.SpecificInfoPerCountry.All(attr => properties.Any(prop => prop.Name == attr.Description))
select type).SingleOrDefault() ?? typeof(T);
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
100 - Move on! Get outta my way!
101 -
102 -
204 - I've nothing to say
401 - You have no power here!
403 - Se tu não mora aqui, vaza.
404 - This shit even exists?
405 -
@jfbueno
jfbueno / view.cshtml
Created February 2, 2017 12:47
renan-noticias
<div class="row">
@foreach(var item in Model)
{
<div class="col-md-4">
<div class="thumbnail">
<h3 style="padding-left:17px;padding:0; background-color:orangered; margin:0; text-align:center;color:white;">@Html.DisplayFor(model => item.Titulo)</h3>
<img src="~/Uploads/Imagens/teste.jpg" class="col-md-12 " style="padding:0;" />
<div>
@Html.DisplayFor(model => item.Resumo);
</div>