Monday, 2 September 2013

angular directive replace newline with html

angular directive replace newline with html

I am using a service to retrieve data which binds to the html like this
{{order.Notes}}
order.Notes may contain multi-line text so i would like to format it using
html tags 'br'
This is the directive i'm trying to use:
angular.module('directives', [])
.directive('htmlText', function () {
return {
restrict: 'E',
template: '<div ng-bind-html-unsafe="html"></div>',
scope: {
text: '='
},
link: function (scope, elem, attrs) {
var updateText = function () {
if (scope.text != null) {
scope.html = scope.text.replace('\n', "<br/>");
}
};
scope.$watch('text', function (oldVal, newVal) {
if (newVal) {
updateText();
}
});
}
};
});
<html-text text="order.Notes"></html-text>
however, newVal is always null. what am i missing here?

Retrieving GAE data via Key

Retrieving GAE data via Key

I'm new to python & google app engine so this is going to be a basic
question but I cannot find an answer elsewhere ...
I'm trying to retrieve a record by passing the key (as generated by GAE)
from an HTML page back to python.
My html call is
<a
href="/playerprofile?uid=ahRkZXZ-Y293YnJpZGdlYm9va2luZ3IWCxIGTWVtYmVyIgpKb2huIEpvbmVzDA">John
Jones</a>
I'm then trying to pull it out of the table like this
uid = self.request.get('uid')
m = Member.all().filter('Key = ',uid)
It doesn't retrieve anything. How do I do it?

iterating json elements in c#

iterating json elements in c#

I have got the following json returned from a service :
{
responseHeader: {
status: 0,
QTime: 1
},
spellcheck: {
suggestions: [
"at",
{
numFound: 2,
startOffset: 0,
endOffset: 2,
suggestion: [
"at least five tons of glitter alone had gone into it
before them and",
"at them the designer of the gun had clearly not been
instructed to beat"
]
},
"collation",
"(at least five tons of glitter alone had gone into it before them
and)"
]
}
}
I need to create in c# a List of what inside the "suggestion" element.
What is the best way?
What are the elements not surrounded by "". Shouldn't all json element be
surrounded by ""? Thanks.

Mono GUI Application is going to hang after moving tab from one window to another window

Mono GUI Application is going to hang after moving tab from one window to
another window

I have Ubuntu 12.04 and mono 2.10.8 in my Linux PC.
I am running one .NET binary using mono on my Linux platform PC and it is
working fine on process startup.
But when i moved my running GUI window to another window and get back to
that windows at that time , My GUI Application goes into the hang state
because i can not press any button on My GUI window.
I have also used all the optimization option step by step while running
.NET binary using mono but still causes the GUI hang issue.
I have debug my .NET binary with some debugging options and found that
whenever GUI window application goes into stuck condition at that GDIplus
library code is running. so, it seems that there is something is going
wrong into the GDIplus library.
does any one have idea what is happening here or any one have faced this
issue before?
Please let me know if anyone need any more information and give valuable
feedback as sson as possible.

Collision detection - stop two cubes intersecting

Collision detection - stop two cubes intersecting

I'm trying to work out how to do this and keep getting stuck. Working out
when the two cubes collide is fine, its just how I limit each of them not
to intersect, and instead slide along the edges of one another when they
come into contact that I am struggling with.
I've tried working out the bounding box of each cube (each cube is 100cm
width and height by the way) and then tried saying if B position.x is less
than the bounding box max.x of A then limit box B's position.x. But how I
get that to work on all of the sides I have no idea? Any helpers with a
better brain than mine willing to help?

Sunday, 1 September 2013

Not able to bind plugin goals to maven lifecycle phases

Not able to bind plugin goals to maven lifecycle phases

I am using maven sql plugin. I am using the plugin to setup the my test db
before executing integration tests. Here is my plugin configuration from
my project pom. When I execute mvn clean install I expect the plugin goals
to execute. But they are not getting executed. Any help will be
appreciated. I am facing similar issue for aspectj plugin (configuration
provided below).
My SQL plugin configuration:
<!-- Maven SQL Plugin for setting up test schema for integration tests -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies> <!-- specify the dependent JDBC driver here -->
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<url>jdbc:hsqldb:sample</url>
<username>sa</username>
<password></password>
</configuration>
<executions>
<execution>
<id>create_db_schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<!-- specific configuration for this execution -->
<configuration>
<srcFiles>
<srcFile>src/test/resources/mystudywindow-test-schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>shutdown_db_instance</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>SHUTDOWN IMMEDIATELY</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
My aspectj plugin configuration:
<!-- AspectJ Compile-time waving for spring cross-store. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
<showWeaveInfo>true</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-cross-store</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

Multilingual site like stackoverflow

Multilingual site like stackoverflow

I've spend a couple of days thinking of a best practical way to build a
multilingual site like stackoverflow, where all users can post their
questions in different languages taking the following points in
consideration:
The website has a home page were the questions appears, (like stackoverflow)
It is language wise, it means, users who speak language X don't see
questions in language Y, unless they want to. They don't see other
language unless they choose to browse all questions in all/specific
language(s).
I have thought about many solutions for this, such as:
To let the user choose the language of the question or his country while
posting it, but I don't see it feasible and it can be very boring.
To have a sub-domain for each language, like this answer here Building
multilingual site, but this will not give a realistic visit number to the
main domain (www.example.com).
I've looked into social networks, like facebook & twitter, who let the
user to decide which feed to read on his wall, which they can in any
language, but that is far from what I want. I don't want the user to
choose, because that will lead me to create groups, and eventually it will
turn into another social network.
So, I'm wondering how can I manage to create a multilingual site but like
stackoverflow taking in consideration the points above?