Search Results

Search found 1864 results on 75 pages for 'optional'.

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

  • In Django, what's the best way to handle optional url parameters from the template?

    - by Thierry Lam
    I have the following type of urls which are both valid: hello/ hello/1234/ My urls.py has the following: urlpatterns = patterns('hello.views', url(r'^$', 'index', name='index'), url(r'^(?P<user_id>\d+)/$', 'index', name='index'), ) In my views.py, when I pass user_id to the template, it defaults to 0 if not specified. My template looks like the following, I'm using namespace hello for my hello app: {% url hello:index user_id %} If user_id is not specified, the url defaults to hello/0/. The only way I can think of preventing the default 0 from showing in the url is by an if stmt: {% if user_id %} {% url hello:index user_id %} {% else %} {% url hello:index %} {% endif %} The above will give me hello/ if there are no user_id and hello/1234/ if it's present. Is the above solution the best way to solve this issue?

    Read the article

  • How to make parameters optional when using Rails named routes?

    - by Jason
    I have a named route: map.find '/find/:category/:state/:search_term/:permalink', :search_term=>nil, :controller=>'find', :action=>'show_match' and the following URL matches it & works OK: http://localhost:3000/find/cars/ca/TestSeachTerm/bumpedupphoto-test but if I take out the 2nd last parameter i.e. "TestSearchTerm", then the route fails to get matched, even though I have :search_term=nil in the route. http://localhost:3000/find/cars/ca//bumpedupphoto-test Can anyone see what I am doing wrong? Being trying to solve this for a few days now. Thanks!

    Read the article

  • Powershell advanced functions: are optional parameters supposed to get initialized?

    - by Richard Berg
    filter CountFilter($StartAt = 0) { Write-Output ($StartAt++) } function CountFunction { [CmdletBinding()] param ( [Parameter(ValueFromPipeline=$true, Mandatory=$true)] $InputObject, [Parameter(Position=0)] $StartAt = 0 ) process { Write-Output ($StartAt++) } } $fiveThings = $dir | select -first 5 # or whatever "Ok" $fiveThings | CountFilter 0 "Ok" $fiveThings | CountFilter "Ok" $fiveThings | CountFunction 0 "BUGBUG ??" $fiveThings | CountFunction I searched Connect and didn't find any known bugs that would cause this discrepancy. Anyone know if it's by design?

    Read the article

  • What is the best way to format Django urls for two parameters, either of which are optional?

    - by Parker
    I'm designing a gallery application for viewing vehicle pictures and there are two parameters: Manufacturer Vehicle type Right now you can view either, but not both. Urls go like so: /manufacturer/# /type/# Where # is an ID number. How/can I format my URLs so it can accept both? My current solution is to do: /both/#/# but this requires some retooling since the application doesn't know when you want to filter by both. Any insight would be appreciated.

    Read the article

  • Fast way to perform addition of 2 LARGE float arrays in Android. Optional JNI or Opengl ES

    - by nathan
    I simply need to add floatArray1 to floatArray2 storing the result in floatArray2.. no third array.. all arrays are one dimensional but are very large... probibly as large as the os will let me get away with. Max i would need is two float arrays with 40,000 floats each... but i could get away with 1/10th that i suppose minimum. Would love to do this in 1/30th or 1/60th of a second but that does not seem possible? Also if the code is JNI,NDK or OpenGL ES thats fine.. does android have an assembly language or like machine code i could use somehow?

    Read the article

  • Optional structural typing possibilty in C++ or anyother language?

    - by ambhai
    In C++ how to tell compiler that Ogre::Vector3 IS_SAME_AS SomeOtherLIB::Vector3 ? I feel that.. in languages like c++ which are not structural typed but there are cases when it makes sense. Normally as game developer when working with 4+ libraries that provide sort or their own Vector3 implementation. The code is littered with ToOgre, ToThis, ToThat conversion function. Thats a lot of Float3 copying around which should not happen on first place. Is in C++ or any other languages where we dont have to convert (copying) from one type to another which is essentially the samething. But any solution in C++ as most of the good gamedevs libs are for c/c++.

    Read the article

  • Optional mix of filter parameters in a search the Rails way.

    - by GSP
    I've got a simple list page with a couple of search filters status which is a simple enumeration and a test query which I want to compare against both the title and description field of my model. In my controller, I want to do something like this: def index conditions = {} conditions[:status] = params[:status] if params[:status] and !params[:status].empty? conditions[???] = ["(descr = ? or title = ?)", params[:q], params[:q]] if params[:q] and !params[:q].empty? @items = Item.find(:all, :conditions => conditions) end Unfortunately, it doesn't look like I can mix the two types of conditions (the hash and the paramatized version). Is there a "Rails Way" of doing this or do I simply have to do something awful like this: has_status = params[:status] and !params[:status].empty? has_text = params[:q] and !params[:q].empty? if has_status and !has_text # build paramatized condition with just the status elsif has_text and !has_status # build paramatized condition with just the text query elsif has_text and has_status # build paramatized condition with both else # build paramatized condition with neither end I'm migrating from Hibernate and Criteria so forgive me if I'm not thinking of this correctly... Environment: Rails 2.3.4

    Read the article

  • How to allow three optional parameters in the URL by .htaccess?

    - by eij
    I have http://example.com and a PHP routing class that checks if some URL exists. I want to make a new route, which is: http://example.com/foo/bar/123 but as long as I open it, the Apache redirects me to an error page. So I'm using a .htaccess. The code is: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) /index.php [L] and it works, as long as I use http://example.com/foo, but once I add some other parameters, it redirects me to an error. I'm guessing that the rewrite code is wrong. Is it wrong? If yes, could you suggest me the good one? If no, where the problem could be located?

    Read the article

  • Visual Studio &amp; TFS &ndash; List of addins, extensions, patches and hotfixes &ndash; Latest and Greatest

    - by terje
    This post is a list of the addins and extensions we (I ) recommend for use in Inmeta.  It’s coming up all the time – what to install, where are the download sites, etc etc, and thus I thought it better to post it here and keep it updated. The basics are Visual Studio 2010 connected to a Team Foundation Server 2010.  The edition of Visual Studio I use is the Ultimate Edition, but as many stay with the Premium Edition I’ve marked the extensions which only works with the Ultimate with a . I’ve also split the group into Recommended (which means Required) and Optional (which means Recommended) and Nice to Have (which means Optional) .   The focus is to get a setup which can be used for a complete coding experience for the whole ALM process.  The Code Gallery is found either through the Tools/Extension Manager menu in Visual Studio or through this link. The ones to really download is the Recommended category.  Then consider the Optional based on your needs.  The list of course reflects what I use for my work , so it is by no means complete, and for some of the tools there are equally useful alternatives.  The components directly associated with Visual Studio from Microsoft should be common, see the Microsoft column.     Product Available on Code Gallery Latest Version License Rec/Opt/N2H Applicable to Microsoft TFS Power Tools Sept 2010 Complete setup msi on link, split into parts on CG Sept 2010 Free Recommended TFS integration Yes Productivity Power Tools Yes 10.0.11019.3 Free Recommended Coding Yes Code Contracts No 1.4.30903 Free Recommended Coding & Quality Yes Code Contracts Editor Extensions Yes 1.4.30903 Free Recommended Coding & Quality Yes VSCommands Yes 3.6.4.1 Lite version Free (Good enough) Nice to have Coding No Power Commands Yes 1.0.2.3 Free Recommended Coding Yes FeaturePack 2   No.  MSDN Subscriber download under Visual Studio 2010 FP2 Part of MSDN Subscription Recommended Modeling & Testing Yes ReSharper No (Trial only) 5.1.1 Licensed Recommended Coding & Quality No dotTrace No 4.0.1 Licensed Optional Quality No NDepends No (Trial only) Licensed Optional Quality No tangible T4 editor Yes 1.950 Lite version Free (Good enough) Optional Coding (T4 templates) No Reflector No (Trial of Pro version only) 6.5 Lite version Free (Good enough) Recommended Coding/Investigation No LinqPad No 4.26.2 Licensed Nice to have Coding No Beyond Compare No 3.1.11 Licensed Recommended Coding/Investigation No Pex and Moles No (Moles available alone on CG) . Complete on MSDN Subscriber download under Visual Studio 2010 0.94.51023 Part of MSDN Subscription Optional Coding & Unit Testing Yes ApexSQL No Licensed Nice to have SQL No                 Some important Patches, upgrades and fixes Product Date Information Rec/Opt Applicable to Scrolling context menu KB2345133 and KB2413613 October 2010 Here Recommended Visual Studio MTM Patch October 2010 Here and here  KB2387011 Recommended (if you use MTM) MTM Data warehouse fix June 2010 Iteration dates fails with SQL 2008 R2.  KB2222312. Affects Burndown chart in Agile workbook Only for SQL 2008 R2 Server Upgrade 2008 to 2010 issue and hotfix August 2010 Fixes problems with labels and branches which are lost during upgrade. Apply before upgrade. Note: This has been fixed in the latest re-release of the TFS Server dated Aug 5th 2010. See here. Recommends downloading the latest bits. Only if upgrade from 2008 from earlier bits Server

    Read the article

  • TechDays 2010: What’s New On C# 4.0

    - by Paulo Morgado
    I would like to thank those that attended my session at TechDays 2010 and I hope that I was able to pass the message of what’s new on C#. For those that didn’t attend (or did and want to review it), the presentation can be downloaded from here. Code samples can be downlaoded from here. Here’s a list of resources mentioned on the session: The evolution of C# The Evolution Of C# Covariance and contravariance  C# 4.0: Covariance And Contravariance In Generics Covariance And Contravariance In Generics Made Easy Covarince and Contravariance in Generics Exact rules for variance validity Events get a little overhaul in C# 4, Afterward: Effective Events Named and optional arguments  Named And Optional Arguments Alternative To Optional Arguments Named and Optional Arguments (C# Programming Guide) Dynamic programming  Dynamic Programming C# Proposal: Compile Time Static Checking Of Dynamic Objects Using Type dynamic (C# Programming Guide) Dynamic Language Runtime Overview COM Interop Improvements COM Interop Improvements Type Equivalence and Embedded Interop Types Conclusion Visual C# Developer Center Visual C# 2010 Samples C# Language Specification 4.0 .NET Reflector LINQPad

    Read the article

  • How can I make an object's hitbox rotate with its texture?

    - by Matthew Optional Meehan
    In XNA, when you have a rectangular sprite that doesnt rotate, it's easy to get its four corners to make a hitbox. However, when you do a rotation, the points get moved and I assume there is some kind of math that I can use to aquire them. I am using the four points to draw a rectangle that visually represents the hitboxes. I have seen some per-pixel collision examples, but I can forsee they would be hard to draw a box/'convex hull' around. I have also seen physics like farseer but I'm not sure if there is a quick tutorial to do what I want.

    Read the article

  • Should I add parameters to instance methods that use those instance fields as parameters?

    - by john smith optional
    I have an instance method that uses instance fields in its work. I can leave the method without that parameters as they're available to me, or I can add them to the parameter list, thus making my method more "generic" and not reliable on the class. On the other hand, additional parameters will be in parameters list. Which approach is preferable and why? Edit: at the moment I don't know if my method will be public or private. Edit2: clarification: both method and fields are instance level.

    Read the article

  • What is the diffference between "data hiding" and "encapsulation"?

    - by john smith optional
    I'm reading "Java concurrency in practice" and there is said: "Fortunately, the same object-oriented techniques that help you write well-organized, maintainable classes - such as encapsulation and data hiding -can also help you crate thread-safe classes." The problem #1 - I never heard about data hiding and don't know what it is. The problem #2 - I always thought that encapsulation is using private vs public, and is actually the data hiding. Can you please explain what data hiding is and how it differs from encapsulation?

    Read the article

  • A way to return multiple return values from a method: put method inside class representing return value. Is it a good design?

    - by john smith optional
    I need to return 2 values from a method. My approach is as follows: create an inner class with 2 fields that will be used to keep those 2 values put the method inside that class instantiate the class and call the method. The only thing that will be changed in the method is that in the end it will assign those 2 values to the fields of the instance. Then I can address those values by referencing to the fields of that object. Is it a good design and why?

    Read the article

  • How to efficiently protect part of an application with a license

    - by Patrick
    I am working on an application that has many functional parts. When a customer buys the application, he buys the standard functionality, but he can also buy some additional elements of the application for an additional price. All of the elements are part of the same application executable. A license key is used to indicate which of the elements should be accessible in the application. Some of the elements can be easily disabled if the user didn't pay for it. These are typically the modules that you can access via the application's menu. However, some elements give more problems: What if a part of the data model is related to an optional part? Do I build up these data structures in my application so the rest of my application can just assume they're always there? Or do I don't build them, and add checks in the rest of may application? What if some optional part is still useful to perform some internal tasks, but I don't want to expose it to the user externally? What if the marketing responsible wants to make a standard part now an optional part? In all of my application I assume that that part is present, but if it becomes optional, I should add checks on it everywhere in the application. I have some ideas on how to solve some of the problems (e.g. interfaces with dual implementations: one working implementation, and one that is activated if the optional part is not activated). Do you know of any patterns that can be used to solve this kind of problem? Or do you have any suggestions on how to handle this licensing problem? Thanks.

    Read the article

  • When to use functional programming approach and when not? (in Java)

    - by john smith optional
    let's assume I have a task to create a Set of class names. To remove duplication of .getName() method calls for each class, I used org.apache.commons.collections.CollectionUtils and org.apache.commons.collections.Transformer as follows: Snippet 1: Set<String> myNames = new HashSet<String>(); CollectionUtils.collect( Arrays.<Class<?>>asList(My1.class, My2.class, My3.class, My4.class, My5.class), new Transformer() { public Object transform(Object o) { return ((Class<?>) o).getName(); } }, myNames); An alternative would be this code: Snippet 2: Collections.addAll(myNames, My1.class.getName(), My2.class.getName(), My3.class.getName(), My4.class.getName(), My5.class.getName()); So, when using functional programming approach is overhead and when it's not and why? Isn't my usage of functional programming approach in snippet 1 is an overhead and why?

    Read the article

  • Should I extract specific functionality into a function and why?

    - by john smith optional
    I have a large method which does 3 tasks, each of them can be extracted into a separate function. If I'll make an additional functions for each of that tasks, will it make my code better or worse and why? Edit: Obviously, it'll make less lines of code in the main function, but there'll be additional function declarations, so my class will have additional methods, which I believe isn't good, because it'll make the class more complex. Edit2: Should I do that before I wrote all the code or should I leave it until everything is done and then extract functions?

    Read the article

  • what is the easiest way to make a hitbox that rotates with it's texture

    - by Matthew Optional Meehan
    In xna when you have a sprite that doesnt rotate it's very easy to get the four corner of a sprite to make a hitbox, but when you do a rotation the points get moved and I assume there is some kind of math that I can use to aquire them. I am using the four points to draw a rectangle that visually represents the hitboxes. I have seen some per-pixel collission examples but I can forsee they would be hard to draw a box/'convex hull' around. I have also seen physics like farseer but I'm not sure if there is a quick tutorial to do what I want. What do you guys think is the best approach becuase I am looking to complete this work by the end of the week.

    Read the article

  • Saving a record in Authlogic table

    - by denniss
    I am using authlogic to do my authentication. The current model that serves as the authentication model is the user model. I want to add a "belongs to" relationship to user which means that I need a foreign key in the user table. Say the foreign key is called car_id in the user's model. However, for some reason, when I do u = User.find(1) u.car_id = 1 u.save! I get ActiveRecord::RecordInvalid: Validation failed: Password can't be blank My guess is that this has something to do with authlogic. I do not have validation on password on the user's model. This is the migration for the user's table. def self.up create_table :users do |t| t.string :email t.string :first_name t.string :last_name t.string :crypted_password t.string :password_salt t.string :persistence_token t.string :single_access_token t.string :perishable_token t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns t.timestamps end end And later I added the car_id column to it. def self.up add_column :users, :user_id, :integer end Is there anyway for me to turn off this validation?

    Read the article

  • Need to fix my regex

    - by Misha Zaslavsky
    I am trying to match a string to a regex pattern, but have some problems. My string could have 3 forms: [dbo].[Start] dbo.Start Start This is my regex: "^((\[)?dbo(\])?)?(\.)?(\[)?Start(\])?$" All 3 forms returns success but there are some more options such as: [dboStart or dbo[Start I know that this is because it is optional, but how could I make dependencies when making optional, so that if one optional has value then the second optional must have a value too. Could you help me please to fix this? Thanks.

    Read the article

  • how to use a pear package!?

    - by Naughty.Coder
    I want to use HTTP_DOWNLOAD to manage my downloads ,, I have never used PEAR before !! HTTP_DOWNLOAD depends on many other packages , I downloaded them and the ones they , in turn , depend on and this is the structure I made : Download.PHP <---HTTP_DOWNLOAD MAIN FILE Header.php <--- HTTP_HEADER MAIN FILE PEAR.php PEAR5.php Type.php <--- MIME_Type >Type <---- FOLDER - Extension.php MIME_Type File - Parameter.php MIME_Type File assuming that Http_DOWNLOAD depends on : * PHP 4.2.0 * PEAR 1.4.0b1 * PEAR * HTTP_Header * pcre extension * Archive_Tar (Optional) * Archive_Zip (Optional) * MIME_Type (Optional) * mime_magic extension (Optional) * pgsql extension (Optional) and I edited the paths inside each file to reflect this structure , and I tried to run the following code : <?php require_once 'Download.php'; $params = array('file'=>'file.zip'); $down = new HTTP_Download($params); $down->send(true); ?> nothing happens !! I also got a hard time trying to figure how to use the class and I think this code should work .. but not sure ! Help Please !

    Read the article

  • How to add complex data type from Groovy script to the response in SoapUI

    - by SeeU
    My question is about putting data elements (from groovy script) in the response in SoapUI. I've an array of data that I would like to put in my response (in different tags/elements) I'm aware of putting a simple element like this: The element "MyName" in the Xml response: <ns:MyName>${MyName}</ns:MyName> Is mapped from the Groovy script by context.setProperty("MyName" , "My name" ) Now the problem: my Xml response looks like this: <soapenv:Body> <ns:GetDataSummaryResponse> <!--Optional:--> <ns:GetDataSummaryResult> <ns:DataSummary> <!--Zero or more repetitions:--> <ns:DataSummaryResponseDetail> <ns:Name>?</ns:Name> <!--Optional:--> <ns:DataProgress> <!--Optional:--> <From>?</From> <!--Optional:--> <Procent>?</Procent> <!--Optional:--> <To>?</To> <!--Optional:--> In Groovy I've built data array which is filled with data for example like this: context:[DataSummary:[DataSummaryResponseDetail:[Name:My name, DataProgress:[From:some text, Procent:some value, To:some text]]] In the response I'm able to see the whole value of ${DataSummary} but how do I get the element "Procent" I maybe am wrong about how to build my context data, but feel free to adjust! BR/SeeU

    Read the article

  • How to submit Nothing as a route value to ASP MVC

    - by Adam
    I have a route with several optional parameters. These are possible search terms in different fields. So, for example, if I have fields key, itemtype and text then I have in global.asax: routes.MapRoute( _ "Search", _ "Admin.aspx/Search/{Key}/{ItemType}/{Text}", _ New With {.controller = "Admin", .action = "Search" .Key = Nothing, .ItemType = Nothing, .Text = Nothing} _ ) My action takes optional parameters: Function Search(Optional ByVal Key As String = Nothing, _ Optional ByVal ItemType As Integer = 0, _ Optional ByVal Text As String = Nothing, _ Optional ByVal OtherText As String = Nothing) It then checks if the Key and Text strings have a non-null (and non-empty) value and adds search terms to the db request as needed. However, is it possible to send in a null value for, for example, Key but still send in a value for Text? If so, what does the URL look like? (Admin.aspx/Search//0/Foo doesn't work :) ) I know I can handle this using a parameter array instead, but wondered if this was possible using the sort of route described? I could of course define some other value as equivalent to null (for example, a space/%20) but is there any way to send a null value in the URL? I'm suspecting not, but thought I'd see if anyone knew of one. I'm using ASP MVC 2 for this project.

    Read the article

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