Skip to content

Instantly share code, notes, and snippets.

View cleytonferrari's full-sized avatar

Cleyton Ferrari cleytonferrari

View GitHub Profile
@cleytonferrari
cleytonferrari / SubMenus.cs
Last active December 3, 2019 23:35
Criar uma listagem de menu com sub menus, usando um método recursivo.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MenuTransparencia
{
class Program
{
@cleytonferrari
cleytonferrari / SeoUrl.cs
Last active December 20, 2015 04:29
Normaliza texto para virar URL. var UrlNormalizada = SeoUrl.Sanitize("meu texto que vai virar url");
public static class SeoUrl
{
public static string Sanitize(string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}
var normalizedString = FoldDiacriticals(input);
@cleytonferrari
cleytonferrari / AlunoController.cs
Created August 3, 2013 15:28
Exemplo de Controller para um crud simples em ASP .Net MVC
using System.Web.Mvc;
using TISelvagem.Aplicacao;
using TISelvagem.Dominio;
namespace TISelvagem.UI.Web.Controllers
{
public class AlunoController : Controller
{
//
// GET: /Aluno/
@cleytonferrari
cleytonferrari / FSharp.fs
Last active December 20, 2015 16:09
Exemplo de uso em F#, fui pesquisando e consegui chegar nisso, o meu helloWorld
let somar (n1:int) (n2:int) = n1 + n2
let subtrair = fun n1 n2 -> n1 - n2
let multiplicar n1 n2 = n1 * n2
module Calculadora =
let somar n1 n2 = n1 + n2
let subtrair = fun n1 n2 -> n1 - n2
let rec fatorial n =
if n = 0
@cleytonferrari
cleytonferrari / data.cs
Created August 10, 2013 14:00
Algumas funções pra trabalhar com datas
DateTime baseDate = DateTime.Today;
var today = baseDate;
var yesterday = baseDate.AddDays(-1);
var thisWeekStart = baseDate.AddDays(-(int)baseDate.DayOfWeek);
var thisWeekEnd = thisWeekStart.AddDays(7).AddSeconds(-1);
var lastWeekStart = thisWeekStart.AddDays(-7);
var lastWeekEnd = thisWeekStart.AddSeconds(-1);
var thisMonthStart = baseDate.AddDays(1 - baseDate.Day);
var thisMonthEnd = thisMonthStart.AddMonths(1).AddSeconds(-1);
@cleytonferrari
cleytonferrari / ola.rb
Created August 16, 2013 20:48
Hello world em Ruby
class Ola
def initialize(nome="mundo")
@nome = nome
end
def dizOi
puts "Olá #{@nome}"
end
def dizFui
puts "Adeus #{@nome}"
end
using System.Collections.Generic;
using System.Web.Http;
using W7Gestao.UI.Web.Helper;
namespace W7Gestao.UI.Web.Controllers.API.Configuracao
{
public class UsuarioController : ApiController
{
[Seguranca(Roles = "Administrador")]
public IEnumerable<string> Get()
@cleytonferrari
cleytonferrari / AtaController.cs
Created October 1, 2013 03:01
Vários dominios para varios temas em um mesmo site
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;
using W7.Camara.Aplicacao;
using W7.Camara.UI.Web.Site.ViewModel;
namespace W7.Camara.UI.Web.Site.Controllers
@cleytonferrari
cleytonferrari / if.cs
Created November 20, 2013 20:07
Orgulho de ter feito tanto IF em um FOR, deve ter matado uns 6 ursos pandas com essa brincadeira!
foreach (var empenhoXML in listaDeEmpenhosConvertidos)
{
var empenhoBanco = lista.FirstOrDefault(x => x.NumeroEmpenho == empenhoXML.NumeroEmpenho);
if (empenhoBanco != null)
{
if (empenhoXML.ValorEmpenhado < 0)
{
if (empenhoBanco.Anulacao == null) empenhoBanco.Anulacao = new Collection<ItensAnulacao>();
if (empenhoBanco.Anulacao.Any(x => x.Data == empenhoXML.Data && x.Valor == empenhoXML.ValorEmpenhado))
continue;
@cleytonferrari
cleytonferrari / modelagem
Created December 17, 2013 21:21
Problema de Modelagem
Public class Vereador {
public int Id {get;set;}
public string Nome {get;set;}
public string Partido {get;set;}
}
Public class Funcionario {
public int Id {get;set;}
public string Nome {get;set;}