Stretching background image to full size
I want to make this image as the background image of my webpage. However ,
the problem is that the image doesn't cover the whole of the page, as you
may see in this preview , and it gets repeated at the rightmost end . Is
there a way so that the image covers the whole page (be it any way ,
stretching , re-sizing , or something new).
My Code:
<!DOCTYPE HTML>
<html>
<head>
<title>Angry Birds Star Wars</title>
<script src =
"http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src = "http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
body {
background:
url('http://www.androidtapp.com/wp-content/uploads/2012/11/Angry-Birds-Star-Wars-Menu.png');
}
</style>
</head>
<body>
</body>
</html>
Thanks.
Sunday, 1 September 2013
Saturday, 31 August 2013
Multiple Inheritance in C
Multiple Inheritance in C
I am stuck with a classical Multiple Inheritance problem in C.
I have created source files Stack.c and Queue.c. Both of them #include a
file Node.c (which containing functions to allocate and deallocate
memory). Now, I am trying to implement another program in a single file,
for which I need to include both Stack.c and Queue.c. I tried to #include
both the files, but the compiler is throwing a conflicting type error.
What is the most correct way to do so?
Thanks in advance!!
I am stuck with a classical Multiple Inheritance problem in C.
I have created source files Stack.c and Queue.c. Both of them #include a
file Node.c (which containing functions to allocate and deallocate
memory). Now, I am trying to implement another program in a single file,
for which I need to include both Stack.c and Queue.c. I tried to #include
both the files, but the compiler is throwing a conflicting type error.
What is the most correct way to do so?
Thanks in advance!!
how to set seed in multiple imputation in Amelia?
how to set seed in multiple imputation in Amelia?
Every time the "Amelia" package is run, some new sets of datasets are
produced. Is there a way (such as setting seed, as is done in random
number generation) so that the produced datasets can be replicated?
Thanks.
Every time the "Amelia" package is run, some new sets of datasets are
produced. Is there a way (such as setting seed, as is done in random
number generation) so that the produced datasets can be replicated?
Thanks.
setBackGroundRGB not accepting string
setBackGroundRGB not accepting string
The class setBackgroundRGB() works if I pass it a literal
setBackgroundRGB(255,255,255);
but if I pass it a variable instead, it fails:
_Color = "255, 255, 255";
setBackgroundRGB(_Color);
Does not work and returns an error
`Cannot find method setBackgroundRGB(string)`
Do i need to do some kind of conversion here that I am not aware of?
The class setBackgroundRGB() works if I pass it a literal
setBackgroundRGB(255,255,255);
but if I pass it a variable instead, it fails:
_Color = "255, 255, 255";
setBackgroundRGB(_Color);
Does not work and returns an error
`Cannot find method setBackgroundRGB(string)`
Do i need to do some kind of conversion here that I am not aware of?
MySQL really unexpected error. BIGINT out of range
MySQL really unexpected error. BIGINT out of range
I have this kinda complicated query that is well explained in this
question. I haven't changed anything in the query or anything relating to
this system , however I suddenly started getting this error
BIGINT UNSIGNED value is out of range in '(_db.ads.impressions_total -
(cast(((curdate()) - cast(_db.ads.start as date)) as unsigned) *
_db.ads.impressions_perday))'
I'm really confused, I guess something is not caching right but what can I
do? I really need help..
I have this kinda complicated query that is well explained in this
question. I haven't changed anything in the query or anything relating to
this system , however I suddenly started getting this error
BIGINT UNSIGNED value is out of range in '(_db.ads.impressions_total -
(cast(((curdate()) - cast(_db.ads.start as date)) as unsigned) *
_db.ads.impressions_perday))'
I'm really confused, I guess something is not caching right but what can I
do? I really need help..
Asp.net and ListView Control
Asp.net and ListView Control
I am printing data using List View control. I used LinkButton in
itemtemplate. I want that column name should not be printed. What changes
i have to make?
I am printing data using List View control. I used LinkButton in
itemtemplate. I want that column name should not be printed. What changes
i have to make?
Receive an array via $resource get method
Receive an array via $resource get method
I can see the received array and params in the console.log, but I can't
echo that array to the view...
That online JSON service returns {"key": "value"}
How to make this {{some_item.key}} to work? Thanks!!
<!DOCTYPE html>
<html ng-app="Simple">
<body>
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script>
<div ng-controller="SimpleController"></div>
{{some_item.key}}
<script>
angular.module('Simple', ['ngResource']);
function SimpleController($scope, $resource) {
$scope.simple = $resource('http://echo.jsontest.com/key/value',
{callback:'JSON_CALLBACK'},
{get:{method:'JSONP'}}
);
$scope.some_item = $scope.simple.get();
console.log($scope.some_item); // gives a response array
console.log($scope.some_item.key); // undefined
}
</script>
</body>
</html>
I can see the received array and params in the console.log, but I can't
echo that array to the view...
That online JSON service returns {"key": "value"}
How to make this {{some_item.key}} to work? Thanks!!
<!DOCTYPE html>
<html ng-app="Simple">
<body>
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script>
<div ng-controller="SimpleController"></div>
{{some_item.key}}
<script>
angular.module('Simple', ['ngResource']);
function SimpleController($scope, $resource) {
$scope.simple = $resource('http://echo.jsontest.com/key/value',
{callback:'JSON_CALLBACK'},
{get:{method:'JSONP'}}
);
$scope.some_item = $scope.simple.get();
console.log($scope.some_item); // gives a response array
console.log($scope.some_item.key); // undefined
}
</script>
</body>
</html>
Friday, 30 August 2013
Database error after DeleteObject(...) / SaveChanges()
Database error after DeleteObject(...) / SaveChanges()
Context: web application / ASP.NET 4.0 / EF 4.0 / MSSQLEXPRESS2012
I'm trying to do a simple delete as follows:
if (someObject != null)
{
if (!context.IsAttached(someObject))
context.SomeObjects.Attach(someObject);
context.DeleteObject(someObject);
context.SaveChanges();
}
The code executes without problem and SaveChanges returns the expected
number of rows. But when I try to read the table afterwards it times out
(this happens in mssms as well as in code).
It also seems to corrupt other processes, returning '8501 MSDTC on server
is unavailable' and "No process is on the other end of the pipe" on
subsequent site access. Which of the three errors happens in the
application seems somewhat random, but the timeout in mssms always
happens.
Inserts and updates on the same table execute without problem.
Apart from reading through a zillion posts, I tried wrapping it in
try/catch and transaction with SaveChanges(false) and manual
AcceptAllChanges; the debugger shows the correct object just before delete
- everything appears normal until table read or accessing another page.
I'm not sure where best to look next - any ideas are greatly appreaciated!
Context: web application / ASP.NET 4.0 / EF 4.0 / MSSQLEXPRESS2012
I'm trying to do a simple delete as follows:
if (someObject != null)
{
if (!context.IsAttached(someObject))
context.SomeObjects.Attach(someObject);
context.DeleteObject(someObject);
context.SaveChanges();
}
The code executes without problem and SaveChanges returns the expected
number of rows. But when I try to read the table afterwards it times out
(this happens in mssms as well as in code).
It also seems to corrupt other processes, returning '8501 MSDTC on server
is unavailable' and "No process is on the other end of the pipe" on
subsequent site access. Which of the three errors happens in the
application seems somewhat random, but the timeout in mssms always
happens.
Inserts and updates on the same table execute without problem.
Apart from reading through a zillion posts, I tried wrapping it in
try/catch and transaction with SaveChanges(false) and manual
AcceptAllChanges; the debugger shows the correct object just before delete
- everything appears normal until table read or accessing another page.
I'm not sure where best to look next - any ideas are greatly appreaciated!
Thursday, 29 August 2013
Why does my function sometimes not execute the document.body.innerHTML command?
Why does my function sometimes not execute the document.body.innerHTML
command?
I've made a function to output data from Google Maps using the Google API.
The function is called to output from an array of places.
The problem is that sometimes it won't output the last
document.body.innerHTML part which outputs the place's URL. If I remove
the for loop which outputs the place's review aspects then the URL is
always shown.
function printme(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
document.body.innerHTML += ('<br />'+ place.name + ' R: '+ place.rating);
for (var i = 0, reviews; reviews = place.reviews[i]; i++) {
for (var x = 0, aspectr; aspectr = reviews.aspects[x]; x++) {
document.body.innerHTML += ('<br />'+'Aspect: ' + aspectr.type + ' '
+ aspectr.rating);
}
}
document.body.innerHTML += ('<br />'+ '<a href =
'+place.url+'>'+place.url+'</a>'+'<br />');
}
else {
alert(status);
}
}
I can't get my head around why that is.
command?
I've made a function to output data from Google Maps using the Google API.
The function is called to output from an array of places.
The problem is that sometimes it won't output the last
document.body.innerHTML part which outputs the place's URL. If I remove
the for loop which outputs the place's review aspects then the URL is
always shown.
function printme(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
document.body.innerHTML += ('<br />'+ place.name + ' R: '+ place.rating);
for (var i = 0, reviews; reviews = place.reviews[i]; i++) {
for (var x = 0, aspectr; aspectr = reviews.aspects[x]; x++) {
document.body.innerHTML += ('<br />'+'Aspect: ' + aspectr.type + ' '
+ aspectr.rating);
}
}
document.body.innerHTML += ('<br />'+ '<a href =
'+place.url+'>'+place.url+'</a>'+'<br />');
}
else {
alert(status);
}
}
I can't get my head around why that is.
Jquery code to print object json to normal form
Jquery code to print object json to normal form
USing jQuery code how can i print the json data
while printing the data am getting [object object]
how can i see the actual data using jquery to conver [object object]
USing jQuery code how can i print the json data
while printing the data am getting [object object]
how can i see the actual data using jquery to conver [object object]
Wednesday, 28 August 2013
Selecting for the absence of value in a one-to-many table design
Selecting for the absence of value in a one-to-many table design
I've been working all day on a problem that I expected to be simple, but
is proving incredibly elusive. I suspect I may not be asking the right
questions, so please bear with me.
I have a table with a bunch of newspaper articles for a research project.
The idea is that researchers can tag individual articles. These tags are
stored in a second table. An article can have any number of tags.
I can then select articles with a certain tag by using;
SELECT *,
GROUP_CONCAT(`TAGS`.`TAG`) AS tags
FROM ARTICLES
LEFT JOIN TAGS
ON TAGS.ID = ARTICLES.ID
WHERE TAGS.TAG = 'search term'
GROUP BY ARTICLES.ID;
My problems start when I want to select articles based on the absence of a
particular tag. If an article has only one tag, the result is as expected,
but if there is more then one tag associated with an article, the tag is
simply ommitted.
SELECT *,
GROUP_CONCAT(`TAGS`.`TAG`) AS tags
FROM ARTICLES
LEFT JOIN TAGS
ON TAGS.ID = ARTICLES.ID
WHERE TAGS.TAG != 'search term'
OR TAGS.TAG IS NULL
GROUP BY ARTICLES.ID;
if the original tables where as follows;
ID Name
1 Article #1
2 Article #2
and;
ArticleID Tag
1 New
1 Long
1 Boring
2 Old
2 Long
2 Interesting
Then if I use the above query to select articles where tag != Boring, the
results would be;
ArticleID Name Tags
1 Article #1 New, Long
2 Article #2 Old, Long, Interesting
How can I make it exclude the first article altogether, rather then just
excluding that tag? Keeping in mind that there are over a hundred thousand
articles in the database, what is the most efficient way to do this? I've
looked at dozens of other questions and google searches, but selecting for
the absence of a tag like this is something I could not find advice on.
On a sidenote, I am currently using a one-to-many table, as each tag
appears once for each article it is linked to. I noticed that a lot of
people in similar scenarios use a many-to-many design. Is this that much
faster then having just a foreign key in the tags table referencing the
article table?
Thank you for helping out an SQL noob :).
I've been working all day on a problem that I expected to be simple, but
is proving incredibly elusive. I suspect I may not be asking the right
questions, so please bear with me.
I have a table with a bunch of newspaper articles for a research project.
The idea is that researchers can tag individual articles. These tags are
stored in a second table. An article can have any number of tags.
I can then select articles with a certain tag by using;
SELECT *,
GROUP_CONCAT(`TAGS`.`TAG`) AS tags
FROM ARTICLES
LEFT JOIN TAGS
ON TAGS.ID = ARTICLES.ID
WHERE TAGS.TAG = 'search term'
GROUP BY ARTICLES.ID;
My problems start when I want to select articles based on the absence of a
particular tag. If an article has only one tag, the result is as expected,
but if there is more then one tag associated with an article, the tag is
simply ommitted.
SELECT *,
GROUP_CONCAT(`TAGS`.`TAG`) AS tags
FROM ARTICLES
LEFT JOIN TAGS
ON TAGS.ID = ARTICLES.ID
WHERE TAGS.TAG != 'search term'
OR TAGS.TAG IS NULL
GROUP BY ARTICLES.ID;
if the original tables where as follows;
ID Name
1 Article #1
2 Article #2
and;
ArticleID Tag
1 New
1 Long
1 Boring
2 Old
2 Long
2 Interesting
Then if I use the above query to select articles where tag != Boring, the
results would be;
ArticleID Name Tags
1 Article #1 New, Long
2 Article #2 Old, Long, Interesting
How can I make it exclude the first article altogether, rather then just
excluding that tag? Keeping in mind that there are over a hundred thousand
articles in the database, what is the most efficient way to do this? I've
looked at dozens of other questions and google searches, but selecting for
the absence of a tag like this is something I could not find advice on.
On a sidenote, I am currently using a one-to-many table, as each tag
appears once for each article it is linked to. I noticed that a lot of
people in similar scenarios use a many-to-many design. Is this that much
faster then having just a foreign key in the tags table referencing the
article table?
Thank you for helping out an SQL noob :).
Changing Color array to produce Red Tint in OpenGL
Changing Color array to produce Red Tint in OpenGL
I have run across some open source code for a screensaver and would like
to understand how I could modify the color array of a Color Verticies to
produce a RED tint instead of a GREEN tent
Here is the code that the author uses to set the green color:
// Compute the new state of the color vertices
- (void) computeColorVertices
{
int i,maxi,c;
GLfloat g, gstep, cursorglow;
c = 0; // To suppress spurious warning
gstep = stripParams.colorCycleSpeed;
// First, run down the strip cycling colors to bright then back to dark
g = startColor;
maxi = cursorDrawing ? cursorPos : stripSize;
for (i=0; i < maxi; i++) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 : g;
// Cells which are very bright are slightly whitened
colorArray[16*i + 4*c + 0] = ((g > 0.7) && (cellState[i] != 0)) ?
(g - 0.6) : 0.0;
colorArray[16*i + 4*c + 2] = ((g > 0.7) && (cellState[i] != 0)) ?
(g - 0.6) : 0.0;
// Transparent if cell is empty, otherwise opaque
colorArray[16*i + 4*c + 3] = (cellState[i] == 0) ? 0.0 : 1.0;
}
g += gstep;
if (g > 1.0) {
g = 0.2;
}
}
// Cycle the start color used above, to make the colors appear to fall
startColor -= stripParams.colorFallSpeed;
if (startColor < 0.2) {
startColor = 1.0;
}
// If the cursor's drawing, work up from its position making sure the
cells aren't too dark
if (cursorDrawing) {
maxi = cursorPos - 1;
cursorglow = 0.8;
for (i = maxi; i >= 0 && cursorglow > 0.2; i--) {
// If there's some cursor-imparted glow left, use it
if (colorArray[16*i + 4*c + 1] < cursorglow) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 :
cursorglow;
// Cells which are very bright are slightly whitened
colorArray[16*i + 4*c + 0] = ((cursorglow > 0.7) &&
(cellState[i] != 0)) ? (cursorglow - 0.6) : 0.0;
colorArray[16*i + 4*c + 2] = ((cursorglow > 0.7) &&
(cellState[i] != 0)) ? (cursorglow - 0.6) : 0.0;
// Transparent if cell is empty, otherwise opaque
colorArray[16*i + 4*c + 3] = (cellState[i] == 0) ? 0.0 : 1.0;
}
}
cursorglow -= gstep;
}
}
}
I have run across some open source code for a screensaver and would like
to understand how I could modify the color array of a Color Verticies to
produce a RED tint instead of a GREEN tent
Here is the code that the author uses to set the green color:
// Compute the new state of the color vertices
- (void) computeColorVertices
{
int i,maxi,c;
GLfloat g, gstep, cursorglow;
c = 0; // To suppress spurious warning
gstep = stripParams.colorCycleSpeed;
// First, run down the strip cycling colors to bright then back to dark
g = startColor;
maxi = cursorDrawing ? cursorPos : stripSize;
for (i=0; i < maxi; i++) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 : g;
// Cells which are very bright are slightly whitened
colorArray[16*i + 4*c + 0] = ((g > 0.7) && (cellState[i] != 0)) ?
(g - 0.6) : 0.0;
colorArray[16*i + 4*c + 2] = ((g > 0.7) && (cellState[i] != 0)) ?
(g - 0.6) : 0.0;
// Transparent if cell is empty, otherwise opaque
colorArray[16*i + 4*c + 3] = (cellState[i] == 0) ? 0.0 : 1.0;
}
g += gstep;
if (g > 1.0) {
g = 0.2;
}
}
// Cycle the start color used above, to make the colors appear to fall
startColor -= stripParams.colorFallSpeed;
if (startColor < 0.2) {
startColor = 1.0;
}
// If the cursor's drawing, work up from its position making sure the
cells aren't too dark
if (cursorDrawing) {
maxi = cursorPos - 1;
cursorglow = 0.8;
for (i = maxi; i >= 0 && cursorglow > 0.2; i--) {
// If there's some cursor-imparted glow left, use it
if (colorArray[16*i + 4*c + 1] < cursorglow) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 :
cursorglow;
// Cells which are very bright are slightly whitened
colorArray[16*i + 4*c + 0] = ((cursorglow > 0.7) &&
(cellState[i] != 0)) ? (cursorglow - 0.6) : 0.0;
colorArray[16*i + 4*c + 2] = ((cursorglow > 0.7) &&
(cellState[i] != 0)) ? (cursorglow - 0.6) : 0.0;
// Transparent if cell is empty, otherwise opaque
colorArray[16*i + 4*c + 3] = (cellState[i] == 0) ? 0.0 : 1.0;
}
}
cursorglow -= gstep;
}
}
}
Complicated class member construction
Complicated class member construction
Since I know that it is generally much nicer to initialize all members in
the initializer list of the constructor, I would like to know if it is
also possible to do some more complicated construction in c++ inside the
initializer list. In my program I would like to construct a class that
initializes two of it's member vectors. Since I'm using them a Lot I would
like to cache the contents, therefore I want to create the vectors at
construction.
edit The main reason I want to cache these values that I can generate the
the x and y coordinates from a circle with any radius without the need to
recompute the sin and cosine values. So I'm using n (n_samples) for the
granularity of sinx and cosy vector, which I use as lookup table
internally.
So is it possible to do the initialization inside the initializer list, in
such way that the constructor only needs to know how many samples it
should create?
Please note: While writing a short self contained question I wrote sinx
and cosy for the vectors with respectively x and y coordinates of a
circle. I could change this but then I would invalidate answers below. The
sinus of angle gives a y-coordinate and the cosine will give a x value
typically.
#include <vector>
#include <iostream>
#include <cmath>
class circular {
public:
circular( unsigned n = 20 );
/* In my actual program I do much more
* complicated stuff. And I don't want
* the user of this class to be bothered
* with polar coordinates.
*/
void print_coordinates( std::ostream& stream, double radius );
private:
unsigned number_of_samples;
std::vector<double> sinx;
std::vector<double> cosy;
};
circular::circular( unsigned n )
:
number_of_samples(n) //I would like to initialize sinx cosy here.
{
for ( unsigned i = 0; i < number_of_samples; ++i ){
sinx.push_back( std::sin( 2*M_PI / number_of_samples*i ) );
cosy.push_back( std::cos( 2*M_PI / number_of_samples*i ) );
}
}
void
circular::print_coordinates( std::ostream& stream, double r)
{
for ( unsigned i = 0; i < sinx.size(); ++i ) {
stream << "{ " <<
sinx[i] * r <<
" , " <<
cosy[i] * r <<
" } " <<
std::endl;
}
}
int main () {
circular c(20);
c.print_coordinates(std::cout, 4);
c.print_coordinates(std::cout, 5);
return 0;
}
many thanks for your effort.
Heteperfan
Since I know that it is generally much nicer to initialize all members in
the initializer list of the constructor, I would like to know if it is
also possible to do some more complicated construction in c++ inside the
initializer list. In my program I would like to construct a class that
initializes two of it's member vectors. Since I'm using them a Lot I would
like to cache the contents, therefore I want to create the vectors at
construction.
edit The main reason I want to cache these values that I can generate the
the x and y coordinates from a circle with any radius without the need to
recompute the sin and cosine values. So I'm using n (n_samples) for the
granularity of sinx and cosy vector, which I use as lookup table
internally.
So is it possible to do the initialization inside the initializer list, in
such way that the constructor only needs to know how many samples it
should create?
Please note: While writing a short self contained question I wrote sinx
and cosy for the vectors with respectively x and y coordinates of a
circle. I could change this but then I would invalidate answers below. The
sinus of angle gives a y-coordinate and the cosine will give a x value
typically.
#include <vector>
#include <iostream>
#include <cmath>
class circular {
public:
circular( unsigned n = 20 );
/* In my actual program I do much more
* complicated stuff. And I don't want
* the user of this class to be bothered
* with polar coordinates.
*/
void print_coordinates( std::ostream& stream, double radius );
private:
unsigned number_of_samples;
std::vector<double> sinx;
std::vector<double> cosy;
};
circular::circular( unsigned n )
:
number_of_samples(n) //I would like to initialize sinx cosy here.
{
for ( unsigned i = 0; i < number_of_samples; ++i ){
sinx.push_back( std::sin( 2*M_PI / number_of_samples*i ) );
cosy.push_back( std::cos( 2*M_PI / number_of_samples*i ) );
}
}
void
circular::print_coordinates( std::ostream& stream, double r)
{
for ( unsigned i = 0; i < sinx.size(); ++i ) {
stream << "{ " <<
sinx[i] * r <<
" , " <<
cosy[i] * r <<
" } " <<
std::endl;
}
}
int main () {
circular c(20);
c.print_coordinates(std::cout, 4);
c.print_coordinates(std::cout, 5);
return 0;
}
many thanks for your effort.
Heteperfan
ALAssetslibrary - Not able to return to the method the list of informations about images
ALAssetslibrary - Not able to return to the method the list of
informations about images
I have implemented a method that find the images inside the device. For do
this i'm using the ALAssetslibrary framework. I want return an NSString
object with the list of the informations about the images. I have already
found them, but unfortunately the ALAssetslibrary seems that works
asynchronously. This cause a problem. In fact, when i write "return
xmlList" it result null because probably the ALAssetslibrary doesn't have
finish yet to perform the search. How can i resolve this problem? Here
there is my working code.
-(NSString *) getPhotos{
NSMutableArray *idList = [[NSMutableArray alloc] init];
__block XMLWriter* xmlWriter = [[XMLWriter alloc]init];
__block NSString *xmlList;
__block ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
__block NSString *description = [[NSString alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index,
BOOL *stop){
if (asset){
NSString *description = [asset description];
NSRange first = [description rangeOfString:@"URLs:"];
NSRange second = [description rangeOfString:@"?id="];
NSString *path = [description substringWithRange:
NSMakeRange(first.location + first.length, second.location -
(first.location + first.length))];
[idList addObject:path];
}
}];
}
if (group == nil){
[xmlWriter writeStartDocumentWithEncodingAndVersion:@"UTF-8"
version:@"1.0"];
[xmlWriter writeStartElement:@"Data"];
int i = 0;
for(i = 0; i<=[idList count]-1; i++){
[xmlWriter writeStartElement:@"Photo"];
[xmlWriter writeAttribute:@"Id" value:[idList objectAtIndex:i]];
[xmlWriter writeEndElement:@"Photo"];
}
[xmlWriter writeEndElement:@"Data"];
[xmlWriter writeEndDocument];
xmlList = [xmlWriter toString];
NSLog(@"xml list: %@", xmlList);
}
} failureBlock:^(NSError *error) {
NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];
NSLog(@"xml list2 %@", xmlList);
return xmlList;
}
In my code you can see the line "NSLog(@"xml list: %@", xmlList);" inside
the ""if (group == nil)" block. This return the correct informations in
the log. But the last NSLog "NSLog(@"xml list2 %@", xmlList);" return
null, so it is empty. What can i do? Is there a way for add for example a
timer or something? I don't know how proceed. Thanks
informations about images
I have implemented a method that find the images inside the device. For do
this i'm using the ALAssetslibrary framework. I want return an NSString
object with the list of the informations about the images. I have already
found them, but unfortunately the ALAssetslibrary seems that works
asynchronously. This cause a problem. In fact, when i write "return
xmlList" it result null because probably the ALAssetslibrary doesn't have
finish yet to perform the search. How can i resolve this problem? Here
there is my working code.
-(NSString *) getPhotos{
NSMutableArray *idList = [[NSMutableArray alloc] init];
__block XMLWriter* xmlWriter = [[XMLWriter alloc]init];
__block NSString *xmlList;
__block ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
__block NSString *description = [[NSString alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index,
BOOL *stop){
if (asset){
NSString *description = [asset description];
NSRange first = [description rangeOfString:@"URLs:"];
NSRange second = [description rangeOfString:@"?id="];
NSString *path = [description substringWithRange:
NSMakeRange(first.location + first.length, second.location -
(first.location + first.length))];
[idList addObject:path];
}
}];
}
if (group == nil){
[xmlWriter writeStartDocumentWithEncodingAndVersion:@"UTF-8"
version:@"1.0"];
[xmlWriter writeStartElement:@"Data"];
int i = 0;
for(i = 0; i<=[idList count]-1; i++){
[xmlWriter writeStartElement:@"Photo"];
[xmlWriter writeAttribute:@"Id" value:[idList objectAtIndex:i]];
[xmlWriter writeEndElement:@"Photo"];
}
[xmlWriter writeEndElement:@"Data"];
[xmlWriter writeEndDocument];
xmlList = [xmlWriter toString];
NSLog(@"xml list: %@", xmlList);
}
} failureBlock:^(NSError *error) {
NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];
NSLog(@"xml list2 %@", xmlList);
return xmlList;
}
In my code you can see the line "NSLog(@"xml list: %@", xmlList);" inside
the ""if (group == nil)" block. This return the correct informations in
the log. But the last NSLog "NSLog(@"xml list2 %@", xmlList);" return
null, so it is empty. What can i do? Is there a way for add for example a
timer or something? I don't know how proceed. Thanks
Tuesday, 27 August 2013
Access first element of ng-repeat
Access first element of ng-repeat
How can I access the first qty and price values in each subsequent row:
"selection" in this case is variable set by some radio buttons.
<tr ng-repeat="(qty, price) in product.sizes[selection]">
<td><input type="radio"> <% qty %></td>
<td><% price %></td>
<td>You save (actual calc more complex) {{price - FIRSTROWPRICE}}</td>
</tr>
I can prevent that last row from doing the math by using $first/ng-if so
no issues for that.
Here's the data:
{
"name": "The product",
"sizes": {
"2x2": { "100": "55", "200": "80", "300": "95"},
"3x3": { "100": "155", "200": "180", "300": "195"}
}
}
And the "selection" param is selected using some radio buttons:
<form>
<div class="radio" ng-repeat="(size, data) in product.sizes">
<label>
<input type="radio" value="{{ size }}" ng-model="$parent.selection">
{{ size }}
</label>
</div>
</form>
How can I access the first qty and price values in each subsequent row:
"selection" in this case is variable set by some radio buttons.
<tr ng-repeat="(qty, price) in product.sizes[selection]">
<td><input type="radio"> <% qty %></td>
<td><% price %></td>
<td>You save (actual calc more complex) {{price - FIRSTROWPRICE}}</td>
</tr>
I can prevent that last row from doing the math by using $first/ng-if so
no issues for that.
Here's the data:
{
"name": "The product",
"sizes": {
"2x2": { "100": "55", "200": "80", "300": "95"},
"3x3": { "100": "155", "200": "180", "300": "195"}
}
}
And the "selection" param is selected using some radio buttons:
<form>
<div class="radio" ng-repeat="(size, data) in product.sizes">
<label>
<input type="radio" value="{{ size }}" ng-model="$parent.selection">
{{ size }}
</label>
</div>
</form>
Parsing url from txt file
Parsing url from txt file
I am trying to parse a txt file which looks like this:
Disallow: /cyberworld/map/ # This is an infinite virtual URL space
Disallow: /tmp/ # these will soon disappear
Disallow: /foo.html
I need to read the file and extract the part with the url after 'Disallow'
but also ignoring the comments. Thanks in advance.
I am trying to parse a txt file which looks like this:
Disallow: /cyberworld/map/ # This is an infinite virtual URL space
Disallow: /tmp/ # these will soon disappear
Disallow: /foo.html
I need to read the file and extract the part with the url after 'Disallow'
but also ignoring the comments. Thanks in advance.
node.js expose variable to module?
node.js expose variable to module?
I have read a lot of articles about how to create modules in node.js, and
you can use module.exports to expose module internals to the file which
includes it.. awesome!
How does this work the other way around? I'll use the following as an
example :-)
USER.JS
function User() {
this.property = 'value';
this.doSomething = function() {
var getStuff = mainFileFunction();
// do something with getStuff
}
module.exports = User;
MAIN.JS
var myArray = [];
myArray.push('something');
myArray.push('something else');
mainFileFunction() {
for(thing in myArray) {
return myArray[thing];
}
}
var u = new user();
log(u.property); <--- THIS IS EXPOSED, COOL!
u.doSomething(); <--- This will throw an error because mainFileFunction
is not defined in user.js :-(
If I were to move mainFileFunction to the user file, then it still
wouldn't work because the myArray array wouldn't be defined... and if I
were to move that over too, I wouldn't be able to use it in other
functions in main (which I want to) :-)
I'm sorry if I'm missing something really obvious here... What I want is
to expose the parts of my choosing from modules I include (module.export
works for that) but I also want to expose everything from the main file to
all the includes..
or just expose everything to everything? is that totally messy and horrible??
Just to explain what I am trying to do here... I want to have classes
defined in separate files, but I want to instantiate a bunch of them as
objects in the main file and store them in arrays.. I want the objects to
contain methods which can access arrays of the other object types.
Thanks guys! :-)
I have read a lot of articles about how to create modules in node.js, and
you can use module.exports to expose module internals to the file which
includes it.. awesome!
How does this work the other way around? I'll use the following as an
example :-)
USER.JS
function User() {
this.property = 'value';
this.doSomething = function() {
var getStuff = mainFileFunction();
// do something with getStuff
}
module.exports = User;
MAIN.JS
var myArray = [];
myArray.push('something');
myArray.push('something else');
mainFileFunction() {
for(thing in myArray) {
return myArray[thing];
}
}
var u = new user();
log(u.property); <--- THIS IS EXPOSED, COOL!
u.doSomething(); <--- This will throw an error because mainFileFunction
is not defined in user.js :-(
If I were to move mainFileFunction to the user file, then it still
wouldn't work because the myArray array wouldn't be defined... and if I
were to move that over too, I wouldn't be able to use it in other
functions in main (which I want to) :-)
I'm sorry if I'm missing something really obvious here... What I want is
to expose the parts of my choosing from modules I include (module.export
works for that) but I also want to expose everything from the main file to
all the includes..
or just expose everything to everything? is that totally messy and horrible??
Just to explain what I am trying to do here... I want to have classes
defined in separate files, but I want to instantiate a bunch of them as
objects in the main file and store them in arrays.. I want the objects to
contain methods which can access arrays of the other object types.
Thanks guys! :-)
What are the "dubious" GPU features mentioned here?
What are the "dubious" GPU features mentioned here?
From a history of graphics hardware:
Indeed, in the most recent hardware era, hardware makers have added
features to GPUs that have somewhat... dubious uses in the field of
graphics, but substantial uses in GPGPU tasks.
What is the author referring to here?
From a history of graphics hardware:
Indeed, in the most recent hardware era, hardware makers have added
features to GPUs that have somewhat... dubious uses in the field of
graphics, but substantial uses in GPGPU tasks.
What is the author referring to here?
Able to recover a deleted branch using git tag
Able to recover a deleted branch using git tag
I have a test repository with a master and test branch. I did make few
changes in test branch and did a tagging of the test branch. Then I
deleted the test branch (no, I did not merge with master). Surprisingly,
when I tried to checkout using the tag which I did earlier, I was able get
the test branch which I deleted earlier (of course in DETACHED HEAD state,
in "no branch"). How this is possible? Can someone help me understand
this??
I have a test repository with a master and test branch. I did make few
changes in test branch and did a tagging of the test branch. Then I
deleted the test branch (no, I did not merge with master). Surprisingly,
when I tried to checkout using the tag which I did earlier, I was able get
the test branch which I deleted earlier (of course in DETACHED HEAD state,
in "no branch"). How this is possible? Can someone help me understand
this??
Does Extjs charts capable of showing long (64 bit) values as a time stamp?
Does Extjs charts capable of showing long (64 bit) values as a time stamp?
At latest times I am dealing with Extjs charts and trying out what I can
get from it, and came to the question like is it capable of handling
long(64 bit) values as timestamps for x axis. As much as I know javascript
is not able to handle operations with long values, Anyone has such an
experience will be highly appreciated.
At latest times I am dealing with Extjs charts and trying out what I can
get from it, and came to the question like is it capable of handling
long(64 bit) values as timestamps for x axis. As much as I know javascript
is not able to handle operations with long values, Anyone has such an
experience will be highly appreciated.
Subscribe to:
Posts (Atom)