Daily Archives

Articles indexed Wednesday October 30 2013

Page 13/19 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How should I model an economy-based game in code?

    - by Matthew G.
    I'd like to create an economy game based on an ancient civilization. I'm not sure how to design it. If I were working on a smaller game, like a copy of "Space Invaders," I'd have no problem structuring it like this: Main Control Class Graphics Class Player Class Enemy class I don't understand how I'd do this for larger projects like my economy game. Do I create a country class that contains a bunch of towns? Do the towns contain a lot building class, most contain classes of people? Do I make a path finding class that the player can access to get around?

    Read the article

  • Avoiding lag when rendering Texture2D for first time

    - by Emir Lima
    I have found a similar question here, but it is about playing sounds. I am using 2048 x 2048 textures for sprite sheets and every time I call spriteBatch.Draw using a sheet for the first time in game execution, causes a considerable lag. The lag doesn't appears for the next times. Someone has faced this problem before? What can I do to overcome this? Update: I inserted a code in the end of content load routine that draws EVERY Texture2D that is loaded into ContentManager before follow to the game screen. This works well. None lag occurs when different textures are rendered over the time, EXCEPT if the IsFullScreen are changed. Apparently, changing this property makes the textures loaded in the GPU gone. Is that correct?

    Read the article

  • Strange compilation error on reference passing argument to function

    - by Grewdrewgoo Goobergabbsoen
    Here's the code: #include <iostream> using namespace std; void mysize(int &size, int size2); int main() { int *p; int val; p = &val; cout << p; mysize(&val, 20); // Error is pointed here! } void mysize(int &size, int size2) { cout << sizeof(size); size2 = size2 + 6000; cout << size2; } Here's the error output from GCC: In function 'int main()': Line 10: error: invalid initialization of non-const reference of type 'int&' from a temporary of type 'int*' compilation terminated due to -Wfatal-errors. What does that imply? I do not understand the error message ... invalid initialization of a non-constant? I declared the prototype function above with two parameters to take, one a reference of an integer and one just an integer value itself. I passed the reference of the int (see line 10), yet this error keeps being thrown at me. What is the issue?

    Read the article

  • get the list and input from one function and run them in different function

    - by rookie
    i have a programm that generate the list and then i ask them to tell me what they want to do from the menu and this is where my problem start i was able to get the input form the user to different function but when i try to use the if else condition it doesn't check, below are my code def menu(x,l): print (x) if x == 1: return make_table(l) if x == 2: y= input("enter a row (as a number) or a column (as an uppercase letter") if y in [ "1",'2','3']: print("Minmum is:",minimum(y,l)) if x== 3: print ('bye') def main(): bad_filename = True l =[] while bad_filename == True: try: filename = input("Enter the filename: ") fp = open(filename, "r") for f_line in fp: f_str=f_line.strip() f_str=f_str.split(',') for unit_str in f_str: unit=float(unit_str) l.append(unit) bad_filename = False except IOError: print("Error: The file was not found: ", filename) #print(l) condition=True while condition==True: print('1- open\n','2- maximum') x=input("Enter the choice") menu(x,l) main() from the bottom function i can get list and i can get the user input and i can get the data and move it in second function but it wont work after that.thank you

    Read the article

  • Post complex types to WebApi Client

    - by BumbleBee
    I am new to WebAPI. I have a MVC project and webApi project both reside under the **same solution**. Also, BLL Class library and DAL class library reside under the same solution. Earlier, my MVC project will talk to the BLL now I am trying to create a WebAPi project which stands in between MVC and BLL. Here is what I have come up with so far : I'm using the HTTPClient to post to a WebApi project. My post method on my controller accepts a single parameter (a model). StatsCriteria criteria = new StatsCriteria(); ...... var client = new HttpClient(); var response = client.PostAsJsonAsync("http://localhost:52765/api/reports", criteria).Result; ....... Here's the signature for my controller in Webapi [HttpPost] public CMAReportVM Reports([FromBody] StatsCriteria criteria) { var cmaReport = Service3.GetCMAReport(criteria.Mlsnums); //Create Map to enable mapping business object to View Model Mapper.CreateMap<CMAReport, CMAReportVM>(); // Maps model to VM model class var cmaVM = Mapper.Map<CMAReport, CMAReportVM>(cmaReport); reutn cmaVM; } // and here's my routing: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } I am getting the following 405 : Method not allowed. As the WebAPI and MVC project both reside under same sloution I am not sure where/how to host my webapi.

    Read the article

  • What CSS do I need to make my site more responsive?

    - by user2938757
    My site is: http://library.skybundle.com I feel like I almost have a responsive site. I did all the CSS styling myself. It is a Wordpress site but I completely edited the CSS of the original theme, so it is night-and-day different than it used to be. The original theme was mostly just for a canvas for me to work with, since I am not an expert in PHP and we wanted a Wordpress site for easy editing later on. Thanks to stackoverflow, I now have a footer that sticks to the bottom of every page and everything mostly looks good -- the way we want it anyway. The only thing missing now is the we want browser windows on MOBILE devices, such as on an iPhone, to automatically adjust the layout of the content in the body (wrapper). For example, on the main page (library.skybundle.com), I would like those two big icons two become vertically aligned as soon as the browser window sizes to a small, mostly vertical size, like that of a mobile phone. Take this site, for example: http://freedomsoundproductions.securesb.net/ This is what we would like it to do. So one a page with a sidebar, the content to the right of the sidebar should basically jump into the same "column" as the left sidebar and form one single long column. Just like in the example site above. This should all be possible via CSS. People in other forums seem to want me to use jQuery and stuff, but I can only use CSS, and I know that this must be possible without having to resort to jQuery, HTML, or other code.

    Read the article

  • not rewriting .asp files using htaccess

    - by user2939099
    I have .asp files re-writing themselves to .php files using htaccess and a rewrite rule on another site. it works fine but I am trying to do the same on my other site with one URL and it doesn't work. both have mod_rewrite enabled and on similar servers. (Apache v3.22.17 rev9999 / PHP v5.4.21) <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.+).(asp)$ $1.php [L] </IfModule> this is the full htaccess code.. can you see anything wrong with this?

    Read the article

  • jQuery tabs work in Safari and firefox but show up as bullet point in IE

    - by Ria
    I am using the jquery tabs . It shows up fine in Safari and firefox, however it will not load correct in IE. They show up as bullet points in stead of tabs. Here is an example of a page http://www.pianoandkeyboardshoponline.co.uk/Test/detailed_page.php?pro duct_id=302-Casio-CDP120-Digital-Piano-in-Black <script type="text/javascript"> $(function() { $("#jQueryTabs").tabs()({ event:"click", collapsible: false, selected:'0', fx: { opacity: 'none', duration: 1 } }).tabs( "none" , 1 , false ); }); </script> When I refresh the page the tabs show up, however I want them to show up correct when the page is loaded. Any suggestion welcome

    Read the article

  • Why is this ajax call being made even though it shouldn't be

    - by user2921557
    i have this validation script im working on but cant see why im having an issue. You can see that i have a check = false / true, check before it runs the ajax call. However, even if a field is empty and check is set to false, it is still running the call. so: // JavaScript - Update Password AJAX $(document).ready(function () { // When the form is submitted $('.updatepasswordform').submit(function () { var check = true; // Get the values var password1 = $("input[name=password1]").val(); var password2 = $("input[name=password2]").val(); var newpassword = $("input[name=newpassword]").val(); /* Password Validation */ // If fields are empty if (password1 === '') { check = false; $("input[name=password1]").css('border', 'solid 2px red'); } // If fields are empty if (password2 === '') { check = false; $("input[name=password2]").css('border', 'solid 2px red'); } // If fields are empty if (newpassword === '') { check = false; $("input[name=newpassword]").css('border', 'solid 2px red'); } if (check = true) { $.ajax({ type: "POST", url: "process/updatepassword.php", data: $(".updatepasswordform").serialize(), dataType: "json", success: function (response) { /* Checks for database validation, removed for space saving */ } }); } return false; }); });

    Read the article

  • Push html attribute to array onClick

    - by Hunkeone
    I'm trying to push number attribute of the element to the array onclick with a simple function, but array contains only empty values separated with commas. Here's html code. <button type="button" class="btn btn-success btn-lg" number="12" onclick="basket.push(this.number)">toBakset</button> <button type="button" class="btn btn-success btn-lg" number="15" onclick="basket.push(this.number)">toBakset</button> <button type="button" class="btn btn-success btn-lg" number="18" onclick="basket.push(this.number)">toBakset</button> from the start "basket" array is empty. Seems this question is so dumb but I can't find a solution :(

    Read the article

  • Google Cloud Messaging

    - by atar
    I downloaded the GCM project from git and i was able to start the server (app engine for java) and also compile the client apk on the device. On startup the device successfully registers with the server and I can see the registration id when i go to http://myserverip:8080/_ah/admin/. The problem is when i hit the 'Send Message' button there is a message 'Single message queued for registration id ' and it doesn't do anything. Below is a screenshot of the error i noticed on the terminal. Am i missing something. Any help is appreciated. Thanks. .

    Read the article

  • Delete all rows that do not have the value: Criteria 1 or Criteria 2 or Criteria 3 in Column D --> Using VBA Macro for excel

    - by JDS
    I am new to Macro's/VBA and cannot seem to figure out how to do this action for multiple criteria. I am trying to Delete all rows that do not have the value: Identify Fail or Identify Success in Column D. I write the following code and it works for one criteria "Identify Fail": '***********************************************' Sub DeleteRows() 'Action 1 --> Delete all Rows without Identify Fail in column D' Application.ScreenUpdating = False For i = Range("D" & Rows.Count).End(xlUp).Row To 1 Step -1 If Range("D" & i).Value <> "Identify Fail" Then Rows(i).Delete shift:=xlUp Next i Application.ScreenUpdating = True End Sub '***********************************************' Once I try to add 'OR' with another criteria it does not work: '***********************************************' Sub DeleteRows() 'Action 1 --> Delete all Rows without Identify Fail in column D' Application.ScreenUpdating = False For i = Range("D" & Rows.Count).End(xlUp).Row To 1 Step -1 If Range("D" & i).Value <> "Identify Fail" Or "Identify Success" Then Rows(i).Deleteshift:=xlUp Next i Application.ScreenUpdating = True End Sub '***********************************************' Any suggestions would be appreciated as I have been scouring this website and have not found an efficient code that will do the trick.

    Read the article

  • HTML/CSS - How can I position these nested unordered lists correctly?

    - by Samuroid
    I am looking for some help resolving an issue im having with positioning the following unordered list elements that are contained in a div which has relative positioning: The html structure of the UL: <div id="accountBox" class="account_settings_box"> <ul> <ul> <li class="profileImage"><img src="images/profileimage.jpg" alt="Profile Image" /></li> <li class="profileName">Your name</li> <li class="profileEmail">Your email</li> </ul> <li><a href="">Messages</a></li> <li><a href="">Settings</a></li> <li><a href="">Password</a></li> <li><a href="">Sign out</a></li> </ul> </div> and the CSS for this list: .account_settings_box ul ul { display: inline-block; margin: 0; padding: 0; width: 100%; height: 150px; outline: 1px solid blue; } .account_settings_box ul ul li { display: inline-block; border: none; /* Reset the border */ } .profileImage { float: right; display: block; width: 150px; height: 150px; outline: 1px solid purple; } .profileName, .profileEmail { width: auto; height: auto; width: 150px; height: 150px; } .account_settings_box ul ul li:hover { outline: 1px solid red; } .profileImage img { width: 150px; height: 150px; } I am having difficultly with the embedded ul, i.e, .account_settings_box ul ul element. The image below shows what it currently looks like. I am trying to achieve the follow: Have the image floating to the right, and have the "your name" and "your email" positioned to the left of the image (basically where they are currently). Thanks for your help in advance. Sam :)

    Read the article

  • Bootstrap site mobile view not using full viewport

    - by jbarnett
    I'm currently making a responsive blog using the bootstrap 3.0 framework. I'm using the 1197 Max-width container for my content and it renders fine on desktops. However, when I try opening the site on my phone (I'm using an Android Galaxy Note 2), there is a lot of extra padding on the right and left sides of the viewport. I've tried following the API docs and guides as close as possible, but still can't get this to work. Here is the site I am working on http://www.justinbar.net Does anyone know what is going on with this? Am I doing something wrong, or do I need to override default behavior (which sounds a bit hacky to me).

    Read the article

  • How to create lines with Athens?

    - by Kilon
    I have no clue how to create lines with Athens. I took a look at Cairo docs but I cant see how Athens is related to Cairo. http://zetcode.com/gfx/cairo/basicdrawing/ In the above link I cant find any equivalent for cairo_set_line_width(cr, 1); I tried to look inside Athens but is nowhere to be found. Overall I find the Athens architecture quite confusing though Cairo looks simple. Any idea how to makes this work ?

    Read the article

  • git recognizes directory as file

    - by dbarrera
    A recent issue has arised. I have my local copy of code at ~/code/ directory where I made a git init. Whenever I copied a folder with files within it, git recognized folders and files normally. But today I copied a folder and when I did a git status, git recognized hw2/ folder as a file. Additionally, I removed .git folder and reinitialized git and now every folder is recognized as file. Any ideas why this could be?

    Read the article

  • Cannot see response body in ie8 when response http status code is set to some error code(422)

    - by Deewendra Shrestha
    I am making a requset to a web service that sends custom error with proper HTTP header when I notice some validation error, this works fine in chrome and mozilla as things always do and then it broke in ie8 as it always does! After checking the network activity, I see that ie8 is not able to get response body when HTTP code is other that 200(or at-least it seems so). In groovy I am returning error like : render(status: 422, contentType: 'TEXT', text: ((errors as JSON) as String)) Is there a way I could somehow get ie8 to read in the response body, or as an alternative I might be able to set response header but before trying that I was wondering if you guys have already seen this issue and know a solution to it. Thanks, Dee

    Read the article

  • hadoop - large database query

    - by Mastergeek
    Situation: I have a Postgres DB that contains a table with several million rows and I'm trying to query all of those rows for a MapReduce job. From the research I've done on DBInputFormat, Hadoop might try and use the same query again for a new mapper and since these queries take a considerable amount of time I'd like to prevent this in one of two ways that I've thought up: 1) Limit the job to only run 1 mapper that queries the whole table and call it good. or 2) Somehow incorporate an offset in the query so that if Hadoop does try to use a new mapper it won't grab the same stuff. I feel like option (1) seems more promising, but I don't know if such a configuration is possible. Option(2) sounds nice in theory but I have no idea how I would keep track of the mappers being made and if it is at all possible to detect that and reconfigure. Help is appreciated and I'm namely looking for a way to pull all of the DB table data and not have several of the same query running because that would be a waste of time.

    Read the article

  • CRC32 calculations for png chunk doesn't match the real one

    - by user2507197
    I'm attempting to mimic the function used for creating CRC's in PNG files, I'm using the autodin II polynomial and the source code from: http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/crc32.c My tests have all been for the IHDR chunk, so my parameters have been: crc - 0xffffffff and 0 (both have been suggested) buff - the address of the IHDR Chunk's type. length - the IHDR Chunk's length + 4 (the length of the chunk's data + the length of the type) I printed the calculated CRC in binary, which I compared to the actual CRC of the chunk. I can see no similarities (little-big endian, reversed bits, XOR'd, etc). This is the data for the IHDR chunk (hexadecimal format): length(big endian): d0 00 00 00 (13) type: 49 48 44 52 data: 00 00 01 77 00 00 01 68 08 06 00 00 00 existing CRC: b0 bb 40 ac If anyone can tell me why my calculations are off, or give me a CRC32 function that will work I would greatly appreciate it. Thank-you!

    Read the article

  • django generic view update/create: update works but create raises IntegrityError

    - by smarber
    I'm using CreateView and UpdateView directely into urls.py of my application whose name is dydict. In the file forms.py I'm using ModelForm and I'm exluding a couple of fields from being shown, some of which sould be set when either creating or updating. So, as mentioned in the title, update part works but create part doesn't which is obvious because required fields that I have exluded are sent empty which is not allowed in my case. So the question here is, how should I do to fill exluded fields into the file forms.py so that I don't have to override CreateView? Thanks in advance.

    Read the article

  • Parsing ip addresses in php

    - by user2938780
    I am trying to get the number of active connections (Real Time) from a log file by IP connected and having a Play status but instead, it's giving me the total number of IP with status play. The number doesn't decrease at all. Keeps on increasing as soon as a new ip is added. How can I fix it? Here my code: $stringToParse = file_get_contents('wowzamediaserver_access.log'); preg_match_all('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $stringToParse, $matchOP); echo "Number of connections: ".sizeof(array_unique($matchOP[0])); HERE IS THE LOG: 2013-10-30 14:54:36 CET stop stream INFO 200 account1 - _defaultVHost_ account1 _definst_ 149.21 streamURL 1935 fullStreamURL IP_ADDRESS_1 http (cupertino) - 2013-10-30 14:56:12 CET play stream INFO 200 account2 - _defaultVHost_ account1 _definst_ 149.21 streamURL 1935 fullStreamURL IP_ADDRESS_2 rtmp (cupertino) - 2013-10-30 14:58:23 CET stop stream INFO 200 account2 - _defaultVHost_ account1 _definst_ 149.21 streamURL 1935 fullStreamURL IP_ADDRESS_2 rtmp (cupertino) - 2013-10-30 14:58:39 CET play stream INFO 200 account1 - _defaultVHost_ account1 _definst_ 149.21 streamURL 1935 fullStreamURL IP_ADDRESS_1 http (cupertino) - 2013-10-30 14:59:12 CET play stream INFO 200 account2 - _defaultVHost_ account1 _definst_ 149.21 streamURL 1935 fullStreamURL IP_ADDRESS_2 rtmp (cupertino) - I want to be able to count the IP whenever it has a "PLAY" status and don't count it whenever it's "STOP" 2013-10-30 14:59:00 CET play stream INFO 200 tv2vielive - _defaultVHost_ tv2vielive _definst_ 0.315 [any] 1935 rtmp://tv2vie.zion3cloud.com:1935/tv2vielive 78.247.255.186 rtmp http://www.tv2vie.org/swf/flowplayer-3.2.16.swf WIN 11,7,700,202 92565864 3576 3455 1 0 0 0 tv2vielive - - - - - rtmp://tv2vie.zion3cloud.com:1935/tv2vielive/tv2vielive rtmp://tv2vie.zion3cloud.com:1935/tv2vielive/tv2vielive - rtmp://tv2vie.zion3cloud.com:1935/tv2vielive - 2013-10-30 14:59:04 CET stop stream INFO 200 tv2vielive - _defaultVHost_ tv2vielive _definst_ 4.75 [any] 1935 rtmp://tv2vie.zion3cloud.com:1935/tv2vielive 78.247.255.186 rtmp http://www.tv2vie.org/swf/flowplayer-3.2.16.swf WIN 11,7,700,202 92565864 3576 512571 1 7222 0 503766 tv2vielive - - - - - rtmp://tv2vie.zion3cloud.com:1935/tv2vielive/tv2vielive rtmp://tv2vie.zion3cloud.com:1935/tv2vielive/tv2vielive - rtmp://tv2vie.zion3cloud.com:1935/tv2vielive - Any solutions? I have even tried the first answer solution but getting "0" play connections. $stringToParse = file_get_contents('wowzamediaserver_access.log'); $pattern = '~^.* play.* ( ([0-9]{1,3}+\.){3,3}[0-9]{1,3}).*$~m'; preg_match_all($pattern, $stringToParse, $matches); echo count($matches[1]) . ' play actions'; But whenever I use my code, I am getting "Number of connections: xxxxx(actual count of IPs). My concern is that I only need the count of IPs with PLAY status. If that IP changes to STOP then it wont count.

    Read the article

  • How to reset Scrapy parameters? (always running under same parameters)

    - by Jean Ventura
    I've been running my Scrapy project with a couple of accounts (the project scrapes a especific site that requieres login credentials), but no matter the parameters I set, it always runs with the same ones (same credentials). I'm running under virtualenv. Is there a variable or setting I'm missing? Edit: It seems that this problem is Twisted related. Even when I run: scrapy crawl -a user='user' -a password='pass' -o items.json -t json SpiderName I still get an error saying: ERROR: twisted.internet.error.ReactorNotRestartable And all the information I get, is the last 'succesful' run of the spider.

    Read the article

  • Encode_JSON Errors in Lasso 8.6.2 After Period of Time

    - by ATP_JD
    We are in the process of converting apps from Lasso 8 to Lasso 9, and as an intermediate step, have upgraded from 8.5.5 to 8.6.2 (which runs alongside 9 on our new box, in different virtual hosts). I am finding that with 8.6.2 we are getting a slew of errors on pages that call encode_json. The weird thing with these errors is that they don't start happening until some period of time after the site starts. Then, some hours later, all encode_json calls begin to fail with error messages like this: An error occurred while processing your request. Error Information Error Message: No tag, type or constant was defined under the name "?????????????????" with arguments: array: (pair: (-find)=([\x{0020}-\x{21}\x{23}-\x{5b}\x{5d}-\x{10fff}])), (r) at: onCompare with params: 'r' at: JSON with params: 'reload', -Options=array: (-Internal) at: JSON with params: @map: (reload)=(false), (tcstring)=(LZU), (timestring)=(10:42 AM&nbsp;&nbsp;&nbsp;1442Z) at: [...].lasso with params: 'pageloadtime'='1383038310' on line: 31 at position: 1 Error Code: -9948 (Yes, those Chinese(?) characters are in the error message.) I have removed the 8.5.5 encode_json tag from LassoStartup, so we are using the correct built-in method. The encode_json method fails for any and all parameters I throw at it from simple strings to arrays of maps. Upon restarting the site, encode_json resumes working for an hour or two, seemingly depending on load. On 8.5.5, we don't have this problem. Does anyone have experience with this issue? Any advice regarding trying the 8.5.5 tag swap encode_json to see if I can override the built-in method? Maybe it will work better? Thanks in advance for your time and assistance. -Justin

    Read the article

  • Trouble with Perfect Scrollbar jQuery

    - by coolpup
    I'm using the Perfect Scrollbar jQuery app (http://www.yuiazu.net/perfect-scrollbar/) for this site: http://thehummingbirdplace.com/ The scrollbar shows up when you hover over the News section, but it won't scroll down to reveal the content. I've used this scrollbar before successfully, so I'm stumped as to what is different now. I haven't been able to replicate this on a simpler page, when I experiment on another page it either works or just vanishes, so I'm not sure why it is successfully showing up, yet not scrolling on the main page. Any help would be appreciated!!

    Read the article

  • imagePickerController move and scale does not work

    - by ghostrider
    Here is my code: -(void) takePhoto { UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; //imagePickerController.editing = YES; imagePickerController.allowsEditing=YES; imagePickerController.delegate = self; [self presentViewController:imagePickerController animated:YES completion:NULL]; } #pragma mark - Image picker delegate methdos -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:NO completion:nil]; [self.Picture setImage:[info objectForKey:UIImagePickerControllerOriginalImage]]; } and I have implemented the delegates UINavigationControllerDelegate,UIImagePickerControllerDelegate The image is taken, I can see the move and scale box, but when i move it the box returns to the initial posision - likes it bounces back. Why is that?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19  | Next Page >