Search Results

Search found 1642 results on 66 pages for 'dan morgan'.

Page 38/66 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • How to get ANTLR 3.2 to exit upon first error?

    - by Dan Becker
    In section 10.4, The Definitive ANTLR reference tells you to override mismatch() & recoverFromMismatchedSet() if you want to exit upon the first parsing error. But, at least in ANTLR 3.2, it appears that there is no mismatch() method, and the recoverFromMismatchedSet() documentation says that it is "Not Currently Used". So it appears things have changed since the book was published. What am I supposed to do instead to exit upon the first parsing error in ANTLR 3.2?

    Read the article

  • How can I add an Items-like property to my User Control?

    - by Dan Tao
    It's pretty straightforward to add simple properties to a User Control that will appear in the desired categories in the Windows Forms designer, e.g.: [Category("Appearance")] public Color BackColor { get { return _textBox.BackColor; } set { _textBox.BackColor = value; } } What if I want to expose a more complex property, such as a collection of items of a type I define? I'm thinking something along the lines of the ListView.Items property, or the DataGridView.Columns property -- where the user of the control can access this complex property via a more specialized pop-up form (as opposed to a simple TextBox or ComboBox). Even a simple nudge in the right direction would be much appreciated.

    Read the article

  • Binding a list belonging to another object in a custom model binder in ASP.NET MVC

    - by Dan
    I realize something like this has been asked, but this may be a little different Below is my Event object: Event : IEvent public int Id public string Title public List<EventContact> Contacts And EventContact: EventContact public int Id public string Name So, an Event has a list of EventContact' objects. Now, Event also implements IEvent - hence the custom model binder. I useIEventinstead of Event, so when the default model binder tries to do its thing, it lets me know it can't create anIEvent'. I have my view with populated with the contact info: <input type="text" name="contact[0].Name" value="DB Value"/> <input type="text" name="contact[1].Name" value="DB Value"/> <input type="text" name="contact[2].Name" value="DB Value"/> <!-- Event fields, etc --> So, in my custom model binder I am able to see all the value - sweet! The only thing is, I'm really not sure how to get all the contact fields and create a list of contacts from them, along with binding all the Event fields. Any and all help is appreciated!

    Read the article

  • Using the erlang mysql module, how is a database connection closed?

    - by Dan
    In using the erlang mysql module the exposed external functions are: %% External exports -export([start_link/5, start_link/6, start_link/7, start_link/8, start/5, start/6, start/7, start/8, connect/7, connect/8, connect/9, fetch/1, fetch/2, fetch/3, prepare/2, execute/1, execute/2, execute/3, execute/4, unprepare/1, get_prepared/1, get_prepared/2, transaction/2, transaction/3, get_result_field_info/1, get_result_rows/1, get_result_affected_rows/1, get_result_reason/1, encode/1, encode/2, asciz_binary/2 ]). From the this this, it is not apparent how to close a connection. How a connection closed?

    Read the article

  • What languages have a while-else type control structure, and how does it work?

    - by Dan
    A long time ago, I thought I saw a proposal to add an else clause to for or while loops in C or C++... or something like that. I don't remember how it was supposed to work -- did the else clause run if the loop exited normally but not via a break statement? Anyway, this is tough to search for, so I thought maybe I could get some CW answers here for various languages. What languages support adding an else clause to something other than an if statement? What is the meaning of that clause? One language per answer please.

    Read the article

  • How to customize the appearance of a tab bar?

    - by Dan Harrelson
    I am looking to customize the appearance of a tab bar. Specifically I want to: Change the default tabBar color Add a custom image on top of the tabBar Add custom images to tabBarButtons Change the font of tabBarButtons In a nutshell, I want all of the functionality of a tab bar but with a completely custom look. Should I start subclassing elements, or using categories or what?

    Read the article

  • Accessing previous activity instances in a sequence activity

    - by Dan Revell
    This has a rather SharePoint spin to it but the problem is straight workflow. I've got a parallel replication activity which contains a sequence activity. The sequence activity contains a CreateTask activity, a CodeActivity, a OnTaskChanged activity and finally a CompleteTask activity. The idea is to create a task for each username passed into the ReplicatorActivity.InitialChildData property. Typically in workflow I bind a field to the CreateTask.TaskId and CreateTask.TaskProperties and inside the CreateTask.MethodInvoking I set these through the local bound fields. This works and my tasks all get created properly. However in the CodeActivity that follows, I want to then access the TaskProperties. The problem I am encountering is that this field holds the values of the final task to be created as the CreateTask runs for all the replications before the CodeActivity gets to runs. From the CodeActivity, here are two ways I've tried to access the CreateTask activity instance from the same context or instance or whatever the terminology is for the replicated sequence. CreateTask task = ((CreateTask)sender.Parent.GetActivityByName("createSoftwareRequestTask", true)); CreateTask createTask = (CreateTask)sender.Parent.Activities[0]; Unfortunately the CreateTask activities both refer back to the last task to be created and not the task from the context that the CodeActivity is executing within. Two reasons why this might be that I can think of. I'm not accessing the correct instance with my code. I am accessing the correct instance, but as the properties I require were bound to and set through local fields then their previous data was overwritten. I'm hitting a brick wall with my understanding of workflow with this and would very much appreciate some assistance here.

    Read the article

  • How do I create an ImageView in java code, within an existing Layout?

    - by Dan T
    I'm looking for an easy way for the user to see how many drinks they've had for a BAC calculator. PICTURE OF THE APP, for reference On button press, I would like an image to be added to the screen, directly under the spinner and with left alignment. When I press the button again, I want another image to be added to the screen. So if I pressed the add beer button, a drawable of a beer would appear below the spinner. If I pressed the add beer button again, I want there to be TWO drawables of beers under the spinner, preferably with them being added from the right. (Also, having them reach their width limit, wrapping around, and starting again on the left, but below a full line, would be AWESOME) I can't figure out how to do this. I assume adding a ImageView in code to a relative layout (because it needs to be positioned to the right) would be the best route, but if it's possible in xml I'd be more than happy to use that. Any help?

    Read the article

  • using SET datatype in mysql

    - by Dan Snyder
    Is it possible to set a varaible to a query result such as: DECLARE result INT; SET result = (SELECT index FROM table WHERE data = 'xxxx' LIMIT 1); Assuming of course you know that there will only be one result set

    Read the article

  • Focus behavior in Applet-Javascript interaction

    - by Dan
    I have a web page with an applet that opens a popup window and also makes Javascript calls. When that Javascript call results in a focus() call on an HTML input, that causes the browser window to push itself in front of the applet window. But only on certain browsers, namely MSIE. On Firefox the applet window remains on top. How can I keep that behavior consistent in MSIE? Note that using the old Microsoft VM for Java also achieves the desired (applet window in front) result. HTML code: <html> <head> <script type="text/javascript"> function focusMe() { document.getElementById('mytext').focus(); } </script> </head> <body> <applet id="myapplet" mayscript code="Popup.class" ></applet> <form> <input type="text" id="mytext"> <input type="button" onclick="document.getElementById('myapplet').showPopup()" value="click"> </form> </body> </html> Java code: public class Popup extends Applet { Frame frame; public void start() { frame = new Frame("Test Frame"); frame.setLayout(new BorderLayout()); Button button = new Button("Push Me"); frame.add("Center", button); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { frame.setVisible(false); } }); frame.pack(); } public void showPopup() { frame.setVisible(true); JSObject.getWindow(this).eval("focusMe()"); } }

    Read the article

  • Best way to implement keywords for image upload gallery

    - by Dan Berlyoung
    I'm starting to spec out an image gallery type system similar to Facebook's. Members of the site will be able to create image galleries and upload images for others to view. Images will have keywords the the uploader can specify. Here's the question, what's the best way to model this? With image and keyword tables linked vi a HABTM relation? Or a single image table with the keywords saved as comma delimited values in a text field in the image record? Then search them using a LIKE or FULL TEXT index function? I want to be able to pull up all images containing a given keyword as well as generate a keyword cloud. I'm leaning toward the HABTM setup but I wanted to see what everyone else though. Thanks!!

    Read the article

  • PHP / MySQL - How to retrieve 2 separate sets of objects?

    - by Dan
    Hi, I have a set of models which correspond to tables in my database. I have been retrieving them easily enough, for example. $result = $mysqli->query('SOME SQL'); $post = $result->fetch_object; What would be the best approach for performing a join and also returning the related objects? For example, each post is created by a user, so for each row returned in the joined statement, both a page and user object should be returned. Any advice appreciated. Thanks.

    Read the article

  • Hierarchy / Flyweight / Instancing Problem in Python

    - by Dan
    Here is the problem I am trying to solve, (I have simplified the actual problem, but this should give you all the relevant information). I have a hierarchy like so: 1.A 1.B 1.C 2.A 3.D 4.B 5.F (This is hard to illustrate - each number is the parent, each letter is the child). Creating an instance of the 'letter' objects is expensive (IO, database costs, etc), so should only be done once. The hierarchy needs to be easy to navigate. Children in the hierarchy need to have just one parent. Modifying the contents of the letter objects should be possible directly from the objects in the hierarchy. There needs to be a central store containing all of the 'letter' objects (and only those in the hierarchy). 'letter' and 'number' objects need to be possible to create from a constructor (such as Letter(**kwargs) ). It is perfectably acceptable to expect that when a letter changes from the hierarchy, all other letters will respect the same change. Hope this isn't too abstract to illustrate the problem. What would be the best way of solving this? (Then I'll post my solution) Here's an example script: one = Number('one') a = Letter('a') one.addChild(a) two = Number('two') a = Letter('a') two.addChild(a) for child in one: child.method1() for child in two: print '%s' % child.method2()

    Read the article

  • Setting up functional Tests in Flex

    - by Dan Monego
    I'm setting up a functional test suite for an application that loads an external configuration file. Right now, I'm using flexunit's addAsync function to load it and then again to test if the contents point to services that exist and can be accessed. The trouble with this is that having this kind of two (or more) stage method means that I'm running all of my tests in the context of one test with dozens of asserts, which seems like a kind of degenerate way to use the framework, and makes bugs harder to find. Is there a way to have something like an asynchronous setup? Is there another testing framework that handles this better?

    Read the article

  • JavaScript data formatting/pretty printer

    - by Dan
    I'm trying to find a way to 'pretty print' a JavaScript data structure in a human-readable form for debugging. I have a rather big and complicated data structure being stored in JS and I need to write some code to manipulate it. In order to work out what I'm doing and where I'm going wrong, what I really need is to be able to see the data structure in its entirety, and update it whenever I make changes through the UI. All of this stuff I can handle myself, apart from finding a nice way to dump a JavaScript data structure to a human-readable string. JSON would do, but it really needs to be nicely formatted and indented. I'd usually use Firebug's excellent DOM dumping stuff for this, but I really need to be able to see the entire structure at once, which doesn't seem to be possible in Firebug. Any suggestions welcome, thanks in advance.

    Read the article

  • Change Layout Of Text Created In Java [Android]

    - by Dan
    Ok right , i asked how to create a random number from 1-100 for android and i came to this TextView tv = new TextView(this); int random = (int)Math.ceil(Math.random()*101); tv.setText("Your Number Is..."+ random ); What this does is create the default kinda "hello world" style text view and says "Your Number Is.... [Then Random Number] My problem is that i cant change the layout of this text , because it is not defined in XML, if someone could tell me how to change the style , or like make the random number into a string so i could use it for any Textview layout that would be great .. Thanks :)

    Read the article

  • Streaming video using non standard protocols

    - by Dan
    Hi - My company makes DVRs that specialize in streaming live and recorded video. The video is encoded using standard MPEG-4 codecs so the codecs in Android should have no trouble with them. However, the video is recorded using non-standard file formats and is streamed using our proprietary protocol (among other things we embed additional data such as watermarks with each frame of video). Is there any way I can take my stream pull out the frames and have it play on an Android device? Thanks!

    Read the article

  • How to access and run field events from extension js?

    - by Dan Roberts
    I have an extension that helps in submitting forms automatically for a process at work. We are running into a problem with dual select boxes where one option is selected and then that selection changes another field's options. Since setting an option selected property to true doesn't trigger the field's onchange event I am trying to do so through code. The problem I've run into is that if I try to access or run functions on the field object from the extension, I get the error Error: uncaught exception: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: chrome://webformsidebar/content/webformsidebar.js :: WebFormSidebar_FillProcess :: line 499" data: no] the line causing the error is... if (typeof thisField.onchange === 'function') The line right before it works just fine... thisField.options[t].selected=true; ...so I'm not sure why this is resulting in such an error. What surprises me most I guess is that checking for the existence of the function leads to an error. It feels like the problem is related to the code running in the context of the extension instead of the browser window document. If so, is there any way to call a function in the browser window context instead? Do I need to actually inject code into the page somehow? Any other ideas? Thanks

    Read the article

  • C# TcpClient, getting back the entire response from a telnet device

    - by Dan Bailiff
    I'm writing a configuration tool for a device that can communicate via telnet. The tool sends a command via TcpClient.GetStream().Write(...), and then checks for the device response via TcpClient.GetStream().ReadByte(). This works fine in unit tests or when I'm stepping through code slowly. If I run the config tool such that it performs multiple commands consecutively, then the behavior of the read is inconsistent. By inconsistent I mean sometimes the data is missing, incomplete or partially garbled. So even though the device performed the operation and responded, my code to check for the response was unreliable. I "fixed" this problem by adding a Thread.Sleep to make sure the read method waits long enough for the device to complete its job and send back the whole response (in this case 1.5 seconds was a safe amount). I feel like this is wrong, blocking everything for a fixed time, and I wonder if there is a better way to get the read method to wait only long enough to get the whole response from the device. private string Read() { if (!tcpClient.Connected) throw (new Exception("Read() failed: Telnet connection not available.")); StringBuilder sb = new StringBuilder(); do { ParseTelnet(ref sb); System.Threading.Thread.Sleep(1500); } while (tcpClient.Available > 0); return sb.ToString(); } private void ParseTelnet(ref StringBuilder sb) { while (tcpClient.Available > 0) { int input = tcpClient.GetStream().ReadByte(); switch (input) { // parse the input // ... do other things in special cases default: sb.Append((char)input); break; } } }

    Read the article

  • Force close message when preferences are called via menu button

    - by Dan T
    I see no problem in the code. Help? preferences.xml <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <ListPreference android:title="Gender" android:summary="Are you male or female?" android:key="genderPref" android:defaultValue="male" android:entries="@array/genderArray" android:entryValues="@array/genderValues" /> <ListPreference android:title="Weight" android:summary="How much do you weigh?" android:key="weightPref" android:defaultValue="180" android:entries="@array/weightArray" android:entryValues="@array/weightValues" /> </PreferenceScreen> arrays.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="genderArray"> <item>Male</item> <item>Female</item> </string-array> <string-array name="genderValues"> <item>male</item> <item>female</item> </string-array> <string-array name="weightArray"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> <string-array name="weightValues"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> </resources> Preferences.java: package com.dantoth.drinkingbuddy; import android.os.Bundle; import android.preference.PreferenceActivity; public class Preferences extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); }; } butts.xml (idk why it's butts but I've gotten used to it now. really just sets up the menu button) <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/settings" android:title="Settings" android:icon="@drawable/ic_menu_settings" /> <item android:id="@+id/archive" android:title="Archive" android:icon="@drawable/ic_menu_archive" /> <item android:id="@+id/new_session" android:title="New Session" android:icon="@drawable/ic_menu_new" /> <item android:id="@+id/about" android:title="About" android:icon="@drawable/ic_menu_about" /> </menu> within DrinkingBuddy.java: @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: startActivity(new Intent(this, Preferences.class)); return true; case R.id.archive: Toast.makeText(this, "Expect to see your old drinking sessions here.", Toast.LENGTH_LONG).show(); return true; //ETC. } return false; That's it. I can press the menu button on the phone and see the menu items I created, but when I click on the "Settings" (r.id.settings) it FC. Do I have to do anything to the manifest/other thing to get this to work??

    Read the article

  • Calling system commands from Perl

    - by Dan J
    In an older version of our code, we called out from Perl to do an LDAP search as follows: # Pass the base DN in via the ldapsearch-specific environment variable # (rather than as the "-b" paramater) to avoid problems of shell # interpretation of special characters in the DN. $ENV{LDAP_BASEDN} = $ldn; $lcmd = "ldapsearch -x -T -1 -h $gLdapServer" . <snip> " > $lworkfile 2>&1"; system($lcmd); if (($? != 0) || (! -e "$lworkfile")) { # Handle the error } The code above would result in a successful LDAP search, and the output of that search would be in the file $lworkfile. Unfortunately, we recently reconfigured openldap on this server so that a "BASE DC=" is specified in /etc/openldap/ldap.conf and /etc/ldap.conf. That change seems to mean ldapsearch ignores the LDAP_BASEDN environment variable, and so my ldapsearch fails. I've tried a couple of different fixes but without success so far: (1) I tried going back to using the "-b" argument to ldapsearch, but escaping the shell metacharacters. I started writing the escaping code: my $ldn_escaped = $ldn; $ldn_escaped =~ s/\/\\/g; $ldn_escaped =~ s/`/\`/g; $ldn_escaped =~ s/$/\$/g; $ldn_escaped =~ s/"/\"/g; That threw up some Perl errors because I haven't escaped those regexes properly in Perl (the line number matches the regex with the backticks in). Backticks found where operator expected at /tmp/mycommand line 404, at end of line At the same time I started to doubt this approach and looked for a better one. (2) I then saw some Stackoverflow questions (here and here) that suggested a better solution. Here's the code: print("Processing..."); # Pass the arguments to ldapsearch by invoking open() with an array. # This ensures the shell does NOT interpret shell metacharacters. my(@cmd_args) = ("-x", "-T", "-1", "-h", "$gLdapPool", "-b", "$ldn", <snip> ); $lcmd = "ldapsearch"; open my $lldap_output, "-|", $lcmd, @cmd_args; while (my $lline = <$lldap_output>) { # I can parse the contents of my file fine } $lldap_output->close; The two problems I am having with approach (2) are: a) Calling open or system with an array of arguments does not let me pass > $lworkfile 2>&1 to the command, so I can't stop the ldapsearch output being sent to screen, which makes my output look ugly: Processing...ldap_bind: Success (0) additional info: Success b) I can't figure out how to choose which location (i.e. path and file name) to the file handle passed to open, i.e. I don't know where $lldap_output is. Can I move/rename it, or inspect it to find out where it is (or is it not actually saved to disk)? Based on the problems with (2), this makes me think I should return back to approach (1), but I'm not quite sure how to

    Read the article

  • Use QuickCheck by generating primes

    - by Dan
    Background For fun, I'm trying to write a property for quick-check that can test the basic idea behind cryptography with RSA. Choose two distinct primes, p and q. Let N = p*q e is some number relatively prime to (p-1)(q-1) (in practice, e is usually 3 for fast encoding) d is the modular inverse of e modulo (p-1)(q-1) For all x such that 1 < x < N, it is always true that (x^e)^d = x modulo N In other words, x is the "message", raising it to the eth power mod N is the act of "encoding" the message, and raising the encoded message to the dth power mod N is the act of "decoding" it. (The property is also trivially true for x = 1, a case which is its own encryption) Code Here are the methods I have coded up so far: import Test.QuickCheck -- modular exponentiation modExp :: Integral a => a -> a -> a -> a modExp y z n = modExp' (y `mod` n) z `mod` n where modExp' y z | z == 0 = 1 | even z = modExp (y*y) (z `div` 2) n | odd z = (modExp (y*y) (z `div` 2) n) * y -- relatively prime rPrime :: Integral a => a -> a -> Bool rPrime a b = gcd a b == 1 -- multiplicative inverse (modular) mInverse :: Integral a => a -> a -> a mInverse 1 _ = 1 mInverse x y = (n * y + 1) `div` x where n = x - mInverse (y `mod` x) x -- just a quick way to test for primality n `divides` x = x `mod` n == 0 primes = 2:filter isPrime [3..] isPrime x = null . filter (`divides` x) $ takeWhile (\y -> y*y <= x) primes -- the property prop_rsa (p,q,x) = isPrime p && isPrime q && p /= q && x > 1 && x < n && rPrime e t ==> x == (x `powModN` e) `powModN` d where e = 3 n = p*q t = (p-1)*(q-1) d = mInverse e t a `powModN` b = modExp a b n (Thanks, google and random blog, for the implementation of modular multiplicative inverse) Question The problem should be obvious: there are way too many conditions on the property to make it at all usable. Trying to invoke quickCheck prop_rsa in ghci made my terminal hang. So I've poked around the QuickCheck manual a bit, and it says: Properties may take the form forAll <generator> $ \<pattern> -> <property> How do I make a <generator> for prime numbers? Or with the other constraints, so that quickCheck doesn't have to sift through a bunch of failed conditions? Any other general advice (especially regarding QuickCheck) is welcome.

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >