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?

what technology should be used to describe a story or news?

what technology should be used to describe a story or news?

I'm studying semantic web on my research, and it has limitation to present
a story or news, it is used to present the details of a resource.
So if i want to present a story or news in machine readable format, where
should i start?
Thanks

Animation when user enters frontpage

Animation when user enters frontpage

I want the following "effect":
When user enters my website (index.php) I want them just to see a Logo
with a background (which overlays the index.php).
Now imagine the screen is divided horizontally at the middle. Without
pressing anything the upper part should move upwards and the lower part
downwards. Somehow like a "curtain" effect.

How to create core.jar using Terminal in Mac?

How to create core.jar using Terminal in Mac?

I have downloaded zxing-2.2 from the following link:
https://code.google.com/p/zxing/downloads/list
I am navigate to the root directory of the downloaded zxing-2.2 folder and
executing following command to create core.jar :
ant -f core/build.xml
Following is the output i see in terminal:
Buildfile: /Users/Piscean/Desktop/zxing-2.2/build.xml
release:
[zip] Building zip: /Users/Piscean/Desktop/zxing-2.2/ZXing-2.2.zip
[zip] Warning: skipping zip archive
/Users/Piscean/Desktop/zxing-2.2/ZXing-2.2-testdata.zip because no files
were included.
BUILD SUCCESSFUL
Total time: 2 seconds
But it does not create any core.jar in core folder. But it creates a new
ZXing-2.2.zip in zxing-2.2 folder. Am i doing something wrong? How can i
create core.jar ? Thanks in advance.

NSString componentsSeparatedByString after that values i need to show in one label

NSString componentsSeparatedByString after that values i need to show in
one label

I friends,
I have some values in one string how can i split that string values
separately i need to show in one label , dis my values i got in nsstring
values showing ( "", "user_currency_code=USD", "user_currency_symbol=$",
"usertypecode=ROBT", "player_level=1", "player_isblocked=false",
"lang=en", "respond=true", "flylogin=false", "str=PageEnd",
"user_balance=100000394.90", "user_bonus_balance=0.00", "first_name=test",
"cash_balance=100000394.90", "coupon_balance=0.00", "str=PageEnd",
"remain_GameCount=0", "remain_PTAmount=0.00",
"real_user_balance=100000394.90", "fun_user_balance=95725.15",
"user_bonus_balance=0.00", "bonusstatus=false", "bonus_id=null" )
in dis value separately i need to show all separate labels example
currency code values ,i need to show one label in dis label it will
display like dis USD. Like that i need to get all values and show in each
label

Sunday, 1 September 2013

Why does Browser still sends request for cache-control public with max-age?

Why does Browser still sends request for cache-control public with max-age?

I have Amazon S3 objects, and for each object, I have set
Cache-Control: public, max-age=3600000
That is roughly 41 days.
And I have Amazon CloudFront Distribution set with Minimum TTL also with
3600000.
This is the first request after clearing cache.
GET /1.0.8/web-atoms.js HTTP/1.1
Host: d3bhjcyci8s9i2.cloudfront.net
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/29.0.1547.57 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
And Response is
HTTP/1.1 200 OK
Content-Type: application/x-javascript
Content-Length: 226802
Connection: keep-alive
Date: Wed, 28 Aug 2013 10:37:38 GMT
Cache-Control: public, max-age=3600000
Last-Modified: Wed, 28 Aug 2013 10:36:42 GMT
ETag: "124752e0d85461a16e76fbdef2e84fb9"
Accept-Ranges: bytes
Server: AmazonS3
Age: 342557
Via: 1.0 6eb330235ca3971f6142a5f789cbc988.cloudfront.net (CloudFront)
X-Cache: Hit from cloudfront
X-Amz-Cf-Id: 92Q2uDA4KizhPk4TludKpwP6Q6uEaKRV0ls9P_TIr11c8GQpTuSfhw==
Even while Amazon clearly sends Cache-Control, Chrome still makes second
request instead of reading it from Cache.
GET /1.0.8/web-atoms.js HTTP/1.1
Host: d3bhjcyci8s9i2.cloudfront.net
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/29.0.1547.57 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
If-None-Match: "124752e0d85461a16e76fbdef2e84fb9"
If-Modified-Since: Wed, 28 Aug 2013 10:36:42 GMT
Question: Why does chrome makes second request?
Expires This behavior changes when I put an explicit Expires attribute in
headers. Browser will not send subsequent request for Expires header, but
for cache-control public, it does send it. My all S3 objects will never
change, they are immutable, when we change file, we put them as new object
with new URL.
In Page Script Reference Chrome makes subsequent requests only sometimes,
I did this test by actually typing URL in browser. When script is
referenced by HTML page, for few subsequent requests chrome loads cached
scripts, but once again after sometime, once in a while it does send
request to server. There is no Disk Size issue here, Chrome has sufficient
cache space.
Problem is we get charged for every request, and I want S3 objects to be
cached forever, and should be loaded from Cache and should never connect
to server back.

back-tick in ruby does not work with tail -f command

back-tick in ruby does not work with tail -f command

#myApp.rb
`tail ls` #works fine
`tail -f filename` #does not work... why ?
The above ruby code does not print tail -f output... why ?
how to make it work ?