Skip to content

Instantly share code, notes, and snippets.

View jadianes's full-sized avatar

Jose A Dianes jadianes

  • http://mosaic-tx.com
  • Cambridge, UK
View GitHub Profile
@jadianes
jadianes / TransferEntity.java
Created August 19, 2012 09:51
The transfer entity
package com.jadianes.samples.genericdao.transfer;
/**
* This interface represents a TransferEntity in the Dao pattern used to interchange information between the
* BusinessObject and the DataAccessObject (Dao). Tipically the Dao will set/get this object from the
* DataSource (e.g. a DB or a message channel). See more info about the Dao pattern in:
*/
public interface TransferEntity<K> {
public void setId(K id);
public K getId();
@jadianes
jadianes / Dao.java
Created August 19, 2012 10:03
The DAO
package com.jadianes.samples.genericdao.dao;
import com.jadianes.samples.genericdao.transfer.TransferEntity;
/**
* The Dao represents the DataAccessObject (Dao) in the Dao pattern. It is generified so it is associated
* will a specific TransferEntity (TransferEntity in the Dao pattern) that will create, update, persist, etc.The interface
* enforces the minimum set of operations needed to deal with TransferEntity instances.
* Other methods can be used under the following conventions:
*/
@jadianes
jadianes / DataSource.java
Created August 19, 2012 10:06
The data source
package com.jadianes.samples.genericdao.datasource;
/**
* An interface representing data sources in the Dao pattern.
*/
public interface DataSource {
}
@jadianes
jadianes / DaoFactory.java
Created August 19, 2012 10:13
The Dao factory interface
package com.jadianes.samples.genericdao.factory;
import com.jadianes.samples.genericdao.datasource.DataSource;
/**
* An abstract factory interface representing Dao factories for a particular data source. Implementations of this
* interface will typically offer methods to obtain Dao instances for the given DataSource. The use of
* factories is optional in the Dao libraries. They are actually traversal to different ModelEntities and vertical
* to specific data sources. However, they will increase the portability of business layers across multiple data sources.
*/
@jadianes
jadianes / server.R
Created August 13, 2015 11:23
Sentiment Analyser Shiny app
library(shiny)
library(tm)
library(SnowballC)
library(randomForest)
options(mc.cores=1)
build_model <- function(new_data_df, sparsity) {
# Create new data corpus
new_corpus <- Corpus(VectorSource(new_data_df$Text))
@jadianes
jadianes / urls
Created September 15, 2015 08:20
urls.py for winerama at stage-2.2
from django.conf.urls import url
from . import views
urlpatterns = [
# ex: /
url(r'^$', views.review_list, name='review_list'),
# ex: /review/5/
url(r'^review/(?P<review_id>[0-9]+)/$', views.review_detail, name='review_detail'),
# ex: /wine/