Skip to content

Instantly share code, notes, and snippets.

View cmendesce's full-sized avatar

Carlos Mendes cmendesce

View GitHub Profile
@cmendesce
cmendesce / ActivityDispatcher.java
Created November 14, 2012 02:44
Gerenciadores de activities
package br.com.pingucostore.ui.activities;
import android.content.Context;
import android.content.Intent;
import br.com.pingucostore.domain.entities.Cardapio;
public class ActivityDispatcher {
private Context context;
public ActivityDispatcher(Context context) {
@cmendesce
cmendesce / Entity.java
Created November 20, 2012 02:38
Implementação básica do padrão repository (http://martinfowler.com/eaaCatalog/repository.html) no Android.
package br.edu.fa7.exemplo.domain.entities;
import java.io.Serializable;
public class Entity implements Serializable {
private long id;
public Entity() {
this.id = 0;
}
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
exec sp_MSforeachtable 'DELETE ?'
exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID("?"), "TableHasIdentity") = 1 BEGIN DBCC CHECKIDENT ("?",RESEED,1) END'
@cmendesce
cmendesce / HybridSessionContext.cs
Created April 28, 2013 21:56
Implementa o contexto do nhibernate para armazenar a session, dentro do HttpContext, caso exista, ou dentro do CallContext
namespace Core.Data.NH
{
using System.Runtime.Remoting.Messaging;
using System.Web;
using NHibernate;
using NHibernate.Context;
using NHibernate.Engine;
/// <summary>
@cmendesce
cmendesce / OpenSessionInViewModule.cs
Created April 28, 2013 21:58
HttpModule para controle do ISession do NHibernate usando o Unity.
// --------------------------------------------------------------------------------------------------------------------
// Autor: rafaeluchoa
// Data de criação: 19/11/2012
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Web;
using Core.Data.NH;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;
@cmendesce
cmendesce / hidden_files
Created June 11, 2013 04:09
View hidden files on mac
defaults write com.apple.Finder AppleShowAllFiles YES
@cmendesce
cmendesce / BitmapManager.java
Created October 20, 2013 20:07
Class for downloading and storing images in android project.
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
@cmendesce
cmendesce / CreatePartition
Created May 12, 2014 15:51
This script creates a bootable disk for mavericks osx.
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/SuperDrive --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
// Insert code here to initialize your application
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:NO];
// Multiple files not allowed
[openDlg setAllowsMultipleSelection:NO];