Skip to content

Instantly share code, notes, and snippets.

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

Diego Magalhães dgomesbr

🏠
Working from home
View GitHub Profile
@dgomesbr
dgomesbr / gist:1140687
Created August 11, 2011 20:34
Zebra Stripe tables :)
$(document).ready(function(){
$(".stripeMe tr").on{
mouseover: function()
{
$(this).addClass("over");
}
mouseleave: function()
{
$(this).removeClass("over");
}
@dgomesbr
dgomesbr / ContentHelper.cs
Created February 6, 2012 19:28
ASP.NET MVC 2 Html.ImageActionLink Helper using Microsoft.Web.Mvc
// 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")
// %>
@dgomesbr
dgomesbr / NHibernateHttpModule.cs
Created February 9, 2012 20:08
NHibernateHttpModule.cs depois do resharper
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 / Category.cs
Created February 9, 2012 20:14
Mapeamento da classe Categoria no NHibernate 3.2
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 / IRepository.cs
Created February 9, 2012 20:16
Interface para repositório genérico
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 / GenericRepository.cs
Created February 9, 2012 20:17
Implementação do repositório genérico
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 / gist:1882968
Created February 22, 2012 07:14
StructureMap Fooooo
For<IRepository<TipoServico>>().Use<Repository<TipoServico>>();
@dgomesbr
dgomesbr / SpringConfig.java
Created October 9, 2012 20:23
Spring 3.1 Configurable Class :)
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;
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}