Search Results

Search found 4538 results on 182 pages for 'rules'.

Page 15/182 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Common optimization rules

    - by mafutrct
    This is a dangerous question, so let me try to phrase it correctly. Premature optimization is the root of all evil, but if you know you need it, there is a basic set of rules that should be considered. This set is what I'm wondering about. For instance, imagine you got a list of a few thousand items. How do you look up an item with a specific, unique ID? Of course, you simply use a Dictionary to map the ID to the item. And if you know that there is a setting stored in a database that is required all the time, you simply cache it instead of issuing a database request hundred times a second. I guess there are a few even more basic ideas. I am specifically not looking for "don't do it, for experts: don't do it yet" or "use a profiler" answers, but for really simple, general hints. If you feel this is an argumentative question, you probably misunderstood my intention.

    Read the article

  • Using different validation rules based on user input.

    - by chiefanov
    I have a simple form: a combobox and a textbox. My combobox has 2 values: A and B. When value A is selected I want textbox to use a validation rule. When value B is selected there should be no validation rules applied to the textbox. I've read an article that has a solution and I'm trying to use it, but had no luck so far, and I think there might be a more elegant solution. Has anyone done anything like this before? Any ideas are highly appreciated.

    Read the article

  • Need help converting apache .htaccess code to lighttpd url_rewrite code

    - by miCRoSCoPiC_eaRthLinG
    Hi All, I have this custom written CMS built on XAMPP. I'm trying to test the same on lighttpd to benchmark the so-called performance gains... but am stuck at the rewrite rules. I use the default rewrite rules of WordPress in my .htaccess which hands all url parsing over to my script as long as there aren't any files or directories same as the URL structure. Here's the code: RewriteBase /somedir/ # Let the Script handle all pretty URLs RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule .* index.php [L] Can anyone please help me translate the same to the lighttpd format? I could only (partially) figure out the last line myself going through the lighty docs ... i.e. url.rewrite-once = ( ".*" => "index.php" ) But that of course won't suffice... All my CMS is doing is giving me 404's. Thanks, miCRoSCoPiC^eaRthLinG

    Read the article

  • How do I prevent libvirt from adding iptables rules for guest NAT networks?

    - by Jack Douglas
    Similar to this old request on BugZilla for Fedora 8, I'm hoping something has changed since then or someone knows another way. I want to manage the iptables rules by hand—the one-size-fits-all automatic rules don't suit me at all. These rules seem to be added and removed when a network is started and destroyed. Is there a way of either preventing these rules being added at all or hooking a script into the network start that restores the default rules afterwards. For now, I'm using a very crude method with cron, but I hope there is a better way: * * * * * root iptables-restore < /etc/sysconfig/iptables

    Read the article

  • Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

    - by Kyle Brandt
    How can I become an expert at writing mod_rewrite rules? What is the fundamental format and structure of mod_rewrite rules? What form/flavor of regular expressions do I need to have a solid grasp of? What are the most common mistakes/pitfalls when writing rewrite rules? What is a good method for testing and verifying mod_rewrite rules? Are there SEO or performance implications of mod_rewrite rules I should be aware of? Are there common situations where mod_rewrite might seem like the right tool for the job but isn't? What are some common examples?

    Read the article

  • Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

    - by Kyle Brandt
    How can I become an expert at writing mod_rewrite rules? What is the fundamental format and structure of mod_rewrite rules? What form/flavor of regular expressions do I need to have a solid grasp of? What are the most common mistakes/pitfalls when writing rewrite rules? What is a good method for testing and verifying mod_rewrite rules? Are there SEO or performance implications of mod_rewrite rules I should be aware of? Are there common situations where mod_rewrite might seem like the right tool for the job but isn't? What are some common examples?

    Read the article

  • ANTLR AST rules fail with RewriteEmptyStreamException

    - by Barry Brown
    I have a simple grammar: grammar sample; options { output = AST; } assignment : IDENT ':=' expr ';' ; expr : factor ('*' factor)* ; factor : primary ('+' primary)* ; primary : NUM | '(' expr ')' ; IDENT : ('a'..'z')+ ; NUM : ('0'..'9')+ ; WS : (' '|'\n'|'\t'|'\r')+ {$channel=HIDDEN;} ; Now I want to add some rewrite rules to generate an AST. From what I've read online and in the Language Patterns book, I should be able to modify the grammar like this: assignment : IDENT ':=' expr ';' -> ^(':=' IDENT expr) ; expr : factor ('*' factor)* -> ^('*' factor+) ; factor : primary ('+' primary)* -> ^('+' primary+) ; primary : NUM | '(' expr ')' -> ^(expr) ; But it does not work. Although it compiles fine, when I run the parser I get a RewriteEmptyStreamException error. Here's where things get weird. If I define the pseudo tokens ADD and MULT and use them instead of the tree node literals, it works without error. tokens { ADD; MULT; } expr : factor ('*' factor)* -> ^(MULT factor+) ; factor : primary ('+' primary)* -> ^(ADD primary+) ; Alternatively, if I use the node suffix notation, it also appears to work fine: expr : factor ('*'^ factor)* ; factor : primary ('+'^ primary)* ; Is this discrepancy in behavior a bug?

    Read the article

  • How do you keep your business rules DRY?

    - by Mario
    I periodically ponder how to best design an application whose every business rule exists in just a single location. (While I know there is no proverbial “best way” and that designs are situational, people must have a leaning toward one practice or another.) I work for a shop where they prefer to house as much of the business rules as possible in the database. This requires developers in many cases to perform identical front-end validations to avoid sending data to the database that will result in an exception—not very DRY. It grates me anytime I find myself duplicating any kind of logic—even lowly validation logic. I am a single-point-of-truth purist to an anal degree. On the other end of the spectrum, I know of shops that create dumb databases (the Rails community leans in this direction) and handle all of the business logic in a separate tier (in Rails the models would house “most” of this). Note the word “most” which implies that some business logic does end up spilling into other places (in Rails it might spill over into the controllers). In way, a clean separation of concerns where all business logic exists in a single core location is a Utopian fantasy that’s hard to uphold (n-tiered architecture or not). Furthermore, is see the “Database as a fortress” and would agree that it should be built on constraints that cause it to reject bad data. As such, I hold principles that cause a degree of angst as I attempt to balance them. How do you balance the database-as-a-fortress view with the desire to have a single-point-of-truth?

    Read the article

  • Nested URLs and Rewrite rules in Apache2

    - by Radha Krishna. S.
    Hi, I need some help with rewrite rules and nested URLs. I am using TikiWiki for my website and am in the process of setting up SE friendly URLs for my projects. Specifically, I have the following rewrite rule for www.example.com/projects to point to a page that lists out all the projects hosted in example. RewriteRule ^Projects$ articles?type=Project [L] This works fine. Now, I would like to point www.example.com/projects/project1 to point to a specific project. I have this rewrite rule RewriteRule ^(Projects/Project1)$ tiki-read_article.php?articleId=6 This works, but partially. The content is all rendered as text but the theme - images/ css etc all go for a toss - the page is completely in text. I understand that this happens 'cause the relative paths in the theme/ css/ images all refer to Projects as the base folder instead of the root of the website. I don't want to touch the CMS portion - change the theme/ css/ image paths in the files, more for reasons of upgradability. Can someone help me understand and write a rule so that the above nested URL works? Regards, Radha

    Read the article

  • Changing CSS Rules using JavaScript or jQuery

    - by Praveen Kumar
    Initial Research I am aware of using .css() to get and set the CSS rules of a particular element. I have seen a website with this CSS: body, table td, select { font-family: Arial Unicode MS, Arial, sans-serif; font-size: small; } I never liked Arial Unicode as a font. Well, that was my personal feel. So, I would use Chrome's Style Inspector to edit the Arial Unicode MS to Segoe UI or something which I like. Is there anyway, other than using the following to achieve the same? Case I $("body, table td, select").css("font-family", "Segoe UI"); Recursive, performance intensive. Doesn't work when things are loaded on the fly. Case II $('<style>body, table td, select {font-famnily: "Segoe UI";}</style>') .appendTo("head"); Any other better method than this? Creates a lot of <style> tags!

    Read the article

  • Practical rules for premature optimization

    - by DougW
    It seems that the phrase "Premature Optimization" is the buzz-word of the day. For some reason, iphone programmers in particular seem to think of avoiding premature optimization as a pro-active goal, rather than the natural result of simply avoiding distraction. The problem is, the term is beginning to be applied more and more to cases that are completely inappropriate. For example, I've seen a growing number of people say not to worry about the complexity of an algorithm, because that's premature optimization (eg http://stackoverflow.com/questions/2190275/help-sorting-an-nsarray-across-two-properties-with-nssortdescriptor/2191720#2191720). Frankly, I think this is just laziness, and appalling to disciplined computer science. But it has occurred to me that maybe considering the complexity and performance of algorithms is going the way of assembly loop unrolling, and other optimization techniques that are now considered unnecessary. What do you think? Are we at the point now where deciding between an O(n^n) and O(n!) complexity algorithm is irrelevant? What about O(n) vs O(n*n)? What do you consider "premature optimization"? What practical rules do you use to consciously or unconsciously avoid it? This is a bit vague, but I'm curious to hear other peoples' opinions on the topic.

    Read the article

  • Add/remove validation rules Dynamically

    - by eddy
    Hi, I need to dynamically add validation rules to a text box when the user clicks on the checkbox in that row and remove it when the user unchecks it. This is what I did, and it works fine, but I'm not sure if it is the right way to do it. Here's my html code: <tbody> <c:forEach items="${list}" var="item"> <tr> <td align="center"> <input type="checkbox" name="selectItems" value="<c:out value="${item.numberPlate}"/>" /> </td> <td align="left"><c:out value="${item.numberPlate}"/></td> <td align="left"><c:out value="${item.driver.fullName}"/></td> <td align="left"><input type="text" name="mileage_<c:out value="${item.numberPlate}"/>" value="" /></td> </tr> </c:forEach> </tbody> and my jquery: $("input[name=selectItems]").change(function() { if (this.checked) { $(this).closest("tr").find("input[name^=mileage]").attr("class","required"); $(this).closest("tr").find("input[name^=mileage]").attr("number",true); } else { $(this).closest("tr").find("input[name^=mileage]").attr("class","") } }); any suggestion is welcome and... I almost forgot, Merry Xmas!

    Read the article

  • IIS 6.0 Rewrite rules for Wordpress (Forward slash not working and other things)

    - by DigitalBlade
    Hi, I am using Wordpress 3.0.4 on IIS 6.0 and Windows Server 2003, hosted by a company. I was having lots of issues using permalinks. I have fixed most, but now I have an issue with a forward-slash not being added to the address. This would be fine on most websites, but not on IIS for some reason. Specifically, if I go to "mysite.com/wp-admin" I can log-in and get to the dashboard, but as soon as I click anything there i am redirected to a broken link. For example: "mysite.com/post-new.php". If I add the slash at the end it's fine. So I tried to have a rewrite rule to automatically add the slash to such address: RewriteRule /wp-admin /wp-admin/ [L] But it still doesn't work. For your reference, here's the complete file: [ISAPI_Rewrite] RewriteBase / RewriteCond ${REQUEST_FILENAME} !-f RewriteCond ${REQUEST_FILENAME} !-d # For special WordPress folders (e.g. theme, admin, etc.) RewriteRule /wp-admin /wp-admin/ [L] RewriteRule /wp-(.*) /wp-$1 [L] RewriteRule /(.*\.(?:jpg|jpeg|gif|css|txt|xml|html|png|js)) /$1 [I,L] # Rules to ensure that normal content gets through RewriteRule /images/(.*) /images/$1 [L] RewriteRule /favicon.ico /favicon.ico [L] RewriteRule /robots.txt /robots.txt [L] RewriteRule /phpmyadmin/(.*) /phpmyadmin/$1 [L] RewriteRule /phpmyadmin /phpmyadmin/ [L] # For all WordPress pages RewriteRule ^/$ /index.php [L] RewriteRule /(.*) /index.php/$1 [L] Any ideas? Thanks in advance

    Read the article

  • Filtering a collection based on filtering rules

    - by Mike
    I have an observable collection of Entities, with each entity having a status added, deleted, modified and cancelled. I have four buttons (toggle) when clicked should filter my collection as below: If I select the button Added, then my collection should contain entities with status added. If I select the button Deleted and Added, then my collection should contain entities with status Deleted AND entities with status Added, none of the rest. If I select the button Deleted,Added and Modified, then my collection should contain entities with status Deleted, Added AND Modified. . . so on. If I unselect one of the buttons, it should remove those entities from the collection with that status. For example if I unselect Deleted, but select Added and Modified, then my collection should contain items with Added and Modified status and NOT Deleted ones. For implementing this I have created a master collection and a filtered collection. The Filter collection gets filtered based on the selections and unselections. The following is my code: private bool _clickedAdded; public bool ClickedAdded { get { return _clickedAdded; } set { _clickedAdded = value; if(!_clickedAdded) FilterAny(typeof(Added)); } } private bool _clickedDeleted; public bool ClickedDeleted { get { return _clickedDeleted; } set { _clickedDeleted = value; if (!_clickedDeleted) FilterAny(typeof(Deleted)); } } private bool _clickedModified; public bool ClickedModified { get { return _clickedModified; } set { _clickedModified = value; if (!_clickedModified) FilterAny(typeof(Modified)); } } private void FilterAny(Type status) { Func<Entity, bool> predicate = entity => entity.Status.GetType() != status; var filteredItems = MasterEntites.Where(predicate); FilteredEntities = new ObservableCollection<Entity>(filteredItems); } This however breaks the above rules - for example if I have all selected, and then I remove Added followed by deleted then it still shows the list of Added, Modified and Cancelled. It should be just Modified and Cancelled in the filtered collection. Can you please help me in solving this issue? Also do I need 2 different list to solve this. Please note that I'm using .NET 3.5.

    Read the article

  • dynamically bound elements don't subscribe to CSS rules

    - by user961627
    I'm using ajax to dynamically populate a menu. The problem is the dynamically created elements do not follow the CSS rules, although they're created with the right classname. This is surprising. Here's my HTML: <div id='menu1'> <ul class='menu'> <?php $sql = /// /* some sql string, which works */ $result = mysql_query($sql); while($row = mysql_fetch_array( $result )) { $prod_id = $row['product_id']; $prod_name = $row['product_name']; echo "<li data-title='$prod_id' class='menu1_item'>".$prod_name."</li> "; } ?> </ul> </div> <div id='menu2'> <ul class='menu'> </ul> </div> <div id='menu3'> <ul class='menu'> </ul> </div> Here's my jquery: $(".menu1_item").click( function() { $.ajax({ type: "POST", data: { m: '2', id: $(this).attr('data-title') }, url: "fetch_designs.php", success: function(msg){ if (msg != ''){ $("#menu2").html(msg).show(); $(".menu2_item").bind('click',function() { $.ajax({ type: "POST", data: { m: '3', id: $(this).attr('data-title') }, url: "fetch_designs.php", success: function(msg){ if (msg != ''){ $("#menu3").html(msg).show(); } } }); //end menu2 click }); //end if } //end success } }); //end menu1 click }); My CSS is as follows: ul.menu li { cursor:pointer; list-style: none; } #menu1, #menu2, #menu3 { margin:50px; position:relative; display:block; float:left; } .menu1-item .menu2-item .menu3-item { padding:4px; background-color:lightgray; color:black; cursor:pointer; }

    Read the article

  • ASP.NET MVC 2 client-side validation rules not being created

    - by Brant Bobby
    MVC isn't generating the client-side validation rules for my viewmodel. The HTML just contains this: <script type="text/javascript"> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({"Fields":[],"FormId":"form0","ReplaceValidationSummary":false}); //]]> </script> Note that Fields[] is empty! My view is strongly-typed and uses the new strongly-typed HTML helpers (TextBoxFor(), etc). View Model / Domain Model public class ItemFormViewModel { public Item Item { get; set; } [Required] [StringLength(100)] public string Whatever { get; set; } // for demo } [MetadataType(typeof(ItemMetadata))] public class Item { public string Name { get; set; } public string SKU { get; set; } public int QuantityRequired { get; set; } // etc. } public class ItemMetadata { [Required] [StringLength(100)] public string Name { get; set; } [Required] [StringLength(50)] public string SKU { get; set; } [Range(0, Int32.MaxValue)] public int QuantityRequired { get; set; } // etc. } (I know I'm using a domain model as my / as part of my view model, which isn't a good practice, but disregard that for now.) View <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ItemFormViewModel>" %> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Editing item: <%= Html.Encode(Model.Item.Name) %></h2> <% Html.EnableClientValidation(); %> <%= Html.ValidationSummary("Could not save the item.") %> <% using (Html.BeginForm()) { %> <%= Html.TextBoxFor(model => model.Item.Name) %> <%= Html.TextBoxFor(model => model.Item.SKU) %> <%= Html.TextBoxFor(model => model.Item.QuantityRequired) %> <%= Html.HiddenFor(model => model.Item.ItemID) %> <%= Html.TextBox("Whatever", Model.Whatever) %> <input type="submit" value="Save" /> <% } %> </asp:Content> I included the Whatever property on the view model because I suspected that MVC wasn't recursively inspecting the sub-properties of ItemFormViewModel.Item, but even that isn't being validated? I've even tried delving into the MVC framework source code but have come up empty. What could be going on?

    Read the article

  • Data Structures for Logic Games / Deduction Rules / Sufficient Set of Clues?

    - by taserian
    I've been cogitating about developing a logic game similar to Einstein's Puzzle , which would have different sets of clues for every new game replay. What data structures would you use to handle the different entities (pets, colors of houses, nationalities, etc.), deduction rules, etc. to guarantee that the clues you provide point to a unique solution? I'm having a hard time thinking about how to get the deduction rules to play along with the possible clues; any insight would be appreciated.

    Read the article

  • ISA Server 2006 SP1 :: Allow unauthenticated users (non domain users) access to external (internet)

    - by Klaptrap
    Now that we have applied an internal to external rule blocking all users access to the internet, other than those users in a whitelist, we have the obvious issue of non authenticated users, not on our domain, i.e.; domain-less guests not being able to access the internet. Other than configuring each machine to use our alternative gateway - which would require a member of IT to be onsite everytime a guest arrives - can this be done through ISA adn AD?

    Read the article

  • Outlook Rule for forwarding and bouncing ?

    - by Outlook User
    In order to consolidate all my email, I wanted to forward all my Gmail(2 accounts) to a new Live(Hotmail) account. I wanted all email arriving at my Gmail account to be forwarded to my Hotmail(easy enough) BUT I ALSO want all email arriving at Gmail to be replied back to sender with a message like: "Your email has been delivered BUT the user has moved onto [email protected] . Please further all communication to this email". Using Outlook as my email client, how can I work this out?

    Read the article

  • F5/BigIP rule to redirect affinity-bound users from INACTIVE pool node to other ACTIVE node

    - by j pimmel
    We have several server nodes set up for the end users of our system and because we don't use any kind of session replication in the app servers, F5 maintains affinity for users with the ACTIVE node the client was first bound to. At times when we want to re-deploy the app, we change the F5 config and take a node out of the ACTIVE pool. Gradually the users filter off and we can deploy, but the process is a bit slow. We can't just dump all the users into a different node because - given the update heavy nature of the user activities - we could cause them to lose changes. That said, there is one URL/endpoint - call it http://site/product/list - which we know, when the client hits it, that we could shove them off the INACTIVE node they had affinity with and onto a different ACTIVE node. We have had a few tries writing an F5 rule along these lines, but haven't had much success so i thought I might ask here, assuming it's possible - I have no reason to think it's not based on what we have found so far.

    Read the article

  • Sorting emails with no To: tags in Outlook

    - by user29589
    Lately people at work have been sending with mailing lists in blind copies instead of just sending to the mailing lists. I think the intent is to prevent people from accidentally replying to all, but it means that these emails aren't sorted into their proper folders when they arrive. I'd like to at least be able to sort them into a common folder, but these emails arrive with no "To:" line in the headers. I'm using Outlook 2007, and I can't figure out a way to use their built-in rule editor to create a rule that sorts these emails. Is there a plugin that will allow me to sort emails like this, or a better rule editor? Updated: I know this is very old, but this is still very annoying to me. Is there any way to sort these kinds of emails to their own folder?

    Read the article

  • nginx: rewrite a non-existent php-file to another php-file with all arguments

    - by at0m33
    i really need help here. Sitting for some time now and dont figured it out. I want to realize a very simple task - rewrite a non-existent php file to another existant php file with all arguments like: this http://example.com/nonexistent.php?url=google.com to -> http://example.com/existent.php?url=google.com I tried something like this: rewrite ^/nonexistent.php /existent.php; Which dont works (File not found). But redirect a non-existent html file to a php file like this: rewrite ^/nonexistent.html /existent.php; works. I dont want to rewrite a html file, but this is still a confusing behaviour. Therefore it tried also something like this (and some variations): rewrite ^/nonexistent.php?url=^(.*)$ /existent.php?url=$1; which is also not working. (Maybe the syntax is bad) Any help here? It would be very nice!

    Read the article

  • Redirect email based on Source IP / Hostname

    - by PostMan
    So, we have a situation where we would like to be able to redirect (ignoring original destination) emails coming through out exchange server (locally sent) to a different email address. The situation is as follows: Testing a new server, this hosts a lot of our custom applications / scheduled tasks (as does the production version of this server). Instead of changing config files / parameters for these applications we'd rather leave them as they are, as we want to be as close to production as possible, however we don't want the emails go to the staff they would normally go to, we'd rather they were sent to a test email address where we are able to confirm the results. The emails look exactly like the production emails (same from / to / cc / bcc) except their source, hence why we'd like to know if the ability to redirect based on hostname exists. Cheers.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >