Search Results

Search found 1907 results on 77 pages for 'james weng'.

Page 53/77 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • What is a good generic sibling control Javascript communication strategy?

    - by James
    I'm building a webpage that is composed of several controls, and trying to come up with an effective somewhat generic client side sibling control communication model. One of the controls is the menu control. Whenever an item is clicked in here I wanted to expose a custom client side event that other controls can subscribe to, so that I can achieve a loosely coupled sibling control communication model. To that end I've created a simple Javascript event collection class (code below) that acts as like a hub for control event registration and event subscription. This code certainly gets the job done, but my question is is there a better more elegant way to do this in terms of best practices or tools, or is this just a fools errand? /// Event collection object - acts as the hub for control communication. function ClientEventCollection() { this.ClientEvents = {}; this.RegisterEvent = _RegisterEvent; this.AttachToEvent = _AttachToEvent; this.FireEvent = _FireEvent; function _RegisterEvent(eventKey) { if (!this.ClientEvents[eventKey]) this.ClientEvents[eventKey] = []; } function _AttachToEvent(eventKey, handlerFunc) { if (this.ClientEvents[eventKey]) this.ClientEvents[eventKey][this.ClientEvents[eventKey].length] = handlerFunc; } function _FireEvent(eventKey, triggerId, contextData ) { if (this.ClientEvents[eventKey]) { for (var i = 0; i < this.ClientEvents[eventKey].length; i++) { var fn = this.ClientEvents[eventKey][i]; if (fn) fn(triggerId, contextData); } } } } // load new collection instance. var myClientEvents = new bsdClientEventCollection(); // register events specific to the control that owns it, this will be emitted by each respective control. myClientEvents.RegisterEvent("menu-item-clicked"); Here is the part where this code above is consumed by source and subscriber controls. // menu control $(document).ready(function() { $(".menu > a").click( function(event) { //event.preventDefault(); myClientEvents.FireEvent("menu-item-clicked", $(this).attr("id"), null); }); }); <div style="float: left;" class="menu"> <a id="1" href="#">Menu Item1</a><br /> <a id="2" href="#">Menu Item2</a><br /> <a id="3" href="#">Menu Item3</a><br /> <a id="4" href="#">Menu Item4</a><br /> </div> // event subscriber control $(document).ready(function() { myClientEvents.AttachToEvent("menu-item-clicked", menuItemChanged); myClientEvents.AttachToEvent("menu-item-clicked", menuItemChanged2); myClientEvents.AttachToEvent("menu-item-clicked", menuItemChanged3); }); function menuItemChanged(id, contextData) { alert('menuItemChanged ' + id); } function menuItemChanged2(id, contextData) { alert('menuItemChanged2 ' + id); } function menuItemChanged3(id, contextData) { alert('menuItemChanged3 ' + id); }

    Read the article

  • Blackberry RichTextField preferred height during layout

    - by James Veenstra
    This is using the Backberry JDK (5.0 if needed). I have a custom Manager that contains a RichTextField. I want the height of the field to vary by the amount of text in the RichTextField. The sublayout code looks like this (rtf is a RichTextField object): protected void sublayout(int width, int height) { int h = rtf.getPreferredHeight(); setExtent(Display.getWidth(), h); layoutChild(rtf, Display.getWidth(), h); setPositionChild(rtf, 0, 0); setExtent(Display.getWidth(), h); } The call to rtf.getPreferredHeight always returns the same value, no matter how much text (and therefore how many lines on the screen). Any clues on how to get the height of a RichTextField when the content and width are known?

    Read the article

  • How can I redirect directory using htaccess including files with spaces in the names

    - by James
    Hi, I am dealing with a situation where someone has handed me a bunch of old files on the server which already have a lot of incoming links directly to them (mostly pdf files). I now have the files organized but in a different directory. Before it was 'domain/manuals/file' now it is 'domain/media/manual/file'. I am trying to resolve this issue using an htaccess file. Many of the files have spaces in the names (not something I can control) and because they already have links to them I can't just go through renaming them. I have found that I can redirect files individually when they have spaces in the names by using quotes such as: redirect 301 "/manuals/file 123.pdf" "http://www.domain.com/manuals/file 123.pdf" However, there are loads of these files and I wondered if there is a way to create a regular expression that will handle spaces in file names that I could use to redirect the entire directory. I should add that some files contain decent file names with no spaces in, some have one space and others more than one space. It's not pretty. If you've encountered this problem before I would really appreciate hearing your advice, I'm running out of ideas. Thanks.

    Read the article

  • "Intercepting" user input into text box and removing it

    - by James P
    I have a text box that I would like to do some validation on. At the moment I have this code: function updateChanger() { // Validate input var likeMessage = validateInput($("#like").val()); alert(likeMessage); } function validateInput(input) { input = input.replace(/[^a-zA-Z0-9:\(\/\)\s\.,!~]/g, ""); return input; } This successfully trims out unwanted characters in the likeMessage variable, but the character still gets entered into the text box. I would like to stop that from happening. I know it will have something to do with $("#like").val() but the only thing I can think of is just chopping off the end character from the text box value, would this suffice? Thanks for any help!

    Read the article

  • chdir programmatically

    - by james owen
    Friday, March 12, 2010 1:18 pm. In windows -- and probably unix for that matter -- using the chdir() function in a (32-bit) program doesn't change the directory when the program exits. (It does in a 16-bit windows program.) Does anybody know how to do that in a windows 32-bit program?

    Read the article

  • Find Adjacent Nodes A Star Path-Finding C++

    - by Infinity James
    Is there a better way to handle my FindAdjacent() function for my A Star algorithm? It's awfully messy, and it doesn't set the parent node correctly. When it tries to find the path, it loops infinitely because the parent of the node has a pent of the node and the parents are always each other. Any help would be amazing. This is my function: void AStarImpl::FindAdjacent(Node* pNode) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (pNode->mX != Map::GetInstance()->mMap[pNode->mX + i][pNode->mY + j].mX || pNode->mY != Map::GetInstance()->mMap[pNode->mX + i][pNode->mY + j].mY) { if (pNode->mX + i <= 14 && pNode->mY + j <= 14) { if (pNode->mX + i >= 0 && pNode->mY + j >= 0) { if (Map::GetInstance()->mMap[pNode->mX + i][pNode->mY + j].mTypeID != NODE_TYPE_SOLID) { if (find(mOpenList.begin(), mOpenList.end(), &Map::GetInstance()->mMap[pNode->mX + i][pNode->mY + j]) == mOpenList.end()) { Map::GetInstance()->mMap[pNode->mX+i][pNode->mY+j].mParent = &Map::GetInstance()->mMap[pNode->mX][pNode->mY]; mOpenList.push_back(&Map::GetInstance()->mMap[pNode->mX+i][pNode->mY+j]); } } } } } } } mClosedList.push_back(&Map::GetInstance()->mMap[pNode->mX][pNode->mY]); } If you'd like any more code, just ask and I can post it.

    Read the article

  • Python continue from the point where exception was thrown

    - by James Lin
    Hi is there a way to continue from the point where exception was thrown? eg I have the following psudo code unique code 1 unique code 2 unique code 3 if I want to ignore the exceptions of any of the unique code statements I will have to do it like this: try: #unique code 1 except: pass try: #unique code 2 except: pass try: #unique code 3 except: pass but this isn't elegant to me, and for the life of me I can't remember how I resolved this kind of problem last time... what I want to have is something like try: unique code 1 unique code 2 unique code 3 except: continue from last exception raised

    Read the article

  • How do I DRY up business logic between sever-side Ruby and client-side Javascript?

    - by James A. Rosen
    I have a Widget model with inheritance (I'm using Single-Table Inheritance, but it's equally valid for Class-per-Table). Some of the subclasses require a particular field; others do not. class Widget < ActiveRecord ALL_WIDGET_TYPES = [FooWidget, BarWidget, BazWidget] end class FooWidget < Widget validates_presence_of :color end class BarWidget < Widget # no color field end class BazWidget < Widget validates_presence_of :color end I'm building a "New Widget" form (app/views/widgets/new.html.erb) and would like to dynamically show/hide the color field based on a <select> for widget_type. <% form_for @widget do |f| %> <%= f.select :type, Widget::ALL_WIDGET_TYPES %> <div class='hiddenUnlessWidgetTypeIsFooOrBaz'> <%= f.label :color %> <%= f.text_field :color %> </div> <% end %> I can easily write some jQuery to watch for onChange events on widget_type, but that would mean putting some sort of WidgetTypesThatRequireColor constant in my Javascript. Easy enough to do manually, but it is likely to get disconnected from the Widget model classes. I would prefer not to output Javascript directly in my view, though I have considered using content_for(:js) and have a yield :js in my template footer. Any better ideas?

    Read the article

  • Visual C++: Invalid allocation size. How to force the debugger to stop on this message?

    - by James Roth
    The MFC program I am debugging is printing this message in the "Output" window in Visual Studio 9.0: HEAP[AppName.exe]: Invalid allocation size - 99999998 (exceeded 7ffdefff) I'm pretty sure this is due to a bad "new", uninitialized variable or similar error. The question is: how do I get the debugger to stop on this message so that I can view the stack trace and solve the problem?

    Read the article

  • Versioning CommonAssemblyInfo.cs and MSBuild

    - by James Thigpen
    So I have a CommonAssemblyInfo.cs linked into all the projects in my solution and is dynamically generated by my rake/albacore scripts which is not checked into source control. I also have a CommonAssemblyInfo.cs.local for use when there is no ruby available, mainly to be used by devs. Is it possible to have a msbuild task or something that runs before any of the other project compilation that will copy CommonAssemblyInfo.cs.local to CommonAssemblyInfo.cs before trying to compile my solution? I hate having to have a command you have to just know about and type in order to open and buidl the solution in Visual Studio.

    Read the article

  • Ship maritime AIS information API

    - by James Cadd
    Is there an API or Web Service that can be used to read AIS data? Most links I read starting at Wikipedia (http://en.wikipedia.org/wiki/Automatic_Identification_System) say that AIS data is freely available but I'm having a hard time finding a provider of the data. A C# example or language agnostic web service would be helpful.

    Read the article

  • ReWriteRule is redirecting rather rewriting

    - by James Doc
    At the moment I have two machines that I do web development on; an iMac for work at the office and a MacBook for when I have to work on the move. They both running OS X 10.6 have the same version of PHP, Apache, etc running on them. Both computers have the same files of the website, including the .htaccess file (see below). On the MacBook the URLs are rewritten nicely, masking the URL they are pointing to (eg site/page/page-name), however on the iMac they simply redirect to the page (eg site/index.php?method=page&value=page-name) which is making switching back and forth between machines a bit of a pain! I'm sure it must be a config setting somewhere, but I can't for the life of me find it. Has anyone got a remedy? Many thanks. I'm fairly convinced there is a much nice way of writing this htaccess file without loosing access several key folders as well! Options +FollowSymlinks RewriteEngine on RewriteBase /In%20Progress/Vila%20Maninga/ RewriteRule ^page/([a-z|0-9_&;=-]+) index.php?method=page&value=$1 [NC] RewriteRule ^tag/([a-z|0-9_]+) index.php?method=tag&value=$1 [NC] RewriteRule ^search/([a-z|0-9_"]+) index.php?method=search&value=$1 [NC] RewriteRule ^modpage/([con0-9-]+) index.php?method=modpage&value=$1 [NC] RewriteRule ^login index.php?method=login [NC] RewriteRule ^logout index.php?method=logout [NC] RewriteRule ^useraccounts index.php?method=useraccounts [NC]

    Read the article

  • How do I put all types implementing a certain generic interface in a dictionary?

    - by James Wenday
    Given a particular interface ITarget<T> and a particular type myType, here's how you would determine T if myType implements ITarget<T>. (This code snippet is taken from the answer to an earlier question.) foreach (var i in myType.GetInterfaces ()) if (i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ITarget<>)) return i.GetGenericArguments ()[0] ; However, this only checks a single type, myType. How would I create a dictionary of all such type parameters, where the key is T and the value is myType? I think it would look something like this: var searchTarget = typeof(ITarget<>); var dict = Assembly.GetExecutingAssembly().[???] .Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == searchTarget) .[???]; What goes in the blanks?

    Read the article

  • How can I store this kind of graph in neo4j for fast traversal?

    - by James
    This is a graph whose nodes exist in many connected components at once because a node's relationships are a collection of edge groups such that only one edge per edge group can be present at once. I need to be able to find all of the connected components that a node exists in. What would be the best way to store this graph in neo4j to quickly find all of the connected components that a node exists in? Is there a way to use the built in traversals to do this? Also: is there a name for this kind of graph? I'd appreciate any help/ideas. Update: Sorry for not being clear. All nodes are of the same type. Nodes have a variable number of edge groups. Exactly one edge from each edge group needs to be chosen for a particular connected component. I'm going to try to explain through example: Node x1 is related to: (x2 or x3 or x4) AND (x5 or x6) AND (x7) Node x2 is related to: (x8) AND (x9 or x10) So x1's first edge group is (x2, x3, x4), its second edge group is (x5, x6), and its third edge group is (x7). So here are a few connected components that x1 exists in: CC1: x1 is related to: x2, x5, x7 x2 is related to: x8 x9 CC2: x1 is related to: x2, x6, x7 x2 is related to: x8, x9 CC3: x1 is related to: x3, x5, x7 CC4: x1 is related to: x3, x6, x7 etc. I'm grateful for your help in this.

    Read the article

  • Extracting a given number of the highest values in a List

    - by James P.
    I'm seeking to display a fixed number of items on a web page according to their respective weight (represented by an Integer). The List where these items are found can be of virtually any size. The first solution that comes to mind is to do a Collections.sort() and to get the items one by one by going through the List. Is there a more elegant solution though that could be used to prepare, say, the top eight items?

    Read the article

  • ASP.NET - Accessing copied content

    - by James Kolpack
    I have a class library project which contains some content files configured with the "Copy if newer" copy build action. This results in the files being copied to a folder under ...\bin\ for every project in the solution. In this same solution, I've got a ASP.NET web project (which is MVC, by the way). In the library I have a static constructor load the files into data structures accessible by the web project. Previously I've been including the content as an embedded resource. I now need to be able to replace them without recompiling. I want to access the data in three different contexts: Unit testing the library assembly Debugging the web application Hosting the site in IIS For unit testing, Environment.CurrentDirectory points to a path containing the copied content. When debugging however, it points to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE. I've also looked at Assembly.GetExecutingAssembly().Location which points to C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\c44f9da4\9238ccc\assembly\dl3\eb4c23b4\9bd39460_f7d4ca01\. What I need is to the physical location of the webroot \bin folder, but since I'm in a static constructor in the library project, I don't have access to a Request.PhysicalApplicationPath. Is there some other environment variable or structure where I can always find my "Copy if newer" files?

    Read the article

  • How do I construct a request for a WCF http post call?

    - by James Hay
    I have a really simple service that I'm messing about with defined by: [OperationContract] [WebInvoke(UriTemplate = "Review/{val}", RequestFormat = WebMessageFormat.Xml, Method = "POST", BodyStyle=WebMessageBodyStyle.Bare)] void SubmitReview(string val, UserReview review); UserReview is, at the moment, a class with no properties. All very basic. When I try and test this in Fiddler I get a bad request status (400) message. I'm trying to call the service using the details: POST http://127.0.0.1:85/Service.svc/Review/hello Headers User-Agent: Fiddler Content-Type: application/xml Host: 127.0.0.1:85 Content-Length: 25 Body <UserReview></UserReview> I would think i'm missing something fairly obvious. Any pointers?

    Read the article

  • Dynamically Rendering in a Scrollable Area

    - by James
    What is the generic algorithm or process that is commonly used to dynamically render portions of a scrolling area? For example, in Google Maps, when the user scrolls past the bounds of the currently rendered area, a grey checkerboard pattern is displayed within the not-yet-rendered portions while the application loads and renders those areas. I'm looking specifically for the approach, or the mathematics, related to filling a graphics area in chunks based on what has just come into view. If possible, I'm looking for anything relevant to the GDI+ process of doing so.

    Read the article

  • URL equals and checking Internet access

    - by James P.
    On http://java.sun.com/j2se/1.5.0/docs/api/java/net/URL.html it states that: Compares this URL for equality with another object. If the given object is not a URL then this method immediately returns false. Two URL objects are equal if they have the same protocol, reference equivalent hosts, have the same port number on the host, and the same file and fragment of the file. Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null. Since hosts comparison requires name resolution, this operation is a blocking operation. Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP. According to this, equals will only work if name resolution is possible. Since I can't be sure that a computer has internet access at a given time, should I just use Strings to store addresses instead? Also, how do I go about testing if access is available when requested?

    Read the article

  • Force VS to use System.[Type] in Code Completion

    - by James
    Is it possible to have Visual Studio code completion use the System.[Type] instead of the keyword. Example: Autocomplete of List<String> myList = completes as: List<String> myList = new List<string>(); whereas, I want: List<String> myList = new List<String>(): This isn't the only example, but hopefully shows what I'm looking for.

    Read the article

  • Find and replace numbers in string with regex

    - by James
    What I'm trying to achieve is to replace the numbers in the string with a new values calculated from the (match * int). So the string input looks like: 500g Flour 14g Salt 7g Dry yeast 45ml Olive oil 309ml Water And the result should look like this: 1000g Flour 14g Salt 14g Dry yeast 90ml Olive oil 618 ml Water row["ingredients"] is a DataRow. This is where I'm at: System.Text.RegularExpressions. Regex.Replace(row["ingredients"].ToString(), @"[^/d]", Delegate(Match match) { return match * 2; }, RegexOptions.Multiline); Any solution is greatly appreciated.

    Read the article

  • Anyone run recurring payments in their website? Preferably; Paypal API

    - by James
    I'm wrapping up my startup and will need to implement Paypal API into my sign up page. Does anyone use recurring payments via Paypal API integrated into their billing? Better yet, guide me to a trustable developer with experience or will I have to use Elance? I need it to go to a welcome/get started screen in their logged in account once they hit the 'create account' button after filling out billing info. I was also wondering, can you leave the CSC (3 digit security code) field out with integration, because it makes things very hard for recurring payments. I'd like to stick with Paypal, as I have been very satisfied with them for a few years now; I already checked out Chargify, authorize.net, etc. I'd love to see someone with something like this set up already to take a look at and ask a few questions.

    Read the article

  • Using virtual fields in Doctrine_Query

    - by James Maroney
    Is there a way to insert logic based on virtual fields into a Doctrine_Query? I have defined a virtual field in my model, "getStatus()" which I would ultimately like to utilize in a Where clause in my Doctrine_Query. ... ->AndWhere('x.status = ?',$status); "status", however, is not a column in the table it is instead computed by business logic in the model. Filtering the Collection after executing the query works in some situations, but not when a Doctrine_Pager is thrown in the mix, as it computes it's offsets and such before you have access to the Collection. Am I best off ditching Doctrine_Pager and rebuilding that functionality after modifying the Doctrine_Collection?

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >