Search Results

Search found 525 results on 21 pages for 'readability'.

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

  • Android - drawing path as overlay on MapView

    - by Rabas
    Hello, I have a class that extends Overlay and implemments Overlay.Snappable. I have overriden its draw method: @Override public void draw(Canvas canvas, MapView mv, boolean shadow) { Projection projection = mv.getProjection(); ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); //Creating geopoints - ommited for readability Path p = new Path(); for (int i = 0; i < geoPoints.size(); i++) { if (i == geoPoints.size() - 1) { break; } Point from = new Point(); Point to = new Point(); projection.toPixels(geoPoints.get(i), from); projection.toPixels(geoPoints.get(i + 1), to); p.moveTo(from.x, from.y); p.lineTo(to.x, to.y); } Paint mPaint = new Paint(); mPaint.setStyle(Style.FILL); mPaint.setColor(0xFFFF0000); mPaint.setAntiAlias(true); canvas.drawPath(p, mPaint); super.draw(canvas, mv, shadow); } As you can see, I make a list of points on a map and I want them to form a polygonal shape. Now, the problem is that when I set paint style to be FILL or FILL_AND_STROKE nothing shows up on the screen, but when I set it to be just stroke, and set stroke width, it acctually draws what it is supposed to draw. Now, I looked for solution, but nothing comes up. Can you tell me if I something missed to set in the code itself, or are there some sorts of constraints when drawing on Overlay canvases? Thanks

    Read the article

  • BizTalk Business Rules Engine - Repeating Elements Question

    - by Andrew Cripps
    Hello I'm trying to create what I think should be a relatively simple business rule to operate over repeating elements in an XML schema. Consider the following XML snippet (this is simplified with namespaces removed, for readability): <Root> <AllAccounts> <Account id="1" currentPayment="10.00" arrearsAmount="25.00"> <AllCustomers> <Customer id="20" primary="true" canSelfServe="false" /> <Customer id="21" primary="false" canSelfServe="false" /> </AllCustomers> </Account> <Account id="2" currentPayment="10.00" arrearsAmount="15.00"> <AllCustomers> <Customer id="30" primary="true" canSelfServe="false" /> <Customer id="31" primary="false" canSelfServe="false" /> </AllCustomers> </AllAccounts> </Root> What I want to do is to have two rules: Set /Root/AllAccounts/Account[x]/AllCustomers/Customer[primary='true']/canSelfServe = true IF arrearsAmount < currentPayment Set /Root/AllAccounts/Account[x]/AllCustoemrs/Customer[primary='true']/canSelfServer = false IF arrearsAmount = currentPayment Where [x] is 0...number of /Root/AllAccounts/Account records present in the XML. I've tried two simple rules for this, and each rule seems to fire x * x times, where x is the number of Account records in the XML. I only want each rule to fire once for each Account record. Any help greatly appreciated! Thanks Andrew

    Read the article

  • codingbat wordEnds using regex

    - by polygenelubricants
    I'm trying to solve wordEnds from codingbat.com using regex. This is the simplest as I can make it with my current knowledge of regex: public String wordEnds(String str, String word) { return str.replaceAll( String.format( ".*?(?=%s)(?<=(.|^))%1$s(?=(.|$))|.+", java.util.regex.Pattern.quote(word) ), "$1$2" ); } String.format is used to inject word into the pattern for both readability and convenience (it's injected twice). Pattern.quote isn't necessary to pass their tests, but I think it's required for a proper regex-based solution. The regex has two major parts: If after matching as few characters as possible ".*?", word can still be found "(?=%s)", then lookbehind to capture any character immediately preceding it "(?<=(.|^))", match word "%1$s" and lookforward to capture any character following it "(?=(.|$))". The initial "if" test ensures that the atomic lookbehind captures only if there's a word Using lookahead to capture the following character doesn't consume it, so it can be used as part of further matching Otherwise match what's left "|.+" Groups 1 and 2 would capture empty strings I think this works in all cases, but it's obviously quite complex. I'm just wondering if others can suggest a simpler regex to do this. Note: I'm not looking for a solution using indexOf and a loop. I want a regex-based replaceAll solution. I also need a working solution that I can just copy-paste into codingbat and passes.

    Read the article

  • Sub Menu Rollover Pop up Not Showing

    - by Stradigos
    Hello everyone, hopefully this will be an easy answer for some of you CSS veterans out there. I'm developing a site for a client. For readability, I'll just give you a link to the website and the css page in question. HTML CSS I'm trying to make a sub menu pop up to the right of the main menu when you scroll over "Star Quartz Grout." My current CSS obviously isn't correct though, and I could use some guidance. ul#subNav {display: none; width: 134px; } li:hover ul#subNav, li.over ul#subNav {display: inline-block; position: absolute; top: 0px; left: 134px; } My guess is that it's working but it's hidden behind the rest of the page. I could be wrong though. It's kind of hard to confirm, even with Chrome's "Inspect Element" (very nice thing btw). It's probably some dumb mistake. Anyway, thanks in advance. I'm a bit of a CSS novice.

    Read the article

  • [URGENT] IE: ‘nodeType’ is null or not an object

    - by Patrick
    hi, I'm having this issue on my website in IE (6,7,8): ‘nodeType’ is null or not an object The error refers to "f.nodeType" property. Basically f is undefined, so the issue is before, but I cannot fix it. Could you give me some help ? www.donatellabernardi.ch/drupal (from IE developer toolbar debug it appears to be this line that is throwing the error) (autocolumn.min.js line 13 expanded below for readability) function split($putInHere,$pullOutHere,$parentColumn,height){ if($pullOutHere.children().length){ $cloneMe=$pullOutHere.children(":first"); $clone=$cloneMe.clone(true); if($clone.attr("nodeType")==1&&!$clone.hasClass("dontend")){ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Chokes on $putInHere.append($clone); if($clone.is("img")&&$parentColumn.height()<height+20){ $cloneMe.remove(); }else if(!$cloneMe.hasClass("dontsplit")&&$parentColumn.height()<height+20){ $cloneMe.remove(); }else if($clone.is("img")||$cloneMe.hasClass("dontsplit")){ $clone.remove(); }else{ $clone.empty(); if(!columnize($clone,$cloneMe,$parentColumn,height)){ if($cloneMe.children().length){ split($clone,$cloneMe,$parentColumn,height); } } if($clone.get(0).childNodes.length==0){ $clone.remove(); } } } } } Thanks

    Read the article

  • ASP.NET Line Breaks in Title Element

    - by Nathan Taylor
    I'm trying to optimize SEO readability on our websites and one issue I've come across is ASP.NET butchering the title element of my MasterPage. Entered as such in my MasterPage (manually reformatted to remove line breaks caused by the <% %> tags): <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /> - <%=WebsiteSettings.WebsiteName %></title> This is the output I receive: <title> Home - Website Name</title> As you can see ASP.NET is adding preceding and trailing line breaks where the <asp:ContentPlaceHolder /> is substitute becaused Visual Studio auto-formats <asp:Content /> to start and end with a line break. Obviously, this can be prevented in the Visual Studio formatting options, but this is not ideal because I only would want to remove that behavior for the TitleContent placeholder and not the rest. Is there any way I can ensure my Title is trimmed before it is rendered? I am using MVC so code-behind is not an acceptable option.

    Read the article

  • Over-enthusiastic Intellisense in VS2010 - can I tweak it?

    - by CJM
    Since I have upgraded from VS2008 to VS2010, I've been having an increasingly infuriating battle with the Intellisense. For example, when specifying CSS styles, when I press Enter to start an new line, Intellisense (appropriately) lists available Styles to me. And if I select color and then type ':', it presents a list of color presets - often helpful. However, if I type in a space (I like them for readability) or if I type '#' to enter RGB values, it selected the default Intellisense selection, in this case inherits. Another example is in an ASP.NET page - say I am concatenating strings, I type myString =, I get an Intellisense pop-up. If I type space or '"' (to enter a literal) or '.' (so select a property or method within a WITH block), the Intellisense selects the first entry in the list. I can dismiss the Intellisense pop-ups with escape but it makes it incredibly slow to code. This behaviour is different to my VS2008 set-up. I can't seem to find any way to configure Intellisense to behave differently... I really only want it to select and Intellisense entry when I type or ... at least, certainly not when I type '"' or ' ' or '.'!

    Read the article

  • javascript RegEx hashtag matching #foo and #foo-fåäö but not http://this.is/no#hashtag

    - by Simon B.
    Currently we're using javascript new RegExp('#[^,#=!\s][^,#=!\s]*') (see [1]) and it mostly works, except that it also matches URLs with anchors like http://this.is/no#hashtag and also we'd rather avoid matching foo#bar Some attempts have been made with look-ahead but it doesn't seem to work, or that I just don't get it. With the below source text: #public #writable #kommentarer-till-beta -- all these should be matched Verkligen #bra jobbat! T ex #kommentarer till #artiklar och #blogginlägg, kool. -- mixed within text http://this.is/no#hashtag -- problem xxy#bar -- We'd prefer not matching this one, and... #foo=bar =foo#bar -- we probably shouldn't match any of those either. #foo,bar #foo;bar #foo-bar #foo:bar -- We're flexible on whether these get matched in part or in full . We'd like to get below output: (showing $ instead of <a class=tag href=.....>...</a> for readability reasons) $ $ $ -- all these should be matched Verkligen $ jobbat! T ex $ till $ och $, kool. -- mixed within text http://this.is/no$ -- problem xxy$ -- We'd prefer not matching this one, and... $=bar =foo$ -- we probably shouldn't match any of those either. $,bar $ $ $ -- We're flexible on whether these get matched in part or in full [1] http://github.com/ether/pad/blob/master/etherpad/src/plugins/twitterStyleTags/hooks.js

    Read the article

  • How can I write reusable Javascript?

    - by RenderIn
    I've started to wrap my functions inside of Objects, e.g.: var Search = { carSearch: function(color) { }, peopleSearch: function(name) { }, ... } This helps a lot with readability, but I continue to have issues with reusabilty. To be more specific, the difficulty is in two areas: Receiving parameters. A lot of times I will have a search screen with multiple input fields and a button that calls the javascript search function. I have to either put a bunch of code in the onclick of the button to retrieve and then martial the values from the input fields into the function call, or I have to hardcode the HTML input field names/IDs so that I can subsequently retrieve them with Javascript. The solution I've settled on for this is to pass the field names/IDs into the function, which it then uses to retrieve the values from the input fields. This is simple but really seems improper. Returning values. The effect of most Javascript calls tends to be one in which some visual on the screen changes directly, or as a result of another action performed in the call. Reusability is toast when I put these screen-altering effects at the end of a function. For example, after a search is completed I need to display the results on the screen. How do others handle these issues? Putting my thinking cap on leads me to believe that I need to have an page-specific layer of Javascript between each use in my application and the generic methods I create which are to be used application-wide. Using the previous example, I would have a search button whose onclick calls a myPageSpecificSearchFunction, in which the search field IDs/names are hardcoded, which marshals the parameters and calls the generic search function. The generic function would return data/objects/variables only, and would not directly read from or make any changes to the DOM. The page-specific search function would then receive this data back and alter the DOM appropriately. Am I on the right path or is there a better pattern to handle the reuse of Javascript objects/methods?

    Read the article

  • Custom Validation Attribute with Custom Model Binder in MVC 2

    - by griegs
    I apologise for the amount of code I have included. I've tried to keep it to a minimum. I'm trying to have a Custom Validator Attribute on my model as well as a Custom Model binder. The Attribute and the Binder work great seperately but if I have both, then the Validation Attribute no longer works. Here is my code snipped for readability. If I leave out the code in global.asax the custom validation fires but not if I have the custom binder enabled. Validation Attribute; public class IsPhoneNumberAttribute : ValidationAttribute { public override bool IsValid(object value) { //do some checking on 'value' here return true; } } Useage of the attribute in my model; [Required(ErrorMessage = "Please provide a contact number")] [IsPhoneNumberAttribute(ErrorMessage = "Not a valid phone number")] public string Phone { get; set; } Custom Model Binder; public class CustomContactUsBinder : DefaultModelBinder { protected override void OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) { ContactFormViewModel contactFormViewModel = bindingContext.Model as ContactFormViewModel; if (!String.IsNullOrEmpty(contactFormViewModel.Phone)) if (contactFormViewModel.Phone.Length > 10) bindingContext.ModelState.AddModelError("Phone", "Phone is too long."); } } Global asax; System.Web.Mvc.ModelBinders.Binders[typeof(ContactFormViewModel)] = new CustomContactUsBinder();

    Read the article

  • Google Radar Chart: Not plotting data

    - by Hallik
    Hi. I have different types of data that I have normalized just with base10, so everything is on a 10 point scale. There are two data points, and the legend for them show up fine. All the points around the radar show up fine and so do the labels for them, but I don't see any filled in data. Outside of the labels and axis, the chart is blank. Below is the actual image tag I render, then I split up the variables on each line for easy readability. Anyone mind telling me why it isn't working? <img src="http://chart.apis.google.com/chart?cht=rs&amp;chm=B,3366CC60,0,1.0,5.0|B,CC4D3360,1,1.0,5.0&chs=600x500&chd=t:4.6756775443385,4.7031365524912,1.8646655408171,1.8358167047079,4.2483837215455,4.1367786166752,|5.0319252700625,5.0370797208146,1.8415340693163,1.8591105937857,4.3392150450337,4.1434876641017&chco=3366CC,CC4D33&chls=2.0,4.0,0.0|2.0,4.0,0.0&chxt=x&chxl=0:|Label1|Label2|label3|Label4|Label5|Label6&chxr=0,0.0,10.0&chdl=Data Object 1|Data Object 2&"/> cht=rs& chm=B,3366CC60,0,1.0,5.0|B,CC4D3360,1,1.0,5.0& chs=600x500& chd=t:4.6756775443385,4.7031365524912,1.8646655408171,1.8358167047079,4.2483837215455,4.1367786166752,|5.0319252700625,5.0370797208146,1.8415340693163,1.8591105937857,4.3392150450337,4.1434876641017& chco=3366CC,CC4D33& chls=2.0,4.0,0.0|2.0,4.0,0.0& chxt=x& chxl=0:|Label1|Label2|label3|Label4|Label5|Label6& chxr=0,0.0,10.0& chdl=Data Object 1|Data Object 2& This is the radar chart page, I can't tell what I am doing wrong. http://code.google.com/apis/chart/docs/gallery/radar_charts.html

    Read the article

  • SQL Server - Multi-Column substring matching

    - by hamlin11
    One of my clients is hooked on multi-column substring matching. I understand that Contains and FreeText search for words (and at least in the case of Contains, word prefixes). However, based upon my understanding of this MSDN book, neither of these nor their variants are capable of searching substrings. I have used LIKE rather extensively (Select * from A where A.B Like '%substr%') Sample table A: ID | Col1 | Col2 | Col3 | ------------------------------------- 1 | oklahoma | colorado | Utah | 2 | arkansas | colorado | oklahoma | 3 | florida | michigan | florida | ------------------------------------- The following code will give us row 1 and row 2: select * from A where Col1 like '%klah%' or Col2 like '%klah%' or Col3 like '%klah%' This is rather ugly, probably slow, and I just don't like it very much. Probably because the implementations that I'm dealing with have 10+ columns that need searched. The following may be a slight improvement as code readability goes, but as far as performance, we're still in the same ball park. select * from A where (Col1 + ' ' + Col2 + ' ' + Col3) like '%klah%' I have thought about simply adding insert, update, and delete triggers that simply add the concatenated version of the above columns into a separate table that shadows this table. Sample Shadow_Table: ID | searchtext | --------------------------------- 1 | oklahoma colorado Utah | 2 | arkansas colorado oklahoma | 3 | florida michigan florida | --------------------------------- This would allow us to perform the following query to search for '%klah%' select * from Shadow_Table where searchtext like '%klah%' I really don't like having to remember that this shadow table exists and that I'm supposed to use it when I am performing multi-column substring matching, but it probably yields pretty quick reads at the expense of write and storage space. My gut feeling tells me there there is an existing solution built into SQL Server 2008. However, I don't seem to be able to find anything other than research papers on the subject. Any help would be appreciated.

    Read the article

  • What ever happened to APL?

    - by lkessler
    When I was at University 30 years ago, I used a programming language called APL. I believe the acronym stood for "A Programming Language", This language was interpretive and was especially useful for array and matrix operations with powerful operators and library functions to help with that. Did you use APL? Is this language still in use anywhere? Is it still available, either commercially or open source? I remember the combinatorics assignment we had. It was complex. It took a week of work for people to program it in PL/1 and those programs ranged from 500 to 1000 lines long. I wrote it in APL in under an hour. I left it at 10 lines for readability, although I should have been a purist and worked another hour to get it into 1 line. The PL/1 programs took 1 or 2 minutes to run on the IBM mainframe and solve the problem. The computer charge was $20. My APL program took 2 hours to run and the charge was $1,500 which was paid for by our Computer Science Department's budget. That's when I realized that a week of my time is worth way more than saving some $'s in someone else's budget. I got an A+ in the course. p.s. Don't miss this presentation entitled: "APL one of the greatest programming languages ever"

    Read the article

  • How to force c# binary int division to return a double?

    - by Wayne
    How to force double x = 3 / 2; to return 1.5 in x without the D suffix or casting? Is there any kind of operator overload that can be done? Or some compiler option? Amazingly, it's not so simple to add the casting or suffix for the following reason: Business users need to write and debug their own formulas. Presently C# is getting used like a DSL (domain specific language) in that these users aren't computer science engineers. So all they know is how to edit and create a few types of classes to hold their "business rules" which are generally just math formulas. But they always assume that double x = 3 / 2; will return x = 1.5 however in C# that returns 1. A. they always forget this, waste time debugging, call me for support and we fix it. B. they think it's very ugly and hurts the readability of their business rules. As you know, DSL's need to be more like natural language. Yes. We are planning to move to Boo and build a DSL based on it but that's down the road. Is there a simple solution to make double x = 3 / 2; return 1.5 by something external to the class so it's invisible to the users? Thanks! Wayne

    Read the article

  • How to force c# binary int division to return a double?

    - by Wayne
    How to force double x = 3 / 2; to return 1.5 in x without the D suffix or casting? Is there any kind of operator overload that can be done? Or some compiler option? Amazingly, it's not so simple to add the casting or suffix for the following reason: Business users need to write and debug their own formulas. Presently C# is getting used like a DSL (domain specific language) in that these users aren't computer science engineers. So all they know is how to edit and create a few types of classes to hold their "business rules" which are generally just math formulas. But they always assume that double x = 3 / 2; will return x = 1.5 however in C# that returns 1. A. they always forget this, waste time debugging, call me for support and we fix it. B. they think it's very ugly and hurts the readability of their business rules. As you know, DSL's need to be more like natural language. Yes. We are planning to move to Boo and build a DSL based on it but that's down the road. Is there a simple solution to make double x = 3 / 2; return 1.5 by something external to the class so it's invisible to the users? Thanks! Wayne

    Read the article

  • Some regular expression help?

    - by Rohan
    Hey there. I'm trying to create a Regex javascript split, but I'm totally stuck. Here's my input: 9:30 pm The user did action A. 10:30 pm Welcome, user John Doe. ***This is a comment 11:30 am This is some more input. I want the output array after the split() to be (I've removed the \n for readability): ["9:30 pm The user did action A.", "10:30 pm Welcome, user John Doe.", "***This is a comment", "11:30 am This is some more input." ]; My current regular expression is: var split = text.split(/\s*(?=(\b\d+:\d+|\*\*\*))/); This works, but there is one problem: the timestamps get repeated in extra elements. So I get: ["9:30", "9:30 pm The user did action A.", "10:30", "10:30 pm Welcome, user John Doe.", "***This is a comment", "11:30", "11:30 am This is some more input." ]; I cant split on the newlines \n because they aren't consistent, and sometimes there may be no newlines at all. Could you help me out with a Regex for this? Thanks so much!!

    Read the article

  • Extending EF4 SQL Generation

    - by Basiclife
    Hi, We're using EF4 in a fairly large system and occasionally run into problems due to EF4 being unable to convert certain expressions into SQL. At present, we either need to do some fancy footwork (DB/Code) or just accept the performance hit and allow the query to be executed in-memory. Needless to say neither of these is ideal and the hacks we've sometimes had to use reduce readability / maintainability. What we would ideally like is a way to extend the SQL generation capabilities of the EF4 SQL provider. Obviously there are some things like .Net method calls which will always have to be client-side but some functionality like date comparisons (eg Group by weeks in Linq to Entities ) should be do-able. I've Googled but perhaps I'm using the wrong terminology as all I get is information about the new features of EF4 SQL Generation. For such a flexible and extensible framework, I'd be surprised if this isn't possible. In my head, I'm imagining inheriting from the [SQL 2008] provider and extending it to handle additional expressions / similar in the expression tree it's given to convert to SQL. Any help/pointers appreciated. We're using VS2010 Ultimate, .Net 4 (non-client profile) and EF4. The app is in ASP.Net and is running in a 64-Bit environment in case it makes a difference.

    Read the article

  • does actionscript addChild require a display object first

    - by touB
    I'm trying to move away from mxml to actionsctipt. I have a <s:Rect> that I've created and set its properties, but having trouble adding it. var aRect:Rect = new Rect(); //set properties like aRect.x, aRect.y, aRect.width, aRect.height //tried adding it various ways addChild(aRect); Application.addChild(aRect); Application.application.addChild(aRect); stage.addChild(aRect); But I keep getting the error 1067: Implicit coercion of a value of type spark.primitives:Rect to an unrelated type flash.display:DisplayObject Originally in the mxml, it was right inside <s:Application> not nested inside anything <s:Application> <s:Rect id="aRect" x="10" y="10" width="15%" height="15%"> //then fill code here, removed for readability </s:Rect> </s:Application> What's the deal, I thought actionscript would be nicer than mxml.

    Read the article

  • compact Number formatting behavior in Java (automatically switch between decimal and scientific notation)

    - by kostmo
    I am looking for a way to format a floating point number dynamically in either standard decimal format or scientific notation, depending on the value of the number. For moderate magnitudes, the number should be formatted as a decimal with trailing zeros suppressed. If the floating point number is equal to an integral value, the decimal point should also be suppressed. For extreme magnitudes (very small or very large), the number should be expressed in scientific notation. Alternately stated, if the number of characters in the expression as standard decimal notation exceeds a certain threshold, switch to scientific notation. I should have control over the maximum number of digits of precision, but I don't want trailing zeros appended to express the minimum precision; all trailing zeros should be suppressed. Basically, it should optimize for compactness and readability. 2.80000 - 2.8 765.000000 - 765 0.0073943162953 - 0.00739432 (limit digits of precision—to 6 in this case) 0.0000073943162953 - 7.39432E-6 (switch to scientific notation if the magnitude is small enough—less than 1E-5 in this case) 7394316295300000 - 7.39432E+6 (switch to scientific notation if the magnitude is large enough—for example, when greater than 1E+10) 0.0000073900000000 - 7.39E-6 (strip trailing zeros from significand in scientific notation) 0.000007299998344 - 7.3E-6 (rounding from the 6-digit precision limit causes this number to have trailing zeros which are stripped) Here's what I've found so far: The .toString() method of the Number class does most of what I want, except it doesn't upconvert to integer representation when possible, and it will not express large integral magnitudes in scientific notation. Also, I'm not sure how to adjust the precision. The "%G" format string to the String.format(...) function allows me to express numbers in scientific notation with adjustable precision, but does not strip trailing zeros. I'm wondering if there's already some library function out there that meets these criteria. I guess the only stumbling block for writing this myself is having to strip the trailing zeros from the significand in scientific notation produced by %G.

    Read the article

  • Workaround for basic syntax not being parsed.

    - by Mark Tomlin
    I want to have a class property that allow for an expression to take place on the right side of the equals sign. All versions of PHP choke on the following code, but it is written in this way to allow for easier extendibility in the future. /* Example SDK Class */ class SDK { /* Runtime Option Flags */ // Strings # 0: Makes no change to the strings. var $STRING_NONE = (1 << 0); # 1: Removes color codes from the string. var $STRING_STRIP_COLOR = (1 << 1); # 2: Removes language codes from the string. var $STRING_STRIP_LANG = (1 << 2); # 3: Removes all formatting from the string. var $STRING_STRIP = SELF::STRING_STRIP_COLOR & SELF::STRING_STRIP_LANG; # 4: Converts color codes to HTML & UTF-8. var $STRING_HTML = (1 << 3); # 8: Converts color codes to ECMA-48 escape color codes & UTF-8. var $STRING_CONSOLE = (1 << 4); # 16: Changes player names only. var $STRING_NAMES = (1 << 5); # 32: Changes host names only. var $STRING_HOSTS = (1 << 6); function SDK($fString = SELF::STRING_HTML & SELF::STRING_NAMES & SELF_HOST) { // constructor code. } } $SDK &= new SDK(SDK::STRING_NONE); (1 << 0) seems like very basic syntax to me, and is not fathomable why PHP would not allow for such a thing. Can anyone think of a work around that would maintain readability and future expandability of the following code?

    Read the article

  • How to use will_paginate with a nested resource in Rails?

    - by Sue Petersen
    I'm new to Rails, and I'm having major trouble getting will_paginate to work with a nested resource. I have two models, Statement and Invoice. will_paginate is working on Statement, but I can't get it to work on Invoice. I know I'd doing something silly, but I can't figure it out and the examples I've found on google won't work for me. statement.rb class Statement < ActiveRecord::Base has_many :invoices def self.search(search, page) paginate :per_page => 19, :page => page, :conditions => ['company like ?', "%#{search}%"], :order => 'date_due DESC, company, supplier' end end statements_controller.rb <irrelevant code clipped for readability> def index #taken from the RAILSCAST 51, will_paginate podcast @statements = Statement.search(params[:search], params[:page]) end I call this in the view like so, and it works: <%= will_paginate @statements %> But I can't figure out how to get it to work for Invoices: invoice.rb class Invoice < ActiveRecord::Base belongs_to :statement def self.search(search, page) paginate :per_page => 19, :page => page, :conditions => ['company like ?', "%#{search}%"], :order => 'employee' end end invoices_controller.rb class InvoicesController < ApplicationController before_filter :find_statement #TODO I can't get will_paginate to work w a nested resource def index #taken from the RAILSCAST 51, will_paginate podcast @invoices = Invoice.search(params[:search], params[:page]) end def find_statement @statement_id = params[:statement_id] return(redirect_to(statements_url)) unless @statement_id @statement = Statement.find(@statement_id) end end And I try to call it like this: <%= will_paginate (@invoices) % The most common error message, as I play with this, is: "The @statements variable appears to be empty. Did you forget to pass the collection object for will_paginate?" I don't have a clue what the problem is, or how to fix it. Thanks for any help and guidance!

    Read the article

  • Advantages/disadvantages of Python and Ruby

    - by Seburdis
    I know this is going to seem a little like all the other python vs ruby question out there, but I'm not looking specifically to pick one over the other all the time. My question is, essentially, why would you use one language over the other when you are starting a new project? What features does ruby have that python doesn't that would make you decide on it for a given project? What about python over ruby? I was just recently thinking about the differentiation between the two languages because of Jamis Buck's "There is no magic, only awesome" series of articles (4 parts, available here) when I realized I really don't know enough about the two languages to know when to choose one over the other. I'm hoping to get objective answers from people who have experience with both languages, rather than just "python is better, ruby sucks" kind of responses. If you know of a feature in one language that doesn't exist in the other and is great in a certain situation, feel free to chime in and say why you think it's awesome. If you have another language comparable to these that you'd like to suggest pros/cons for, like groovy for example, that would be appreciated too. Some thing I know each language has going for it: Ruby: Awesome metaprogramming Great community Wide selection of Gems Rails Great code readability, usually MacRuby is great for native development on Mac without objc Amazing testing tools (cucumber, rspec, shoulda, autotest, etc.) Python: Whitespace indentation List comprehensions Better functional programming support? Lots of support on linux Easy_install isn't far from gems Great variety of libraries available

    Read the article

  • XmlHttpRequest in a bookmarklet returns empty responseText on GET?

    - by David Eyk
    I'm trying to build a javascript bookmarklet for a special URL shortening service we've built at http://esv.to for shortening scripture references (i.e. "Matthew 5" becomes "http://esv.to/Mt5". The bookmarklet is supposed to do a GET request to http://api.esv.to/Matthew+5, which returns a text/plain response of http://esv.to/Mt5. The code for the bookmarklet itself looks like this (expanded for readability): var body = document.getElementsByTagName('body')[0], script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://esv.to/media/js/bookmarklet.js'; body.appendChild(script); void(0); The code from http://esv.to/media/js/bookmarklet.js looks like this: (function() { function shorten(ref, callback) { var url = "http://esv.to/api/" + escape(ref); var req = new XMLHttpRequest(); req.onreadystatechange = function shortenIt() { if ( this.readyState == 4 && this.status == 200 ) { callback(req.responseText); }; }; req.open( "GET", url ); req.send(); }; function doBookmarklet() { var ref = prompt("Enter a scripture reference or keyword search to link to:", "") shorten(ref, function (short) { prompt("Here is your shortened ESV URL:", short); }); }; doBookmarklet(); })(); When called from http://esv.to itself, the bookmarklet works correctly. But when used on another page, it does not. The strange thing is, when I watch the request from Firebug, the response is 200 OK, the browser downloads 17 bytes (the length of the returned string), but the response body is empty! No error is thrown, just an empty responseText on the XmlHttpRequest object. Now, according to http://stackoverflow.com/questions/664689/ajax-call-from-bookmarklet, GET shouldn't violate the same origin policy. Is this a bug? Is there a workaround?

    Read the article

  • Code golf: combining multiple sorted lists into a single sorted list

    - by Alabaster Codify
    Implement an algorithm to merge an arbitrary number of sorted lists into one sorted list. The aim is to create the smallest working programme, in whatever language you like. For example: input: ((1, 4, 7), (2, 5, 8), (3, 6, 9)) output: (1, 2, 3, 4, 5, 6, 7, 8, 9) input: ((1, 10), (), (2, 5, 6, 7)) output: (1, 2, 5, 6, 7, 10) Note: solutions which concatenate the input lists then use a language-provided sort function are not in-keeping with the spirit of golf, and will not be accepted: sorted(sum(lists,[])) # cheating: out of bounds! Apart from anything else, your algorithm should be (but doesn't have to be) a lot faster! Clearly state the language, any foibles and the character count. Only include meaningful characters in the count, but feel free to add whitespace to the code for artistic / readability purposes. To keep things tidy, suggest improvement in comments or by editing answers where appropriate, rather than creating a new answer for each "revision". EDIT: if I was submitting this question again, I would expand on the "no language provided sort" rule to be "don't concatenate all the lists then sort the result". Existing entries which do concatenate-then-sort are actually very interesting and compact, so I won't retro-actively introduce a rule they break, but feel free to work to the more restrictive spec in new submissions. Inspired by http://stackoverflow.com/questions/464342/combining-two-sorted-lists-in-python

    Read the article

  • Why not use tables for layout in HTML?

    - by Bno
    It seems to be the general opinion that tables should not be used for layout in HTML. Why? I have never (or rarely to be honest) seen good arguments for this. The usual answers are: It's good to separate content from layoutBut this is a fallacious argument; Cliche Thinking. I guess it's true that using the table element for layout has little to do with tabular data. So what? Does my boss care? Do my users care?Perhaps me or my fellow developers who have to maintain a web page care... Is a table less maintainable? I think using a table is easier than using divs and CSS.By the way... why is using a div or a span good separation of content from layout and a table not? Getting a good layout with only divs often requires a lot of nested divs. Readability of the codeI think it's the other way around. Most people understand html, few understand CSS. It's better for SEO not to use tablesWhy? Can anybody show some evidence that it is? Or a statement from Google that tables are discouraged from an SEO perspective? Tables are slower.An extra tbody element has to be inserted. This is peanuts for modern web browsers. Show me some benchmarks where the use of a table significantly slows down a page. A layout overhaul is easier without tables, see css Zen Garden.Most web sites that need an upgrade need new content (html) as well. Scenarios where a new version of a web site only needs a new CSS file are not very likely. Zen Garden is a nice web site, but a bit theoretical. Not to mention its misuse of CSS. I am really interested in good arguments to use divs + CSS instead of tables.

    Read the article

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