Daily Archives

Articles indexed Wednesday June 4 2014

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

  • Make the player run onto stairs smoothly

    - by misiMe
    I have a 2D Platform game, where the player Always runs to the right, but the terrain isn't Always horizontal. Example: I implemented a bounding-box collision system that just checks for intersections with player box and the other blocks, to stop player from running if you encounter a big block, so that you have to jump, but when I put stairs, I want him to run smoothly just like he is on the horizontal ground. With the collision system you have to jump the stairs in order to pass them! I thought about generating a line between the edges of the stairs, and imposing the player movement on that line... What do you think? Is there something more clever to do?

    Read the article

  • Sprite animation problem

    - by hustlerinc
    I have this sprite I have to animate. The sprite is 7 images total but animation is 10 frames (2 positions are repeated). The order I want to go through the frames is like this: 3 - 4 - 5 - 6 - 4 - 3 - 2 - 1 - 0 - 2. My problem is how can I skip 1 frame once I reach the end of each direction? The reason I want to skip is to save me from creating duplicate positions in the spritesheet. I'm doing this in Javascript.

    Read the article

  • Reading variable with double float precision from a text file with gnuplot

    - by user3636322
    I have a text file, containing data in 3 columns like below: 0.0100000000 | 0.0058077299 | -0.0000000288 0.0110000000 | 0.0075128707 | -0.0000000373 0.0120000000 | 0.0093579693 | -0.0000000465 I want to get the variables from this file in gnuplot and use them to draw graphs: What I exactly do is like below (e.g: to pick the variable from row 2 column 3): ii= 2 a_0 = system("awk '{ if (NR == " . ii . ") printf \"%f\", $3}' " .datafile) a_0 = a_0+0. but what is written as a_0 is zero! How can I increase the precision to get the exact value?

    Read the article

  • php automatically commented with apache

    - by clement
    We have installed apache 2.2, and activeperl to run bugzilla, all that on a Windows Server 2003. Here We want to install PHP on the server to install a wiki. I followed those steps: tutorial to install PHP and enable it from Apache. After all those steps, I restart couples of times, and When I try a simple phpinfo() on PHP, the whole PHP code is commented: < ! - - ?php phpinfo(); ? - - Now, the httpd.conf was already edited for the PERL and it can be those edits that make the mistake. Here is the whole httpd.conf file: ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2" Listen 6969 LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule php5_module "c:/php/php5apache2_2.dll" LoadModule authn_default_module modules/mod_authn_default.so LoadModule authn_file_module modules/mod_authn_file.so LoadModule authz_default_module modules/mod_authz_default.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule cgi_module modules/mod_cgi.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so LoadModule include_module modules/mod_include.so LoadModule isapi_module modules/mod_isapi.so LoadModule log_config_module modules/mod_log_config.so LoadModule mime_module modules/mod_mime.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule setenvif_module modules/mod_setenvif.so User daemon Group daemon ServerAdmin [email protected] DocumentRoot C:/bugzilla-4.4.2/ Options FollowSymLinks AllowOverride None Order deny,allow Deny from all Options Indexes FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all ScriptInterpreterSource Registry-Strict DirectoryIndex index.html index.html.var index.cgi index.php Order allow,deny Deny from all Satisfy All ErrorLog "logs/error.log" LogLevel warn LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/" AllowOverride None Options None Order allow,deny Allow from all DefaultType text/plain AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddHandler cgi-script .cgi AddType application/x-httpd-php .php SSLRandomSeed startup builtin SSLRandomSeed connect builtin PHPIniDir "c:/php"

    Read the article

  • How to perform an event on Textbox focus in ASP MVC?

    - by NewbieProgrammer
    I have three textboxes A, B and C in create user view. When user enters some text in textbox A and B, and then when he enters textbox C, I want to display the text of textbox A + text of textbox B in C with "-" in between. For example, He enters "ABC" in textBox A and then he enters "123" in textBox B. Now upon entering textBox C (focus event), I want to display "ABC - 123 - " in textBox C. "-" are added through code. How do I do that in MVC ?

    Read the article

  • Phonegap jqm mixing local and server html files

    - by DavidVdd
    I would like to add some online pages to an application keep them up to date without releasing a new store version. For this I taught I could use jqm ajax navigation to load the external page. (I'm aware that might not be allowed for all platforms.) I have set: $.mobile.allowCrossDomainPages = true; $.mobile.pushStateEnabled = false; This seems to work but the problem is that all my href's and $.mobile.ChangePages would have to be changed to <a href='http://mydomain.com/mypage.html'>link</a> $.mobile.changePage('http://mydomain.com/mypage.html'); in stead of <a href='mypage.html'>link</a> $.mobile.changePage('http://mydomain.com/mypage.html'); I was thinking about overriding the changepage method(found this somewhere) to add a domain when the user is online, but the problem is that this method get's called more then once. var originalChangePage = $.mobile.changePage; $.mobile.changePage = function(to, options) { var o = JSON.stringify(o); try { to = to.replace('file:///android_asset/www/', 'http://mydomain.com/'); } catch (err) { //to isn't always filled in. } originalChangePage(to, options); }; Is there a better way to load html pages locally and online using jqm ajax navigation? Extra info: Phonegap/Cordova version 3.5.0 jqm 1.3.2

    Read the article

  • Issue with TagBuilder.MergeAttribute for parameter null

    - by The Yur
    I would like to use Razor's feature not to produce attribute output inside a tag in case when attribute's value is null. So when Razor meets <div class="@var" where @var is null, the output will be mere <div. I've created some Html extension method to write text inside tag. The method takes header text, level (h1..h6), and html attributes as simple object. The code is: public static MvcHtmlString WriteHeader(this HtmlHelper html, string s, int? hLevel = 1, object htmlAttributes = null) { if ((hLevel == null) || (hLevel < 1 || hLevel > 4) || (s.IsNullOrWhiteSpace())) return new MvcHtmlString(""); string cssClass = null, cssId = null, cssStyle = null; if (htmlAttributes != null) { var T = htmlAttributes.GetType(); var propInfo = T.GetProperty("class"); var o = propInfo.GetValue(htmlAttributes); cssClass = o.ToString().IsNullOrWhiteSpace() ? null : o.ToString(); propInfo = T.GetProperty("id"); o = propInfo.GetValue(htmlAttributes); cssId = o.ToString().IsNullOrWhiteSpace() ? null : o.ToString(); propInfo = T.GetProperty("style"); o = propInfo.GetValue(htmlAttributes); cssStyle = o.ToString().IsNullOrWhiteSpace() ? null : o.ToString(); } var hTag = new TagBuilder("h" + hLevel); hTag.MergeAttribute("id", cssId); hTag.MergeAttribute("class", cssClass); hTag.MergeAttribute("style", cssStyle); hTag.InnerHtml = s; return new MvcHtmlString(hTag.ToString()); } I found that in spite of null values for "class" and "style" attributes TagBuilder still puts them as empty strings, like <h1 class="" style="" But for id attribute it surprisingly works, so when id's value is null, there is no id attribute in tag. My question - is such behavior something that should actually happen? How can I achieve absent attributes with null values using TagBuilder? I tried this in VS2013, MVC 5.

    Read the article

  • Find Field In Access Table

    - by user3535895
    I need to connect to a local table in Access and find a an entry in the name field then find the id of that name. I know how to connect to access and create the connection there, but actually manipulating the table I am lost. I can use this to connect to access, but how would I access the table and find the field I am looking for? The data structure of the table I want to connect to is: name text, address text, id autonumber. System.Collections.ArrayList outside = new System.Collections.ArrayList(); System.Data.OleDb.OleDbConnection olecon = new System.Data.OleDb.OleDbConnection"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path); olecon.Open();

    Read the article

  • ngGrid reusable filter AngularJS

    - by wootscootinboogie
    I have a business requirement that I filter a boolean value in my ngGrid. The filter has three states: only true, only false and both. Filtering like this seems to be a common enough use case that I should refactor that functionality out of my code for re use (possibly in a directive/filter?). I'd like to know how I can go about pulling out the customFilter function in my controller and make it so that I can pass the filter a property name on which to filter, and a value for selectedFilterOption. The code currently works, but I feel like this is a good chance to get better at angular :). So how can I pull out my filtering used here and make it a reusable piece of functionality? app.controller('DocumentController',function($scope,DocumentService) { $scope.filterOptions = { filterText: '', useExternalFilter: false }; $scope.totalServerItems =0; $scope.pagingOptions ={ pageSizes: [5,10,100], pageSize: 5, currentPage: 1 } //filter! $scope.dropdownOptions = [{ name: 'Show all' },{ name: 'Show active' },{ name: 'Show trash' }]; //default choice for filtering is 'show active' $scope.selectedFilterOption = $scope.dropdownOptions[1]; //three stage bool filter $scope.customFilter = function(data){ var tempData = []; angular.forEach(data,function(item){ if($scope.selectedFilterOption.name === 'Show all'){ tempData.push(item); } else if($scope.selectedFilterOption.name ==='Show active' && !item.markedForDelete){ tempData.push(item); } else if($scope.selectedFilterOption.name ==='Show trash' && item.markedForDelete){ tempData.push(item); } }); return tempData; } //grabbing data $scope.getPagedDataAsync = function(pageSize, page, filterValue, searchText){ var data; if(searchText){ var ft = searchText.toLowerCase(); DocumentService.get('filterableData.json').success(function(largeLoad){ //filter the data when searching data = $scope.customFilter(largeLoad).filter(function(item){ return JSON.stringify(item).toLowerCase().indexOf(ft) != -1; }) $scope.setPagingData($scope.customFilter(data),page,pageSize); }) } else{ DocumentService.get('filterableData.json').success(function(largeLoad){ var testLargeLoad = $scope.customFilter(largeLoad); //filter the data on initial page load when no search text has been entered $scope.setPagingData(testLargeLoad,page,pageSize); }) } }; //paging $scope.setPagingData = function(data, page, pageSize){ var pagedData = data.slice((page -1) * pageSize, page * pageSize); //filter the data for paging $scope.myData = $scope.customFilter(pagedData); $scope.myData = pagedData; $scope.totalServerItems = data.length; if(!$scope.$$phase){ $scope.$apply(); } } //watch for filter option change, set the data property of gridOptions to the newly filtered data $scope.$watch('selectedFilterOption',function(){ var data = $scope.customFilter($scope.myData); $scope.myData = data; $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); $scope.setPagingData($scope.myData,$scope.pagingOptions.currentPage,$scope.pagingOptions.pageSize); }) $scope.$watch('pagingOptions',function(newVal, oldVal){ if(newVal !== oldVal && newVal.currentPage !== oldVal.currentPage){ $scope.getPagedDataAsync($scope.pagingOptions.pageSize,$scope.pagingOptions.currentPage,$scope.filterOptions.filterText); } },true) $scope.message ="This is a message"; $scope.gridOptions = { data: 'myData', enablePaging: true, showFooter:true, totalServerItems: 'totalServerItems', pagingOptions: $scope.pagingOptions, filterOptions: $scope.filterOptions, showFilter: true, enableCellEdit: true, showColumnMenu: true, enableColumnReordering: true, enablePinning: true, showGroupPanel: true, groupsCollapsedByDefault: true, enableColumnResize: true } //get the data on page load $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); }); HTML

    Read the article

  • How to set multiple permissions in one class view, depending on http request

    - by andrew13331
    How can I change the permissions depending on if it is a get or a post. Is it possible to do it in one class or would I have to separate it out into two classes? If its a get I want "permission_classes = (permissions.IsAuthenticated)" and if its a post I want "permission_classes = (permissions.IsAdminUser)" class CategoryList(generics.ListCreateAPIView): queryset = QuestionCategory.objects.all() serializer_class = QuestionCategorySerializer permission_classes = (permissions.IsAuthenticated,)

    Read the article

  • Apriori Algorithm- what to do with small min.support?

    - by user3707650
    I have a question about the table beneath my question: If i was told that the given min.support=10%, how can i know what is the support count, by which i will use during the exercise? What i know is: that you take the number of transactions (8) and multiple it by the min.support: 8*(10/100)=0.8 the problem is that i get this number: 0.8, how can i use this support count during this example?? 0.8 is a number that will make me prune all combination set that i will build... please help me!!! TID A B C D E F G 10 1 0 1 0 0 0 1 20 1 1 1 1 0 1 1 30 0 0 0 0 0 0 1 40 0 0 1 0 0 1 1 50 0 0 0 1 1 0 0 60 0 1 1 0 1 1 0 70 0 0 0 0 1 1 0 80 0 0 1 0 1 1 1

    Read the article

  • AFNetworking iOS

    - by Jeromiin
    I have a problem with a request in my app, I want to receive a json but because of the completion block my "PRINT 2" is print before my "PRINT 1" and of course my "PRINT 2" is null. I want the contrary and my "PRINT 2" to be filled but I can't manage to do it. -(void) makeConnection { NSURL *url = [NSURL URLWithString:[@"http://monsite.com/iPhonej/verifPseudo.php?login="stringByAppendingString:[_loginField.text stringByAppendingString:[@"&password=" stringByAppendingString:_passField.text]]]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFJSONResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { self.response = (NSDictionary *)responseObject; NSLog(@"PRINT 1 : %@", self.response[@"la"][@"reponse"][0][@"rep"]); [_dataLock lock]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Request Failed: %@, %@", error, error.userInfo); }]; [operation start]; } - (IBAction)logIn:(id)sender { [self makeConnection]; NSLog(@"PRINT 2 : %@", self.response[@"la"][@"reponse"][0][@"rep"]); } I know that AFNetworking is asynchronous but is there an other way to do the request and receive my json well ? Thank you

    Read the article

  • jQuery code works in Chrome, not in IE9

    - by Francis Ducharme
    Pretty new to jQuery here, I've got a chunk of code that works OK in Chrome, but fails in IE9 (have not tried FF yet). Here's the code: var textColor = $('#navmenu-body').css('color'); textColor = textColor.slice(4); In IE9, I get an error to the effect that slice can't be called because textColor is undefined. I was not sure if it's because jQuery just can't find the #navmenu-body element or that it can't find the CSS attribute color. So I did: var j = $('#navmenu-body'); var textColor = $('#navmenu-body').css('color'); textColor = textColor.slice(4); In IE9's console, j.length returns 0. So the selector is indeed, not working Here's the #navmenu-body HTML DOM <div id="navmenu-body" class="x-panel-body x-panel-body-cssmenu x-layout-fit x-panel-body-cssmenu" style="height: 398px; left: 0px; top: 0px; width: 200px;"> </div> Do I need to do something else for IE9 support ?

    Read the article

  • Stop Entity Framework from updating edmx model with a column that isn't needed

    - by TMan
    I have rowguids in all my tables to help with change tracking in all my tables. I don't want/need these tables in my edmx or my entities. However, I do still need to make changes to other things sometimes so everytime i go to update model from database in the edmx it adds all the rowguids in all my tables everytime and i have to manually delete each one. Is there a way to handle this from happening? Is there a way I can maybe edit the T4 to maybe ignore that 'rowguid' column? Database first Entity framework

    Read the article

  • Visual Basic 2013 String Replacement

    - by user3707612
    I found this code that replaces a string in a text file. But, I am trying to make it so that it replaces several strings in a text file. My.Computer.FileSystem.WriteAllText("C:\windows\PrinterList2.txt", My.Computer.FileSystem.ReadAllText("C:\windows\PrinterList.txt").Replace("IT", "ADM-IT"), False) For example, I need it to replace "IT" with "ADM-IT" and "AR" with "ADM-AR" and possibly a hundred or so more. How can I get it to loop to do them all? Running this line of code over and over just overwrites the file with the last item for replacement. Thanks in advance.

    Read the article

  • Position a div relative to a top-level container?

    - by Seifeddine Dridi
    I'm trying to model an HTML document which only contains div elements positioned in absolute. For each div, properties left and top are precalculated wrt. the top-level div, but a problem occurs with nested divs since according to the CSS standard an element is positioned relative to its first ancestral element whose positioning is either relative or absolute. Does anyone know any workaround? EDIT: small code snippet that demonstrates the problem <html> <body style="background-color: #444444"> <div style="position: relative; background-color: white;"> <div style="position: absolute; background-color: red; width: 4cm; height: 3cm; top: 1cm">div 1 <div style="position: absolute; background-color: green; top: 4cm"> div 1.1</div> </div> </div> </body> </html> The green div is expected to be positioned right after the red div, instead there is a gap of 1cm in between.

    Read the article

  • How to keep the first result of a function from Prolog?

    - by zuhakasa
    I need to write a customized function that will be called many times by other fixed functions. In this function, at the first called time, it will return the total number of lines of a file. The second called time of this function, forward, will return the number of lines in small sections of this file. My question is how I keep the first returned result(total number of lines of a file) and use it for the next called times of my function. I need to write or declare any thing only in this function(not in the caller). Something like this: myFunction(Input, MyResult, FirstResult) :- calculateInputFunction(Input, Result), !, MyResult is Result, ... . The problem is, every time myFunction is called, it receives different Input and returns different MyResult. But I would like to keep the first MyResult to use for next called times of myFunction. How can I do that? Thanks very much for your answer in advance.

    Read the article

  • Create Downloadable CSV File from PHP Script

    - by Aphex22
    How would I create a formatted version of the following PHP script as a downloadable CSV file from the code below (1.0) At the moment the fputcsv function is currently dumping the unparsed PHP/HTML code into a CSV file. This is incorrect. The downloaded CSV file should contain the columns and rows generated from the code at (1.0) as shown in the image link below. I've tried using the following code at the top of the PHP file: // output headers so that the file is downloaded rather than displayed header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=amazon.csv'); // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); $mysql_hostname = ""; $mysql_user = ""; $mysql_password = ""; $mysql_database = ""; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database"); mysql_select_db($mysql_database, $bd) or die("Could not select database"); $sql = "select * from product WHERE on_amazon = 'on' AND active = 'on'"; $result = mysql_query($sql) or die ( mysql_error() ); // loop over the rows, outputting them while ($sql_result = mysql_fetch_assoc($sql)) fputcsv($output, $sql_result); 1.0 The start of the code outputs the column headings for the CSV file: // set headers echo " item_sku, external_product_id, external_product_id_type, item_name, brand_name, manufacturer, product_description, feed_product_type, update_delete, part_number, model, standard_price, list_price, currency, quantity, product_tax_code, product_site_launch_date, merchant_release_date, restock_date ... <br>"; And then follows PHP script for the column values // load all stock while ($line = mysql_fetch_assoc($result) ) { ?> <?php $size_suffix = array ("",'_chain','_con_b','_con_c'); $arrayLength = count ($size_suffix); for($y=0;$y<$arrayLength;$y++) { //Possible size array to loop through when checking quantity $con_size = array (36,365,37,375,38,385,39,395,40,405,41,415,42,425,43,435,44,445,45,455,46,465,47,475,48,485); $arrlength=count($con_size); for($x=0;$x<$arrlength;$x++) { // check if size is available if($line['quantity_c_size_'.$con_size[$x].$size_suffix[$y]] > 0 ) { ?> <!-- item sku --> <?=$line['product_id']?>, <!-- external product id --> <?=$line['code_size_'.$con_size[$x].'']?>, <? // external product id type $barcode = $line['code_size_'.$con_size[$x]]; $trim_barcode = trim($barcode); $count = strlen($trim_barcode); if ($count == 12) { echo "UPC"; } if ($count == 13) { echo "EAN"; } elseif ($count < 12) { echo " "; } ?>, <!-- item name --> <?=$line['title']?>, <? // brand_name $brand = $line['jys_brand']; echo ucfirst($brand); ?>, <? // manufacturer $brand = $line['jys_brand']; echo ucfirst($brand); ?>, <!-- product description --> <?=preg_replace('/[^\da-z]/i', ' ', $line['amazon_desc']) ?>, <!-- feed product type --> Shoes, , , , <!-- standard price --> <?=$line['price']?>, , <!-- currency --> GBP, <!-- quantity --> <?=$line['quantity_size_'.$con_size[$x].$size_suffix[$y]]?>, , <!-- product site launch date --> <?=$line['added_y']?>-<?=$line['added_m']?>-<?=$line['added_d']?>, <!-- merchat release date --> <?=$line['added_y']?>-<?=$line['added_m']?>-<?=$line['added_d']?>, , , , , <!-- item package quantity --> 1, , , , , <!-- fulfillment latency --> 2, <!-- max aggregate ship quantity --> 1, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , <!-- main image url, url1, url2, url3 --> http://www.getashoe.co.uk/full/<?=$line['product_id']?>_1.jpg, http://www.getashoe.co.uk/full/<?=$line['product_id']?>_2.jpg, http://www.getashoe.co.uk/full/<?=$line['product_id']?>_3.jpg, http://www.getashoe.co.uk/full/<?=$line['product_id']?>_4.jpg, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , <!-- heel height --> <?=$line['heel']?>, , , , , , , , , , , <!-- colour name --> <?=$line['colour']?>, <!-- colour map --> <? $colour = preg_replace('/[()]/i', ' ', $line['colour']); if (preg_match( '/[\/].*/i', $colour)) { echo 'Multicolour'; } if (preg_match( '/off.*/i', $colour)) { echo 'Off-White'; } elseif( preg_match( '/white.*/i', $colour)) { echo 'White'; } elseif( preg_match( '/moro.*/i', $colour)) { echo 'Brown'; } elseif( preg_match( '/morado.*/i', $colour)) { echo 'Purple'; } elseif( preg_match( '/cream.*/i', $colour)) { echo 'Off-White'; } elseif( preg_match( '/pewter.*/i', $colour)) { echo 'Silver'; } elseif( preg_match( '/yellow.*/i', $colour)) { echo 'Yellow'; } elseif( preg_match( '/camel.*/i', $colour)) { echo 'Beige'; } elseif( preg_match( '/navy.*/i', $colour)) { echo 'Blue'; } elseif( preg_match( '/tan.*/i', $colour)) { echo 'Brown'; } elseif( preg_match( '/rainbow.*/i', $colour)) { echo 'Multicolour'; } elseif( preg_match( '/orange.*/i', $colour)) { echo 'Orange'; } elseif( preg_match( '/leopard.*/i', $colour)) { echo 'Multicolour'; } elseif( preg_match( '/red.*/i', $colour)) { echo 'Red'; } elseif( preg_match( '/pink.*/i', $colour)) { echo 'Pink'; } elseif( preg_match( '/purple.*/i', $colour)) { echo 'Purple'; } elseif( preg_match( '/blue.*/i', $colour)) { echo 'Blue'; } elseif( preg_match( '/green.*/i', $colour)) { echo 'Green'; } elseif( preg_match( '/brown.*/i', $colour)) { echo 'Brown'; } elseif( preg_match( '/grey.*/i', $colour)) { echo 'Grey'; } elseif( preg_match( '/black.*/i', $colour)) { echo 'Black'; } elseif( preg_match( '/gold.*/i', $colour)) { echo 'Gold'; } elseif( preg_match( '/silver.*/i', $colour)) { echo 'Silver'; } elseif( preg_match( '/multi.*/i', $colour)) { echo 'Multicolour'; } elseif( preg_match( '/beige.*/i', $colour)) { echo 'Beige'; } elseif( preg_match( '/nude.*/i', $colour)) { echo 'Beige'; } ?>, <!-- size name --> <? echo $con_size[$x];?>, <!-- size map --> <? if ($con_size[$x] == 36) { echo "3 UK"; } elseif ($con_size[$x] == 37 ) { echo "4 UK"; } elseif ($con_size[$x] == 38) { echo "5 UK"; } elseif ($con_size[$x] == 39 ) { echo "6 UK"; } elseif ($con_size[$x] == 40 ) { echo "7 UK"; } elseif ($con_size[$x] == 41) { echo "8 UK"; } elseif ($con_size[$x] == 42) { echo "9 UK"; } elseif ($con_size[$x] == 43) { echo "10 UK"; } elseif ($con_size[$x] == 44 ) { echo "11 UK"; } elseif ($con_size[$x] == 45 ) { echo "12 UK"; } elseif ($con_size[$x] == 46 ) { echo "13 UK"; } elseif ($con_size[$x] == 47 ) { echo "14 UK"; } elseif ($con_size[$x] == 48 ) { echo "15 UK"; } elseif ($con_size[$x] == 365) { echo "3.5 UK"; } elseif ($con_size[$x] == 375 ) { echo "4.5 UK"; } elseif ($con_size[$x] == 385) { echo "5.5 UK"; } elseif ($con_size[$x] == 395 ) { echo "6.5 UK"; } elseif ($con_size[$x] == 405 ) { echo "7.5 UK"; } elseif ($con_size[$x] == 415) { echo "8.5 UK"; } elseif ($con_size[$x] == 425) { echo "9.5 UK"; } elseif ($con_size[$x] == 435) { echo "10.5 UK"; } elseif ($con_size[$x] == 445 ) { echo "11.5 UK"; } elseif ($con_size[$x] == 455 ) { echo "12.5 UK"; } elseif ($con_size[$x] == 465 ) { echo "13.5 UK"; } elseif ($con_size[$x] == 475 ) { echo "14.5 UK"; } elseif ($con_size[$x] == 485 ) { echo "15.5 UK"; } ?>, <br> <? // finish checking if size is available } } } ?> I've included an image of how the CSV file should appear. https://i.imgur.com/ZU3IFer.png Any help would be great.

    Read the article

  • Have a trouble with the function roots

    - by user3707462
    Hey guys I have multiple problems with using function 'roots'. I Have to find zeros of 's^1000 + 1'. I made Y = zeros(1,1000) then manually changed the 1000th matrice to '1'. but then 'root' function does not work with it ! Another problem is that I am having trouble with matrix multiplication. The question is finding zeros(roots) of (s^6 + 6*s^5 + 15*s^4 + 20*s^3 + 15*s^2 + 6*s +1)*(s^6 + 6s^5 + 15*s^4 +15*s^2 +6*s +1) so i did: a = [1 6 15 20 15 6 1] b = [1 6 15 0 15 6 1] y = a.*b; roots(y) but this gives me -27.9355 + 0.0000i -8.2158 + 0.0000i 0.1544 + 0.9880i 0.1544 - 0.9880i -0.1217 + 0.0000i -0.0358 + 0.0000i where I calculate the original equation with wolfram then I have made matrix as : p = [1 12 66 200 375 492 524 492 375 200 66 12 1] roots(p) and this gives me : -3.1629 + 2.5046i -3.1629 - 2.5046i 0.3572 + 0.9340i 0.3572 - 0.9340i -1.0051 + 0.0000i -1.0025 + 0.0044i -1.0025 - 0.0044i -0.9975 + 0.0044i -0.9975 - 0.0044i -0.9949 + 0.0000i -0.1943 + 0.1539i -0.1943 - 0.1539i and I think the second solution is right (that is what wolfram alpha gave me) How would you answer these two questions through matlab guys?

    Read the article

  • NSLinguisticTagger on the contents of an NSTextStorage- crashing bug

    - by Remy Porter
    I'm trying to use an NSLinguisticTagger to monitor the contents of an NSTextStorage and provide some contextual information based on what the user types. To that end, I have an OverlayManager object, which wires up this relationship: -(void) setView:(NSTextView*) view { _view = view; _layout = view.layoutManager; _storage = view.layoutManager.textStorage; //get the TextStorage from the view [_tagger setString:_storage.string]; //pull the string out, this grabs the mutable version [self registerForNotificationsOn:self->_storage]; //subscribe to the willProcessEditing notification } When an edit occurs, I make sure to trap it and notify the tagger (and yes, I know I'm being annoyingly inconsistent with member access, I'm rusty on Obj-C, I'll fix it later): - (void) textStorageWillProcessEditing:(NSNotification*) notification{ if ([self->_storage editedMask] & NSTextStorageEditedCharacters) { NSRange editedRange = [self->_storage editedRange]; NSUInteger delta = [self->_storage changeInLength]; [_tagger stringEditedInRange:editedRange changeInLength:delta]; //should notify the tagger of the changes [self highlightEdits:self]; } } The highlightEdits message delegates the job out to a pool of "Overlay" objects. Each contains a block of code similar to this: [tagger enumerateTagsInRange:range scheme:NSLinguisticTagSchemeLexicalClass options:0 usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) { if (tag == PartOfSpeech) { [self applyHighlightToRange:tokenRange onStorage:storage]; } }]; And that's where the problem is- the enumerateTagsInRange method crashes out with a message: 2014-06-04 10:07:19.692 WritersEditor[40191:303] NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds This problem doesn't occur if I don't link to the mutable copy of the underlying string and instead do a [[_storage string] copy], but obviously I don't want to copy the entire backing store every time I want to do tagging. This all should be happening in the main run loop, so I don't think this is a threading issue. The NSRange I'm enumerating tags on exists both in the NSTextStorage and in the NSLinguisticTagger's view of the string. It's not even the fact that the applyHighlightToRange call adds attributes to the string, because it crashes before even reaching that line. I attempted to build a test case around the problem, but can't replicate it in those situations: - (void) testEdit { NSAttributedString* str = [[NSMutableAttributedString alloc] initWithString:@"Quickly, this is a test."]; text = [[NSTextStorage alloc] initWithAttributedString:str]; NSArray* schemes = [NSLinguisticTagger availableTagSchemesForLanguage:@"en"]; tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:schemes options:0]; [tagger setString:[text string]]; [text beginEditing]; [[text mutableString] appendString:@"T"]; NSRange edited = [text editedRange]; NSUInteger length = [text changeInLength]; [text endEditing]; [tagger stringEditedInRange:edited changeInLength:length]; [tagger enumerateTagsInRange:edited scheme:NSLinguisticTagSchemeLexicalClass options:0 usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) { //doesn't matter, this should crash }]; } That code doesn't crash.

    Read the article

  • How can i use the Orientation correct for images

    - by user3578109
    I´m learning android/java by myself @the moment and i have a problem with a part of my app i´m learning on. I made the code with help of the www and my problem is that if i open an image from the gallery it´s send to the edit activity but in the activity pictures what are made in portrait mode are displayed always wrong (90° to the right side).... The codes are Matrix private Bitmap rotateBitmapToOrientation(Bitmap b, int orientation){ Matrix matrix = new Matrix(); matrix.postRotate(orientation); Canvas offscreenCanvas = new Canvas(); offscreenCanvas.drawBitmap(b, matrix, null); return b; } and the other one @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case PICK_IMAGE_FROM_GALLERY: { if (resultCode == RESULT_OK) { Log.d(TAG, "Got Picture!"); Log.d(TAG,"File type - " + data.getType()); Uri photoUri = data.getData(); if (photoUri != null) { try { String[] filePathColumn = {MediaStore.Images.Media.DATA}; String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION}; int orientation = -1; Cursor cursor = getContentResolver().query(photoUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); cursor = getContentResolver().query(photoUri, orientationColumn, null, null, null); if(cursor != null && cursor.moveToFirst()){ orientation = cursor.getInt(cursor.getColumnIndex(orientationColumn[0])); } cursor.close(); HashMap<String, Integer> pRes = this.getImageResolutionSetting(); Bitmap shrunkenBitmap = FileUtilsHelper.shrinkBitmap(filePath, pRes.get("width"), pRes.get("height")); shrunkenBitmap = rotateBitmapToOrientation(shrunkenBitmap, orientation); String res = FileUtilsHelper.saveBitmapAsJpeg(shrunkenBitmap, this); Log.d(TAG,"File Path: " + res); shrunkenBitmap.recycle(); Intent editImage = new Intent(this, EditImage.class); editImage.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); editImage.putExtra("stuff.path", res); startActivity(editImage); }catch(Exception e){ Toast.makeText(this, R.string.cant_save_image,Toast.LENGTH_SHORT).show(); } } } } break; } }} I don´t know what i´m doing wrong... I could really need a teacher on that :) Thx for your help dudes!!

    Read the article

  • Approximate photo of a simple drawing using lines

    - by user3704596
    As an input I have a photo of a simple symbol, e.g.: https://www.dropbox.com/s/nrmsvfd0le0bkke/symbol.jpg I would like to detect the straight lines in it, like points of start and ends of the lines. In this case, assuming the top left of the symbol is (0,0), the lines would be defined like this: start end (coordinates of beginning and end of a line) 1. (0,0); (0,10) (vertical line) 2. (0,10); (15, 15) 3. (15,15); (0, 20) 4. (0,20); (0,30) How can I do it (pereferably using OpenCV)? I though about Hough lines, but they seem to be good for perfect thin straight lines, which is not the case in a drawing. I'll probably work on binarized image, too.

    Read the article

  • Cancelling BackgroundWorker While Running

    - by Nevets
    I have an application in which I launch a window that displays byte data coming in from a 3rd party tool. I have included .CancelAsync() and .CancellationPending into my code (see below) but I have another issue that I am running into. private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { Thread popupwindow = new Thread(() => test()); popupwindow.Start(); // start test script if(backgroundWorker.CancellationPending == true) { e.Cancel = true; } } private voide window_FormClosing(object sender, FormClosingEventArgs e) { try { this.backgroundWorker.CancelAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } Upon cancelling the test I get an `InvalidOperationException occurred" error from my rich text box in my pop-up window. It states that "Invoke or BeginInvoke" cannot be called on a control until the window handle has been created". I am not entirely sure what that means and would appreciate your help. LogWindow code for Rich Text Box: public void LogWindowText(LogMsgType msgtype, string msgIn) { rtbSerialNumberValue.Invoke(new EventHandler(delegate { rtbWindow.SelectedText = string.Empty; rtbWindow.SelectionFont = new Font(rtbWindow.SelectionFont, FontStyle.Bold); rtbWindow.SelectionColor = LogMsgTypeColor[(int)msgtype]; rtbWindow.AppendText(msgIn); rtbWindow.ScrollToCaret(); })); }

    Read the article

  • start javascript code with $(function, etc

    - by YAmikep
    I am studying Backbone and the todo example apps from http://todomvc.com/ I have noticed there are 3 severals ways of starting the code in the files: $(function() { // code here }); $(function( $ ) { // code here }); (function() { // code here }()); I do not understand the differences and when I should use one over the other. I also saw some people using this to start their code: $(document).ready(function(){ // code here }); From what I have seen, this is the full way of writing it right? In a more general way, should I always include my javascript code into something like that in each files? Thanks for your advice.

    Read the article

  • How to call SOAP web service in Android

    - by BobbyShaftoe
    I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with SAX. OK, that's fine, but it's 2008 so I figured there should be some good library for calling standard web services. The web service is just basically one created in NetBeans. I would like to have IDE support for generating the plumbing classes. I just need the easiest/most-elegant way to contact a WSDL based web service from an Android based phone.

    Read the article

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