Search Results

Search found 539 results on 22 pages for 'sean chambers'.

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

  • Callers block until getFoo() has a value ready?

    - by Sean Owen
    I have a Java Thread which exposes a property which other threads want to access: class MyThread extends Thread { private Foo foo; ... Foo getFoo() { return foo; } ... public void run() { ... foo = makeTheFoo(); ... } } The problem is that it takes some short time from the time this runs until foo is available. Callers may call getFoo() before this and get a null. I'd rather they simply block, wait, and get the value once initialization has occurred. (foo is never changed afterwards.) It will be a matter of milliseconds until it's ready, so I'm comfortable with this approach. Now, I can make this happen with wait() and notifyAll() and there's a 95% chance I'll do it right. But I'm wondering how you all would do it; is there a primitive in java.util.concurrent that would do this, that I've missed? Or, how would you structure it? Yes, make foo volatile. Yes, synchronize on an internal lock Object and put the check in a while loop until it's not null. Am I missing anything?

    Read the article

  • Java generics question with wildcards

    - by Sean
    Just came across a place where I'd like to use generics and I'm not sure how to make it work the way I want. I have a method in my data layer that does a query and returns a list of objects. Here's the signature. public List getList(Class cls, Map query) This is what I'd like the calling code to look like. List<Whatever> list = getList(WhateverImpl.class, query); I'd like to make it so that I don't have to cast this to a List coming out, which leads me to this. public <T> List<T> getList(Class<T> cls, Map query) But now I have the problem that what I get out is always the concrete List<WhateverImpl> passed in whereas I'd like it to be the Whatever interface. I tried to use the super keyword but couldn't figure it out. Any generics gurus out there know how this can be done?

    Read the article

  • HTML input not working correctly with AJAX update panels used else where on page

    - by Sean P
    I have some update panels on my page that do some asyncpostbacks to keep some dropdownlists correctly populated. My problem is that on my page i have an HTML input that is handling some file uploads. With the AJAX on the page with asyncpostbacks, and while i step through my code behind, the files arent being uploaded. Using a postbacktrigger (non-async) is not possible because of my layout. Here is my code: <div id="divFileInputs" runat="server"> <input id="file1" name="fileInput" type="file" runat="server" size="50" style="width: 50em" onfocus="AddFileInput()" class="textbox" /></div> <select id="selectFileList" name="ListBox1" size="5" style="width: 50em; text-align: left;" class="textbox" /> <input id="RemoveAttachmentButton" type="button" value="Remove" onclick="RemoveFileInput()" class="removebutton " /> </div> Here is my code behind: Protected Sub CopyAttachments(ByVal issueId As String) Dim files As HttpFileCollection = Request.Files Dim myStream As System.IO.Stream Dim service As New SubmitService.Service For i As Integer = 0 To files.Count - 1 Dim postedFile As HttpPostedFile = files(i) Dim fileNameWithoutPath As String = System.IO.Path.GetFileName(postedFile.FileName) If fileNameWithoutPath.Length > 0 And issueId.Length > 0 Then Dim fileLength As Integer = postedFile.ContentLength Dim fileContents(fileLength) As Byte ' Read the file into the byte array. Send it to the web service. myStream = postedFile.InputStream myStream.Read(fileContents, 0, fileLength) service.ClearQuestAttachToIssue(issueId, fileNameWithoutPath, fileContents) End If Next service = Nothing End Sub When I put a breakpoint in at the declaration of service and then check the value of "files", the count is 0. I am expecting it to be 2 when i have one file uploaded. Anyone know how to fix this?

    Read the article

  • Unit Testing: hard dependency MessageBox.Show()

    - by Sean B
    What ways can the SampleConfirmationDialog be unit tested? The SampleConfirmationDialog would be exercised via acceptance tests, however how could we unit test it, seeing as MessageBox is not abstract and no matching interface? public interface IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> bool? Confirm(); } /// <summary> /// Implementation of a confirmation dialog /// </summary> public class SampleConfirmationDialog : IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> public bool? Confirm() { return MessageBox.Show("do operation x?", "title", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes; } }

    Read the article

  • Point covering problem

    - by Sean
    I recently had this problem on a test: given a set of points m (all on the x-axis) and a set n of lines with endpoints [l, r] (again on the x-axis), find the minimum subset of n such that all points are covered by a line. Prove that your solution always finds the minimum subset. The algorithm I wrote for it was something to the effect of: (say lines are stored as arrays with the left endpoint in position 0 and the right in position 1) algorithm coverPoints(set[] m, set[][] n): chosenLines = [] while m is not empty: minX = min(m) bestLine = n[0] for i=1 to length of n: if n[i][0] <= m and n[i][1] > bestLine[1] then bestLine = n[i] add bestLine to chosenLines for i=0 to length of m: if m <= bestLine[1] then delete m[i] from m return chosenLines I'm just not sure if this always finds the minimum solution. It's a simple greedy algorithm so my gut tells me it won't, but one of my friends who is much better than me at this says that for this problem a greedy algorithm like this always finds the minimal solution. For proving mine always finds the minimal solution I did a very hand wavy proof by contradiction where I made an assumption that probably isn't true at all. I forget exactly what I did. If this isn't a minimal solution, is there a way to do it in less than something like O(n!) time? Thanks

    Read the article

  • Can I retrieve objects from a complex query that limits results to fields from a single table?

    - by Sean Redmond
    I have a model whose rows I always want to sort based on the values in another associated model and I was thinking that the way to implement this would be to use set_dataset in the model. This is causing query results to be returned as hashes rather than objects, though, so none of the methods from the class can be used when iterating over the dataset. I basically have two classes class SortFields < Sequel::Model(:sort_fields) set_primary_key :objectid end class Items < Sequel::Model(:items) set_primary_key :objectid one_to_one :sort_fields, :class => SortFields, :key => :objectid end Some backstory: the data is imported from a legacy system into mysql. The values in sort_fields are calculated from multiple other associated tables (some one-to-many, some many-to-many) according to some complicated rules. The likely solution will be to just add the values in sort_fields to items (I want to keep the imported data separate from the calculated data, but I don't have to). First, though, I just want to understand how far you can go with a dataset and still get objects rather than hashes. If I set the dataset to sort on a field in items like so class Items < Sequel::Model(:items) set_primary_key :objectid one_to_one :sort_fields, :class => SortFields, :key => :objectid set_dataset(order(:sortnumber)) end then the expected clause is added to the generated SQL, e.g.: >> Items.limit(1).sql => "SELECT * FROM `items` ORDER BY `sortnumber` LIMIT 1" and queries still return objects: >> Items.limit(1).first.class => Items If I order it by the associated fields though... class Items < Sequel::Model(:items) set_primary_key :objectid one_to_one :sort_fields, :class => SortFields, :key => :objectid set_dataset( eager_graph(:sort_fields). order(:sort1, :sort2, :sort3) ) end ...I get hashes ?> Items.limit(1).first.class => Hash My first thought was that this happens because all fields from sort_fields are included in the results and maybe if selected only the fields from items I would get Items objects again: class Items < Sequel::Model(:items) set_primary_key :objectid one_to_one :sort_fields, :class => SortFields, :key => :objectid set_dataset( eager_graph(:sort_fields). select(:items.*). order(:sort1, :sort2, :sort3) ) end The generated SQL is what I would expect: >> Items.limit(1).sql => "SELECT `items`.* FROM `items` LEFT OUTER JOIN `sort_fields` ON (`sort_fields`.`objectid` = `items`.`objectid`) ORDER BY `sort1`, `sort2`, `sort3` LIMIT 1" It returns the same rows as the set_dataset(order(:sortnumber)) version but it still doesn't work: >> Items.limit(1).first.class => Hash Before I add the sort fields to the items table so that they can all live happily in the same model, is there a way to tell Sequel to return on object when it wants to return a hash?

    Read the article

  • What doesn't MySQL do? [closed]

    - by sean riley
    When using MySQL 5.1 Enterprise after years of using other database products like Sybase, Infomix, DB2; I run into things that MySQL just doesn't do. For example, it can only generate an EXPLAIN query plan for SELECT queries. What are the other things I should watch out for?

    Read the article

  • Using jQuery to make a group of images appear in order.

    - by Sean Johnson
    I have a page that shows a bunch of thumbnails (around 30), and the client is wanting them to appear one by one, in order, going from left to right on the page. This is what I've tried: var start_opacity = 500; $j('.grid-photo').each(function(i) { start_opacity = start_opacity + 500; setTimeout(function() { $j(i).animate({opacity: 1}, 4000); }, start_opacity); }); It doesn't seem to know what i is referencing. Any thoughts?

    Read the article

  • Strange pattern matching with functions instancing Show

    - by Sean D
    So I'm writing a program which returns a procedure for some given arithmetic problem, so I wanted to instance a couple of functions to Show so that I can print the same expression I evaluate when I test. The trouble is that the given code matches (-) to the first line when it should fall to the second. {-# OPTIONS_GHC -XFlexibleInstances #-} instance Show (t -> t-> t) where show (+) = "plus" show (-) = "minus" main = print [(+),(-)] returns [plus,plus] Am I just committing a motal sin printing functions in the first place or is there some way I can get it to match properly? edit:I realise I am getting the following warning: Warning: Pattern match(es) are overlapped In the definition of `show': show - = ... I still don't know why it overlaps, or how to stop it.

    Read the article

  • Potential issue when using memcache session save handler in PHP

    - by Sean
    I have two load balanced web servers, and I'm using the memcache session save handler with the save path pointing to two memcache servers. It's configured with session redundancy set to two (the number of memcache servers). So PHP is writing session data to both memcache servers, and when I take one of the servers down, everything seems to work fine since the session data has been written to both memcache servers. The problem seems to happen when I use the app for a while with only the one memcache server up, and then bring the other one back up. My theory is that the memcache server comes back up, and PHP then starts asking it for session data which isn't there since it was written to the other server while this one was down. Is there any merit to this theory? Should PHP be asking both servers for the session data and maybe there's some other problem?

    Read the article

  • BtsTask to import policy

    - by Sean
    Hello, I am looking for a way to import BRE generated policy with its' vocabularies into BizTalk application from a command line (in order to script it) leveraging BtsTask command line tool. I've searched around, and couldn't find a firm answer. Thank you.

    Read the article

  • Detectig by how much user has scrolled

    - by Sean
    I have an image pop-up ability on my website (see this screenshot), in order to show users the full resolution picture when they click on a smaller version on the page. This is the current CSS that positions it: div#enlargedImgWrapper { position: absolute; top: 30px; left: 55px; z-index: 999; } The problem now is that if I click on an image further down the page, the window still appears in the top left corner of the page, where I can't see it until I scroll back up. I need it to appear relative to the window, whatever its current position relative to the document is. Note: I don't want to use position: fixed; as some images might be taller than the screen, so I want users to be able to scroll along the image as well. My idea was to use JS to change the top value: var scrollValue = ???; document.getElementById('enlargedImgWrapper').style.top = scrollValue+30 + 'px'; How can I detect by how much the user has scrolled down the page (var scrollValue)? Or is there a 'better' way to do this? Thanks!

    Read the article

  • Any suggestions for improvement on this style for BDD/TDD?

    - by Sean B
    I was tinkering with doing the setups with our unit test specifciations which go like Specification for SUT when behaviour X happens in scenario Y Given that this thing And also this other thing When I do X... Then It should do ... And It should also do ... I wrapped each of the steps of the GivenThat in Actions... any feed back whether separating with Actions is good / bad / or better way to make the GivenThat clear? /// <summary> /// Given a product is setup for injection /// And Product Image Factory Is Stubbed(); /// And Product Size Is Stubbed(); /// And Drawing Scale Is Stubbed(); /// And Product Type Is Stubbed(); /// </summary> protected override void GivenThat() { base.GivenThat(); Action givenThatAProductIsSetupforInjection = () => { var randomGenerator = new RandomGenerator(); this.Position = randomGenerator.Generate<Point>(); this.Product = new Diffuser { Size = new RectangularProductSize( 2.Inches()), Position = this.Position, ProductType = Dep<IProductType>() }; }; Action andProductImageFactoryIsStubbed = () => Dep<IProductBitmapImageFactory>().Stub(f => f.GetInstance(Dep<IProductType>())).Return(ExpectedBitmapImage); Action andProductSizeIsStubbed = () => { Stub<IDisplacementProduct, IProductSize>(p => p.Size); var productBounds = new ProductBounds(Width.Feet(), Height.Feet()); Dep<IProductSize>().Stub(s => s.Bounds).Return(productBounds); }; Action andDrawingScaleIsStubbed = () => Dep<IDrawingScale>().Stub(s => s.PixelsPerFoot).Return(PixelsPerFoot); Action andProductTypeIsStubbed = () => Stub<IDisplacementProduct, IProductType>(p => p.ProductType); givenThatAProductIsSetupforInjection(); andProductImageFactoryIsStubbed(); andProductSizeIsStubbed(); andDrawingScaleIsStubbed(); andProductTypeIsStubbed(); }

    Read the article

  • How to open a document in a separate window from a site map

    - by Sean
    I was hoping to open a document in a menu control using a sitemap. I am using the following code in the sitemap but get an error. I would like to be able to click on the menu item, have it open the sample doc in a new window, but not to have the original page navigate to a new place (essentially to do nothing on the main page.) <siteMapNode url="javascript:widow.open('Sample.doc','SampleName'); return false" title="FAQs" description="FAQs" /> Any idea? Is there some javascript I can use that does not require me to register a function on every page?

    Read the article

  • Wix - set file read access

    - by Sean
    I am looking into a way of setting read access on a specific file for a web application (where all files read option is set to be false--unchecked in IIS) deployed with Wix. Is it a possible option at all or I am asking the question in a wrong way? Thank you.

    Read the article

  • mobile: html5 vs xhtml

    - by Sean
    I am building a mobile app (hybrid mobile web app but with a native shell) with most users on the iphone (some on the blackberry) and am wondering if it should be written in html5 or xhtml? Any insight would be great.

    Read the article

  • How to interpret situations where Math.Acos() reports invalid input?

    - by Sean Ochoa
    Hey all. I'm computing the angle between two vectors, and sometimes Math.Acos() returns NaN when it's input is out of bounds (-1 input && input 1) for a cosine. What does that mean, exactly? Would someone be able to explain what's happening? Any help is appreciated! Here's me method: public double AngleBetween(vector b) { var dotProd = this.Dot(b); var lenProd = this.Len*b.Len; var divOperation = dotProd/lenProd; // http://msdn.microsoft.com/en-us/library/system.math.acos.aspx return Math.Acos(divOperation) * (180.0 / Math.PI); }

    Read the article

  • java overloaded method

    - by Sean Nguyen
    Hi, I have an abstract template method: class abstract MyTemplate { public void something(Object obj) { doSomething(obj) } protected void doSomething(Object obj); } class MyImpl extends MyTemplate { protected void doSomething(Object obj) { System.out.println("i am dealing with generic object"); } protected void doSomething(String str) { System.out.println("I am dealing with string"); } } public static void main(String[] args) { MyImpl impl = new MyImpl(); impl.something("abc"); // --> this return "i am dealing with generic object" } How can I print "I am dealing with string" w/o using instanceof in doSomething(Object obj)? Thanks,

    Read the article

  • Rspec > testing database views

    - by Sean McCleary
    How can database views be tested in Rspec? Every scenario is wrapped in a transaction and the data does not look like it is being persisted to the database (MySQL in my case). My view returns with an empty result set because none of the records are being persisted in the transaction. I am validating that the records are not being stored by setting a debug point in my spec and checking my data with a database client while the spec is being debugged. The only way I can think to have my view work would be if I could commit the transaction before the end of the scenario and then clear the database after the scenario is complete. Does anyone know how to accomplish this or is there a better way? Thanks

    Read the article

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