Daily Archives

Articles indexed Sunday June 17 2012

Page 7/15 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Victory rewards in digital CCG

    - by Nils Munch
    I am currently polishing a digital CCG where people can play against friend and random opponents in a classical Magic the Gathering-like duel CCG. I plan to award the players with 20 ingame currency units (lets call them gold) for each hour they are playing, 50 for each day they are playing and X for each victory. Now, the X is what I am trying to calculate here, since I would prefer keeping the currency to a certain value, but also with to entice the players to battle. I could go with a solid figure, say 25, for beating up an opponent. But that would result in experienced players only beating up newly started players, making the experience lame for both. I could also make a laddered tier, where you start at level 1, and raise in level as you defeat your opponents, where winning over a player awards you his level x 2 in gold. Which would you prefer if you were playing a game like this. There is no gold-based scoreboard, but the gold is used to purchase new cards along the way.

    Read the article

  • Implement Fast Inverse Square Root in Javascript?

    - by BBz
    The Fast Inverse Square Root from Quake III seems to use a floating-point trick. As I understand, floating-point representation can have some different implementations. So is it possible to implement the Fast Inverse Square Root in Javascript? Would it return the same result? float Q_rsqrt(float number) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; i = 0x5f3759df - ( i >> 1 ); y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); return y; }

    Read the article

  • Move a 2D square on y axis on android GLES2

    - by Dan
    I am trying to create a simple game for android, to start i am trying to make the square move down the y axis but the way i am doing it dosent move the square at all and i cant find any tutorials for GLES20 The on draw frame function in the render class updates the users position based on accleration dew to gravity, gets the transform matrix from the user class which is used to move the square down, then the program draws it. All that happens is that the square is drawn, no motion happens public void onDrawFrame(GL10 gl) { user.update(0.0, phy.AccelerationDewToGravity); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); // Re draws black background GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, 12, user.SquareVB);//triangleVB); GLES20.glEnableVertexAttribArray(maPositionHandle); GLES20.glUniformMatrix4fv(maPositionHandle, 1, false, user.getTransformMatrix(), 0); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); } The update function in the player class is public void update(double vh, double vv) { Vh += vh; // Increase horrzontal Velosity Vv += vv; // Increase vertical velosity //Matrix.translateM(mMMatrix, 0, (int)Vh, (int)Vv, 0); Matrix.translateM(mMMatrix, 0, mMMatrix, 0, (float)Vh, (float)Vv, 0); }

    Read the article

  • Aggro with Images

    - by Will
    I have three UIImageViews. enemy1, enemy1AggroBox and mainSprite. What I want to do is when mainSprite and enemy1AggroBox interect, I want enemy1 to start moving towards mainSprite. Basically creating aggro for a game. if(CGRectIntersectsRect(mainSprite.frame, enemy1AggroBox.frame)){ //Code here// } My plan would be to call this method in viewDidLoad. I'm not using any sort of framework like cocos2d or OpenGLES. If you need to see any more code just ask.

    Read the article

  • NSMutableArray memory leak when reloading objects

    - by Davin
    I am using Three20/TTThumbsviewcontroller to load photos. I am struggling since quite a some time now to fix memory leak in setting photosource. I am beginner in Object C & iOS memory management. Please have a look at following code and suggest any obvious mistakes or any errors in declaring and releasing variables. -- PhotoViewController.h @interface PhotoViewController : TTThumbsViewController <UIPopoverControllerDelegate,CategoryPickerDelegate,FilterPickerDelegate,UISearchBarDelegate>{ ...... NSMutableArray *_photoList; ...... @property(nonatomic,retain) NSMutableArray *photoList; -- PhotoViewController.m @implementation PhotoViewController .... @synthesize photoList; ..... - (void)LoadPhotoSource:(NSString *)query:(NSString *)title:(NSString* )stoneName{ NSLog(@"log- in loadPhotosource method"); if (photoList == nil) photoList = [[NSMutableArray alloc] init ]; [photoList removeAllObjects]; @try { sqlite3 *db; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *dbPath = [documentsPath stringByAppendingPathComponent: @"DB.s3db"]; BOOL success = [fileMgr fileExistsAtPath:dbPath]; if(!success) { NSLog(@"Cannot locate database file '%@'.", dbPath); } if(!(sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK)) { NSLog(@"An error has occured."); } NSString *_sql = query;//[NSString stringWithFormat:@"SELECT * FROM Products where CategoryId = %i",[categoryId integerValue]]; const char *sql = [_sql UTF8String]; sqlite3_stmt *sqlStatement; if(sqlite3_prepare(db, sql, -1, &sqlStatement, NULL) != SQLITE_OK) { NSLog(@"Problem with prepare statement"); } if ([stoneName length] != 0) { NSString *wildcardSearch = [NSString stringWithFormat:@"%@%%",[stoneName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; sqlite3_bind_text(sqlStatement, 1, [wildcardSearch UTF8String], -1, SQLITE_STATIC); } while (sqlite3_step(sqlStatement)==SQLITE_ROW) { NSString* urlSmallImage = @"Mahallati_NoImage.png"; NSString* urlThumbImage = @"Mahallati_NoImage.png"; NSString *designNo = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,2)]; designNo = [designNo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *desc = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,7)]; desc = [desc stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *caption = designNo;//[designNo stringByAppendingString:desc]; caption = [caption stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *smallFilePath = [documentsPath stringByAppendingPathComponent: [NSString stringWithFormat:@"Small%@.JPG",designNo] ]; smallFilePath = [smallFilePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([fileMgr fileExistsAtPath:smallFilePath]){ urlSmallImage = [NSString stringWithFormat:@"Small%@.JPG",designNo]; } NSString *thumbFilePath = [documentsPath stringByAppendingPathComponent: [NSString stringWithFormat:@"Thumb%@.JPG",designNo] ]; thumbFilePath = [thumbFilePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([fileMgr fileExistsAtPath:thumbFilePath]){ urlThumbImage = [NSString stringWithFormat:@"Thumb%@.JPG",designNo]; } NSNumber *photoProductId = [NSNumber numberWithInt:(int)sqlite3_column_int(sqlStatement, 0)]; NSNumber *photoPrice = [NSNumber numberWithInt:(int)sqlite3_column_int(sqlStatement, 6)]; char *productNo1 = sqlite3_column_text(sqlStatement, 3); NSString* productNo; if (productNo1 == NULL) productNo = nil; else productNo = [NSString stringWithUTF8String:productNo1]; Photo *jphoto = [[[Photo alloc] initWithCaption:caption urlLarge:[NSString stringWithFormat:@"documents://%@",urlSmallImage] urlSmall:[NSString stringWithFormat:@"documents://%@",urlSmallImage] urlThumb:[NSString stringWithFormat:@"documents://%@",urlThumbImage] size:CGSizeMake(123, 123) productId:photoProductId price:photoPrice description:desc designNo:designNo productNo:productNo ] autorelease]; [photoList addObject:jphoto]; [jphoto release]; } } @catch (NSException *exception) { NSLog(@"An exception occured: %@", [exception reason]); } self.photoSource = [[[MockPhotoSource alloc] initWithType:MockPhotoSourceNormal title:[NSString stringWithFormat: @"%@",title] photos: photoList photos2:nil] autorelease]; } Memory leaks happen when calling above LoadPhotosource method again with different query... I feel its something wrong in declaring NSMutableArray (photoList), but can't figure out how to fix memory leak. Any suggestion is really appreciated.

    Read the article

  • How do you enable Dialer and Mobile Data Settings?

    - by user1461959
    I have a rockchip based Android tv box with heavily modified firmware. The box does not support 3g by default and I am trying to get the mobile data connection to work. I have understood that the Phone.apk and telephony provider apk has to be installed to /system/app. The logs report that the mobile data is enabled and the the phone service is running. However there is no mobile data in Settings and the Dialer app is not shown in launcher application list. What prevents them from showing up ?

    Read the article

  • READING WEBSITE CONTENTS JAVA

    - by Sahil Manchanda
    IM DEVELOPING AN ANDROID APPLICATION WHERE in a website i PROGRAMMATICALLY submit data into search box and retrieve results by JAVA. i get the data by using URLConnect JAVA. i get the source code ie html code...... Urlconnection a = .connect to host getinputstream read data i use these functions now if the site has content like: sahil 3/5 patel chowk 965955 since these details will be inside html tags i want to extract this information . any idea

    Read the article

  • JSF: Avoid nested update calls

    - by dhroove
    I don't know if I am on right track or not still asking this question. I my JSF project I have this tree structure: <p:tree id="resourcesTree" value="#{someBean.root}" var="node" selectionMode="single" styleClass="no-border" selection="#{someBean.selectedNode}" dynamic="true"> <p:ajax listener="#{someBean.onNodeSelect}" update=":centerPanel :tableForm :tabForm" event="select" onstart="statusDialog.show();" oncomplete="statusDialog.hide();" /> <p:treeNode id="resourcesTreeNode" > <h:outputText value="#{node}" id="lblNode" /> </p:treeNode> </p:tree> I have to update this tree after I added something or delete something.. But whenever I update this still its nested update also call I mean to say it also call to update these components ":centerPanel :tableForm :tabForm"... This give me error that :tableForm not found in view because this forms load in my central panel and this tree is in my right panel.. So when I am doing some operation on tree is it not always that :tableForm is in my central panel.. (I mean design is something like this only) So now my question is that can I put some condition or there is any way so that I can specify when to update nested components also and when not.... In nut shell is there any way to update only :resoucesTree is such a way that nested updates are not called so that I can avoid error... Thanks in advance.

    Read the article

  • how to pass arguments into function within a function in r

    - by jon
    I am writing function that involve other function from base R with alot of arguments. For example (real function is much longer): myfunction <- function (dataframe, Colv = NA) { matrix <- as.matrix (dataframe) out <- heatmap(matrix, Colv = Colv) return(out) } data(mtcars) myfunction (mtcars, Colv = NA) The heatmap has many arguments that can be passed to: heatmap(x, Rowv=NULL, Colv=if(symm)"Rowv" else NULL, distfun = dist, hclustfun = hclust, reorderfun = function(d,w) reorder(d,w), add.expr, symm = FALSE, revC = identical(Colv, "Rowv"), scale=c("row", "column", "none"), na.rm = TRUE, margins = c(5, 5), ColSideColors, RowSideColors, cexRow = 0.2 + 1/log10(nr), cexCol = 0.2 + 1/log10(nc), labRow = NULL, labCol = NULL, main = NULL, xlab = NULL, ylab = NULL, keep.dendro = FALSE, verbose = getOption("verbose"), ...) I want to use these arguments without listing them inside myfun. myfunction (mtcars, Colv = NA, col = topo.colors(16)) Error in myfunction(mtcars, Colv = NA, col = topo.colors(16)) : unused argument(s) (col = topo.colors(16)) I tried the following but do not work: myfunction <- function (dataframe, Colv = NA) { matrix <- as.matrix (dataframe) out <- heatmap(matrix, Colv = Colv, ....) return(out) } data(mtcars) myfunction (mtcars, Colv = NA, col = topo.colors(16))

    Read the article

  • Time gaps between host clEnqueue_xxx calls

    - by dialer
    Consider these OpenCL calls (3 memcpy DtoH, 4313 cl_float elements each): clEnqueueReadBuffer(CommandQueue, SpectrumAbsMem, CL_FALSE, 0, SpectrumMemSize, SpectrumAbs, 0, NULL, NULL); clEnqueueReadBuffer(CommandQueue, SpectrumReMem, CL_FALSE, 0, SpectrumMemSize, SpectrumRe, 0, NULL, NULL); clEnqueueReadBuffer(CommandQueue, SpectrumImMem, CL_FALSE, 0, SpectrumMemSize, SpectrumIm, 0, NULL, NULL); When I analyze these with the NVIDIA visual profiler, I see that the actual memcpy operation only takes 8 us, but there is a significant gap of around 130 us after each memcpy. I'm already using the supposedly asynchronous method (the CL_FALSE in the argument list). When I use only one operation, but with three times the size, the operation is way faster. Why is the time gap between the actual memcpy operations so huge, whereas the gap between the kernel execution (exactly before these three operations) and the first memcpy is only 7us? Can I get rid of it, or do I need to accumulate more data before starting a memcpy? If so, is there a convenient way how I could combine mutliple arrays into a single contiguous block of memory, but still have a cl_mem object as a separate device memory pointer to each section?

    Read the article

  • Does my Dictionary must use locking mechanism?

    - by theateist
    Many threads have access to summary. Each thread will have an unique key for accessing the dictionary; Dictionary<string, List<Result>> summary; Do I need locking for following operations? summary[key] = new List<Result>() summary[key].Add(new Result()); It seems that I don't need locking because each thread will access dictionary with different key, but won't the (1) be problematic because of adding concurrently new record to dictionary with other treads?

    Read the article

  • before_save not working with Rails 3

    - by Mich Dart
    I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => { :in => ['active', 'closed'] } validates :title, :presence => true, :length => { :in => 4..30 } before_save :set_default_status_if_not_specified private def set_default_status_if_not_specified self.status = 'active' if self.status.blank? end end If I create a new object like this: Project.create!(:title => 'Test 2', :pm_id => 1) I get these errors: Validation failed: Status is not included in the list But status field should get filled in before save.

    Read the article

  • Which filter of FileSystemWatcher do I need to use for finding new files

    - by BDotA
    So far I know that FileSystemWatcher can look into a folder and if any of the files inside that folder is changed,modifies,.etc... then we can handle it. But I am not sure which filter and event I should use in my scenario: Watch for a Folder, If a file is added to that folder, do XYZ ... So In my scenario I don't care if an existing file is changed,etc..those should be ignored...only do XYZ if and only if a new file has been added to that Folder... Which event and filter do you recommended for this scenario?

    Read the article

  • Singleton & Multithreading in Java

    - by vivek jagtap
    What is the preferred way to work with Singleton class in multithreaded environment? Suppose if I have 3 thread, and all they try to access getInstance() method of singleton class at the same time - What would happen if no synchronization is maintained? Is it good practice to use synchronized getInstance() method or use synchronized block inside getInstance(). Please advise if there is any other way out.

    Read the article

  • How to generate a PDF of dynamic HTML content?

    - by chris Frisina
    I am trying to be able to allow users to generate content dynamically, and have that information be in a , and then allow that specific to be exportable to a pdf. I have got Joomla up and running (with the appropriate mySQL and ANT) locally with the Web2PDF extension, but how would I get those running on my domain (hosted by Dreamhost). Are there any other approaches you might recommend. The content is generated by JS and JQuery, and formatted with CSS and HTML. Other considerations: Web2PDF generates a PDF on the entire content, (pulling the entire page's HTML, not just the specific <div>.

    Read the article

  • I want to use blur function instead mouseup function

    - by yossi
    I have the Demo Table which I can click on the cell(td tag) and I can change the value on it.direct php DataBase. to do that I need to contain two tags.1 - span. 2 - input. like the below. <td class='Name'> <span id="spanName1" class="text" style="display: inline;"> Somevalue </span> <input type="text" value="Somevalue" class="edittd" id="inputName1" style="display: none; "> </td> to control on the data inside the cell I use in jquery .mouseup function. mouseup work but also make truble. I need to replace it with blur function but when I try to replace mouseup with blur the program thas not work becose, when I click on the cell I able to enter the input tag and I can change the value but I can't Successful to Leave the tag/field by clicking out side the table, which alow me to update the DataBase you can see that Demo with blur Here. what you advice me to do? $(".edittd").mouseup(function() { return false; }); //************* $(document).mouseup(function() { $('#span' + COLUME + ROW).show(); $('#input'+ COLUME + ROW ).hide(); VAL = $("#input" + COLUME + ROW).val(); $("#span" + COLUME + ROW).html(VAL); if(STATUS != VAL){ //******ajax code //dataString = $.trim(this.value); $.ajax({ type: "POST", dataType: 'html', url: "./public/php/ajax.php", data: 'COLUME='+COLUME+'&ROW='+ROW+'&VAL='+VAL, //{"dataString": dataString} cache: false, success: function(data) { $("#statuS").html(data); } }); //******end ajax $('#statuS').removeClass('statuSnoChange') .addClass('statuSChange'); $('#statuS').html('THERE IS CHANGE'); $('#tables').load('TableEdit2.php'); } else { //alert(DATASTRING+'status not true'); } });//End mouseup function I change it to: $(document).ready(function() { var COLUMES,COLUME,VALUE,VAL,ROWS,ROW,STATUS,DATASTRING; $('td').click(function() { COLUME = $(this).attr('class'); }); //**************** $('tr').click(function() { ROW = $(this).attr('id'); $('#display_Colume_Raw').html(COLUME+ROW); $('#span' + COLUME + ROW).hide(); $('#input'+ COLUME + ROW ).show(); STATUS = $("#input" + COLUME + ROW).val(); }); //******************** $(document).blur(function() { $('#span' + COLUME + ROW).show(); $('#input'+ COLUME + ROW ).hide(); VAL = $("#input" + COLUME + ROW).val(); $("#span" + COLUME + ROW).html(VAL); if(STATUS != VAL){ //******ajax code //dataString = $.trim(this.value); $.ajax({ type: "POST", dataType: 'html', url: "./public/php/ajax.php", data: 'COLUME='+COLUME+'&ROW='+ROW+'&VAL='+VAL, //{"dataString": dataString} cache: false, success: function(data) { $("#statuS").html(data); } }); //******end ajax $('#statuS').removeClass('statuSnoChange') .addClass('statuSChange'); $('#statuS').html('THERE IS CHANGE'); $('#tables').load('TableEdit2.php'); } else { //alert(DATASTRING+'status not true'); } });//End mouseup function $('#save').click (function(){ var input1,input2,input3,input4=""; input1 = $('#input1').attr('value'); input2 = $('#input2').attr('value'); input3 = $('#input3').attr('value'); input4 = $('#input4').attr('value'); $.ajax({ type: "POST", url: "./public/php/ajax.php", data: "input1="+ input1 +"&input2="+ input2 +"&input3="+ input3 +"&input4="+ input4, success: function(data){ $("#statuS").html(data); $('#tbl').hide(function(){$('div.success').fadeIn();}); $('#tables').load('TableEdit2.php'); } }); }); }); Thx

    Read the article

  • Python: Access members of a set

    - by emu
    Say I have a set myset of custom objects that may be equal although their references are different (a == b and a is not b). Now if I add(a) to the set, Python correctly assumes that a in myset and b in myset even though there is only len(myset) == 1 object in the set. That is clear. But is it now possible to extract the value of a somehow out from the set, using b only? Suppose that the objects are mutable and I want to change them both, having forgotten the direct reference to a. Put differently, I am looking for the myset[b] operation, which would return exactly the member a of the set. It seems to me that the type set cannot do this (faster than iterating through all its members). If so, is there at least an effective work-around?

    Read the article

  • jQuery e.stopPropagation() - how to use without breaking dropbox functionality altogether?

    - by Knut Ole
    Short story: stopPropagation() prevents a dropdown menu from closing - which is good. But it also prevents the dropbox from opening next time around - which is bad. Long story: I'm using Twitter-Bootstrap and I've put a search box inside the dropdown menu like so: <div id="search_word_menu" style="position:absolute;right:157px;top:60px;"> <ul class="nav nav-pills"> <li class="dropdown" id="menu200"> <a class="dropdown-toggle btn-inverse" data-toggle="dropdown" style="width:117px;position:relative;left:2px" href="#menu200"> <i class="icon-th-list icon-white"></i> Testing <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a href="#">Retweets</a></li> <li><a href="#">Favourites</a></li> <li class="divider"></li> <li><a href="#">A list</a></li> <li class="divider"></li> <li><a href="#">A saved search</a></li> <li><a href="#">A saved #hashtag</a></li> <li class="divider"></li> <li> <!-- HERE --> <input id="drop_search" type="text" class="search_box_in_menu" value="Search..."> </li> </ul> </li> </ul> When I click inside the searchbox, the default behaviour is obviously to close the dropdown - but that makes it rather hard to write in a search term. So I've tried with the e.stopPropagation(), which does indeed prevent the dropdown from closing. Then, when I press enter in the searchbox, I'm closing the dropdown with a .toggle() - also seems to work fine. The PROBLEM arises when I want to to it all again, because the e.stopPropagation() has now disabled the dropdown alltogether - ie. when I press the dropdown menu, it doesn't open anymore! This is because of stopPropagation(), no doubt - but how can I resolve this, so that I get the aforementioned functionality, but without breaking the rest altogether? jQuery below: $(document).ready(function() { console.log("document.ready - "); //clearing search box on click $(".search_box_in_menu").click(function(e) { e.stopPropagation(); // works for the specific task console.log(".search_box_in_menu - click."); if($(this).val() == 'Search...') { $(this).val(''); console.log(".search_box_in_menu - value removed."); }; //return false; //this is e.preventDefault() and e.stopPropagation() }); // when pressing enter key in search box $('.search_box_in_menu').keypress(function(e) { var keycode = (e.keyCode ? e.keyCode : e.which); if(keycode == '13') { console.log(".search_box_in_menu - enter-key pressed."); console.log($(this).val()); $(this).closest('.dropdown-menu').toggle(); //works } }); $('.dropdown').click(function() { console.log(".dropdown - click."); $(this).closest('.dropdown-toggle').toggle(); //does nothing }); Would greatly appreciate some help! I'm starting to suspect this might be a bootstrapped-only problem, or at least caused by their implementation - but it's beyond me atm.

    Read the article

  • web.xml : URL mapping

    - by Devashish Dixit
    I have these two lines in my web.xml <url-pattern>/</url-pattern> : Index Servletand <url-pattern>/login</url-pattern> : Login Servlet but whem I open http://localhost:8084/login/, it goes to Index Servlet and when I open http://localhost:8084/login, it goes to Login Servlet. Is there any difference in http://localhost:8084/login/ and http://localhost:8084/login? My web.xml <servlet> <servlet-name>Index</servlet-name> <servlet-class>Index</servlet-class> </servlet> <servlet> <servlet-name>Login</servlet-name> <servlet-class>Login</servlet-class> </servlet> and <servlet-mapping> <servlet-name>Index</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Login</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping>

    Read the article

  • thrust::unique_by_key eating up last element

    - by Programmer
    Please consider the below simple code: thrust::device_vector<int> positions(6); thrust::sequence(positions.begin(), positions.end()); thrust::pair<thrust::device_vector<int>::iterator, thrust::device_vector<int>::iterator > end; //copyListOfNgramCounteachdoc contains: 0,1,1,1,1,3 end.first = copyListOfNgramCounteachdoc.begin(); end.second = positions.begin(); for(int i =0 ; i < numDocs; i++){ end= thrust::unique_by_key(end.first, end.first + 3,end.second); } int length = end.first - copyListOfNgramCounteachdoc.begin() ; cout<<"the value of end -s is: "<<length; for(int i =0 ; i< length ; i++){ cout<<copyListOfNgramCounteachdoc[i]; } I expected the output to be 0,1,1,3 of this code; however, the output is 0,1,1. Can anyone let me know what I am missing? Note: the contents of copyListOfNgramCounteachdoc is 0,1,1,1,1,3 . Also the type of copyListOfNgramCounteachdoc is thrust::device_vector<int>.

    Read the article

  • The rightCalloutAccessory button is not shown

    - by Luca
    I try to manage annotations, and to display an info button on the right of the view when a PIN get selected, my relevant code is this: - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenPin"]; if ([annotation isKindOfClass:[ManageAnnotations class]]) { static NSString* identifier = @"ManageAnnotations"; MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; if (newAnnotation==nil) { newAnnotation=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; }else { newAnnotation.annotation=annotation; } newAnnotation.pinColor = MKPinAnnotationColorGreen; newAnnotation.animatesDrop = YES; newAnnotation.canShowCallout = YES; newAnnotation.rightCalloutAccessoryView=[UIButton buttonWithType:UIButtonTypeInfoLight]; return newAnnotation; }else { newAnnotation.pinColor = MKPinAnnotationColorGreen; newAnnotation.animatesDrop = YES; newAnnotation.canShowCallout = YES; return newAnnotation; } ManageAnnotations.m : @implementation ManageAnnotations @synthesize pinColor; @synthesize storeName=_storeName; @synthesize storeAdress=_storeAdress; @synthesize coordinate=_coordinate; -(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate{ if((self=[super init])){ _storeName=[storeName copy]; _storeAdress=[storeAdress copy]; _coordinate=coordinate; } return self; } -(NSString*)title{ return _storeName; } -(NSString*)subtitle{ return _storeAdress; } ManageAnnotations.h @interface ManageAnnotations : NSObject<MKAnnotation>{ NSString *_storeName; NSString *_storeAdress; CLLocationCoordinate2D _coordinate; } // @property(nonatomic,assign)MKPinAnnotationColor pinColor; @property(nonatomic, readonly, copy)NSString *storeName; @property(nonatomic, readonly, copy)NSString *storeAdress; @property(nonatomic,readonly)CLLocationCoordinate2D coordinate; // -(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate; // The PINS are shown correctly on the Map, but without the info button on the right of the view. Am i missing something?

    Read the article

  • Issue with loading background image using CSS

    - by Geethanga Amarasinghe
    Im using following CSS to set a background-image for my menu #menuContainer { background:url('../images/main-bg.png') repeat-x; } My CSS is inside ~/styles/site.css and my image is inside ~/images/main-bg.png The problem is this works perfectly in Chrome but it's not working in Firefox. But if change the URL to #menuContainer { background:url('images/main-bg.png') repeat-x; } It starts working in Firefox and in Chrome it doesn't work. Can anyone please help?

    Read the article

  • How to export user inputs (from python) to excel worksheet?

    - by mrn
    I am trying to develop a user form in python 2.7.3. Please note that I am a python beginner. I am trying to use xlwt to export data to excel. I want to write values of following variables i.e. a (value to write:'x1') & d (value to write: be user defined information in text box), a=StringVar() checkBox1=Checkbutton(root, text="text1", variable=a, onvalue="x1", offvalue="N/A") checkBox1.place(relx=0., rely=0., relwidth=0., relheight=0.) checkBox1.pack() d=StringVar() atextBox1=Entry(root, textvariable=d, font = '{MS Sans Serif} 10') atextBox1.pack() Need help badly. Thank you so much in advance

    Read the article

  • Why calling Process.killProcess(Process.myPid()) is a bad idea?

    - by Tal Kanel
    I've read some posts saying using this method is "not good", shouldn't been use, it's not the right way to "close" the application and it's not how android works... I understand and accept the fact that Android OS knows better then me when it's the right time to terminate the process, but I didn't heard yet a good explanation why it's wrong using the killProcess() method?. after all - it's part of the android API... what I do know is that calling this method while other threads doing in potential an important work (operations on files, writing to DB, HTTP requests, running services..) can be terminated in the middle, and it's clearly not good. also I know I can benefit from the fact that "re-open" the application will be faster, cause the system maybe still "holds" in memory state from last time been used, and killProcess() prevents that. beside this reason, in assumption I don't have such operations, and I don't care my application will load from scratch each run, there are other reasons why not using the killProcess() method? I know about finish() method to close an Activity, so don't write me about that please.. finish() is only for Activity. not to all application, and I think I know exactly why and when to use it... and another thing - I'm developing also games with the Unity3D framework, and exporting the project to android. when I decompiled the generated apk, I was very suprised to find out that the java source code created from unity - implementing Unity's - Application.quit() method, with Process.killProcess(Process.myPid()). Application.quit() is suppose to be the right way to close game according to Unity3d guides (is it really?? maybe I'm wrong, and missed something), so how it happens that the Unity's framework developers which doing a very good work as it seems implemented this in native android to killProcess()? anyway - I wish to have a "list of reasons" why not using the killProcess() method, so please write down your answer - if you have something interesting to say about that. TIA

    Read the article

  • Shuffle array variables in a pre-specified order, without using extra memory of "size of input array"

    - by Eternal Learner
    Input : A[4] = {0,4,-1,1000} - Actual Array P[4] = {1,0,3,2} - Order to be reshuffled Output: A[4] = {4,0,1000,-1} Condition : Don't use an additional array as memory. Can use an extra variable or two. Problem : I have the below program in C++, but this fails for certain inputs of array P. #include<iostream> using namespace std; void swap(int *a_r,int *r) { int temp = *r; *r = *a_r; *a_r = temp; } int main() { int A[4] = {0,4,-1,1000}; int P[4] = {3,0,1,2}; int value = A[0] , dest = P[0]; for(int i=0; i<4;i++) { swap(&A[dest],&value); dest = P[dest]; } for(int i=0;i<4;i++) cout<<A[i]<<" "; }

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >