Skip to content

Instantly share code, notes, and snippets.

@ms-tg
ms-tg / play20-scala-add-http-response-header.scala
Created June 28, 2012 17:28
Example usage of GlobalSettings#onRouteRequest in Play framework 2.0.x scala
import play.api._
import mvc._
import controllers.Info.VERSION_PROPERTY
import controllers.Info.DEFAULT_VERSION
object Global extends GlobalSettings {
val VERSION_PROPERTY = "my.property.name"
val DEFAULT_VERSION = "0.0.0"
@ms-tg
ms-tg / memoize1.java
Created January 24, 2012 17:40
Scala 'lazy val' vs Java memoization
/**
* Without worrying about concurrency, we can simply cache the return value,
* using null to indicate that it has not yet been calculated...
*/
public class Memoize1 extends Original {
private Integer total;
@Override
public int total() {
if (total == null) {
@ms-tg
ms-tg / Example01FirstLightServiceImpl.java
Created January 12, 2012 21:07
./TIMWeb/src/main/java/gwt/example01firstlight/server/Example01FirstLightServiceImpl.java
package gwt.example01firstlight.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.inject.Singleton;
import gwt.example01firstlight.client.Example01FirstLightService;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Singleton
@ms-tg
ms-tg / Example01FirstLightService.java
Created January 12, 2012 21:04
./TIMWeb/src/main/java/gwt/example01firstlight/client/Example01FirstLightService.java
package gwt.example01firstlight.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("ex1")
public interface Example01FirstLightService extends RemoteService {
String getMessage(String msg);
@ms-tg
ms-tg / Example01FirstLightServiceAsync.java
Created January 12, 2012 20:55
./TIMWeb/src/main/java/gwt/example01firstlight/client/Example01FirstLightServiceAsync.java
package gwt.example01firstlight.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface Example01FirstLightServiceAsync {
void getMessage(String msg, AsyncCallback<String> async);
}
@ms-tg
ms-tg / Example01FirstLight.java
Created January 12, 2012 20:50
./TIMWeb/src/main/java/gwt/example01firstlight/client/Example01FirstLight.java
package gwt.example01firstlight.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import static gwt.example01firstlight.client.Example01FirstLightService.App;
@ms-tg
ms-tg / could_not_entity.txt
Created November 21, 2011 20:19
research resource could not load an entity
Error from research resource (https://timdev.youdevise.com:443/TIMHead/services/company/4028ae8d2fedb469013026db4847036c/research?from=2011-10-01&to=2011-11-21&author=4028ae8d303589ad013056ecb93a5efe&ratingLabel=Neutral):
<?xml version="1.0" standalone="yes" ?>
<error>could not load an entity: [com.youdevise.ids.sector.ReutersSubIndustry#101]</error>
Excerpt from Application.log on Defence:
2011-11-21 20:02:32,166 tbrown (REST request) ERROR [ajp-192.168.43.5-8009-69] rest3.RequestInvoker$ResourceWriter (RequestInvoker.java:89) - Unhandled exception in Rest3 Request.
org.hibernate.exception.JDBCConnectionException: could not load an entity: [com.youdevise.ids.sector.ReutersSubIndustry#101]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
@ms-tg
ms-tg / gist:1355523
Created November 10, 2011 17:34
lightning talk
How do we test TIM controllers from the html parameters?
Rails:
test "should create post" do
assert_difference('Post.count') do
post :create, :post => { :title => 'Hi', :body => 'This is my first post.'}
end
assert_redirected_to post_path(assigns(:post))
assert_equal 'Post was successfully created.', flash[:notice]