Skip to content

Instantly share code, notes, and snippets.

💭
Paternity leave, see y'all in June.

Diego Magalhães dgomesbr

Block or report user

Report or block dgomesbr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!-- if-then-else form -->
<if condition='property("profile").contains("PROD")'>
<then>
<property name="LOGGER_LEVEL" value="INFO" />
<property name="CONSOLE_LOGGER_LEVEL" value="WARN" />
</then>
<else>
<property name="LOGGER_LEVEL" value="INFO" />
View UserRequiredAnnotationInterceptor.java
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}
View UserRequiredAnnotationInterceptor.java
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}
@dgomesbr
dgomesbr / SpringConfig.java
Created Oct 9, 2012
Spring 3.1 Configurable Class :)
View SpringConfig.java
package com.bemobi.wap.config;
import java.util.Properties;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.hibernate.ejb.HibernatePersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@dgomesbr
dgomesbr / gist:1882968
Created Feb 22, 2012
StructureMap Fooooo
View gist:1882968
For<IRepository<TipoServico>>().Use<Repository<TipoServico>>();
@dgomesbr
dgomesbr / GenericRepository.cs
Created Feb 9, 2012
Implementação do repositório genérico
View GenericRepository.cs
using System.Collections.Generic;
using workshop_httpmodule;
namespace Workshop.Data.NHibernate
{
public class GenericRepository<T> : IRepository<T>
{
public T Save(T entity)
{
NHibernateHttpModule.RecuperarSessao.Save(entity);
@dgomesbr
dgomesbr / IRepository.cs
Created Feb 9, 2012
Interface para repositório genérico
View IRepository.cs
using System.Collections.Generic;
namespace Workshop.Data
{
public interface IRepository<T>
{
T Save(T entity);
T Update(T entity);
void Delete(T entity);
T ById(int id);
@dgomesbr
dgomesbr / Category.cs
Created Feb 9, 2012
Mapeamento da classe Categoria no NHibernate 3.2
View Category.cs
using NHibernate.Driver;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
namespace workshop_Entity
{
public class Category
{
public virtual int IdCategoria { get; set; }
public virtual string Nome { get; set; }
@dgomesbr
dgomesbr / NHibernateHttpModule.cs
Created Feb 9, 2012
NHibernateHttpModule.cs depois do resharper
View NHibernateHttpModule.cs
using System;
using System.Web;
using NHibernate;
using NHibernate.Cfg;
namespace workshop_httpmodule
{
public class NHibernateHttpModule : IHttpModule
{
public static readonly string NHibernateSessionKey = "NHibernateSession";
@dgomesbr
dgomesbr / ContentHelper.cs
Created Feb 6, 2012
ASP.NET MVC 2 Html.ImageActionLink Helper using Microsoft.Web.Mvc
View ContentHelper.cs
// After using the Microsoft.Web.Mvc Html.ActionLink<TController>(... Expression<Action<TController>> action ...);
// I was unable to use that for a Image, so here's the code for it:
// **** :) no more magic strings for image linking to actions.
// usage:
// <%= Html.ImageActionLink<HomeController>(
// x => x.ChangeCulture(Culture.pt, this.Request.RawUrl),
// Culture.pt.ToString() + ".png")
// %>
You can’t perform that action at this time.