Search Results

Search found 107 results on 5 pages for 'kai qing'.

Page 3/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • How does the rsync algorithm correctly identify repeating blocks?

    - by Kai
    I'm on a personal quest to learn how the rsync algorithm works. After some reading and thinking, I've come up with a situation where I think the algorithm fails. I'm trying to figure out how this is resolved in an actual implementation. Consider this example, where A is the receiver and B is the sender. A = abcde1234512345fghij B = abcde12345fghij As you can see, the only change is that 12345 has been removed. Now, to make this example interesting, let's choose a block size of 5 bytes (chars). Hashing the values on the sender's side using the weak checksum gives the following values list. abcde|12345|fghij abcde -> 495 12345 -> 255 fghij -> 520 values = [495, 255, 520] Next we check to see if any hash values differ in A. If there's a matching block we can skip to the end of that block for the next check. If there's a non-matching block then we've found a difference. I'll step through this process. Hash the first block. Does this hash exist in the values list? abcde -> 495 (yes, so skip) Hash the second block. Does this hash exist in the values list? 12345 -> 255 (yes, so skip) Hash the third block. Does this hash exist in the values list? 12345 -> 255 (yes, so skip) Hash the fourth block. Does this hash exist in the values list? fghij -> 520 (yes, so skip) No more data, we're done. Since every hash was found in the values list, we conclude that A and B are the same. Which, in my humble opinion, isn't true. It seems to me this will happen whenever there is more than one block that share the same hash. What am I missing?

    Read the article

  • Is it possible to unit test methods that rely on NHibernate Detached Criteria?

    - by Aim Kai
    I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached criteria? Test Method [Test] [Category("UnitTest")] public void FindByNameSuccessTest() { //Mock hibernate here var sessionMock = new Mock<ISession>(); var sessionManager = new Mock<ISessionManager>(); var queryMock = new Mock<IQuery>(); var criteria = new Mock<ICriteria>(); var sessionIMock = new Mock<NHibernate.Engine.ISessionImplementor>(); var expectedRestriction = new Restriction {Id = 1, Name="Test"}; //Set up expected returns sessionManager.Setup(m => m.OpenSession()).Returns(sessionMock.Object); sessionMock.Setup(x => x.GetSessionImplementation()).Returns(sessionIMock.Object); queryMock.Setup(x => x.UniqueResult<SopRestriction>()).Returns(expectedRestriction); criteria.Setup(x => x.UniqueResult()).Returns(expectedRestriction); //Build repository var rep = new TestRepository(sessionManager.Object); //Call repostitory here to get list var returnR = rep.FindByName("Test"); Assert.That(returnR.Id == expectedRestriction.Id); } Repository Class public class TestRepository { protected readonly ISessionManager SessionManager; public virtual ISession Session { get { return SessionManager.OpenSession(); } } public TestRepository(ISessionManager sessionManager) { } public SopRestriction FindByName(string name) { var criteria = DetachedCriteria.For<Restriction>().Add<Restriction>(x => x.Name == name) return criteria.GetExecutableCriteria(Session).UniqueResult<T>(); } } Note I am using "NHibernate.LambdaExtensions" and "Castle.Facilities.NHibernateIntegration" here as well. Any help would be gratefully appreciated.

    Read the article

  • UISlider disappearing when calling setValue with 0

    - by Kai
    I have several UISliders in my application which all work fine until I call the following code: ... frame = CGRectMake(43, 210, 201, 23); mySlider = [[UISlider alloc] initWithFrame:frame]; [mySlider addTarget:self action:@selector(sliderUpdate:) forControlEvents:UIControlEventValueChanged]; mySlider.minimumValue = 0.0; mySlider.maximumValue = 1.0; mySlider.continuous = YES; tempNum = [myArray objectAtIndex:2]; mySlider.value = [tempNum floatValue]; // only breaks if value is 0 [self.view addSubview:mySlider]; ... For some reason the slider doesn't show up unless mySlider.value is set to greater than 0. The only workaround I've found so far is to set it to an extremely small value (such as 0.000000001), which makes the slider appear as expected. Does anyone have any idea why this might be happening and how it can be fixed?

    Read the article

  • Blackberry application works in simulator but not device

    - by Kai
    I read some of the similar posts on this site that deal with what seems to be the same issue and the responses didn't really seem to clarify things for me. My application works fine in the simulator. I believe I'm on Bold 9000 with OS 4.6. The app is signed. My app makes an HTTP call via 3G to fetch an XML result. type is application/xhtml+xml. In the device, it gives no error. it makes no visual sign of error. I tell the try catch to print the results to the screen and I get nothing. HttpConnection was taken right out of the demos and works fine in sim. Since it gives no error, I begin to reflect back on things I recall reading back when the project began. deviceside=true? Something like that? My request is simply HttpConnection connection = (HttpConnection)Connector.open(url); where url is just a standard url, no get vars. Based on the amount of time I see the connection arrows in the corner of the screen, I assume the app is launching the initial communication to my server, then either getting a bad result, or it gets results and the persistent store is not functioning as expected. I have no idea where to begin with this. Posting code would be ridiculous since it would be basically my whole app. I guess my question is if anyone knows of any major differences with device versus simulator that could cause something like http connection or persistent store to fail? A build setting? An OS restriction? Any standard procedure I may have just not known about that everyone should do before beginning device testing? Thanks

    Read the article

  • Silverlight MVVM example which does not use data grids?

    - by Aim Kai
    I was wondering if anyone knew of a great example of using the MVVC pattern for a Silverlight application that does not utilise a data grid? Most of the examples I have read see links below and books such as Pro WPF and Silverlight MVVM by Gary Hall use a silverlight application with a datagrid. Don't get me wrong, these are all great examples. See also: MVVM: Tutorial from start to finish? http://www.silverlight.net/learn/tutorials/silverlight-4/using-the-mvvm-pattern-in-silverlight-applications/ However some recent demo projects I have been working are not necessarily dealing with data grids but I would still want to implement this pattern..

    Read the article

  • Read VB binary file with c# (knowing the structure)

    - by Kai
    I'd like to read a file that has been binary saved by a vb prog. the file should be read line by line, 'cause every single line represents an object with many attributes. a link looks the following: 999011011/10/1 ELW the structure of data types is: Public Type FahrzeugDAT Kennung As String * 8 Name As String * 30 Info As String * 50 StatusFzg As Integer DatumFzg As Date StatusLst As Integer DatumLst As Date TKI As Integer Folgetlg As Integer LstKurztext As String * 100 FME1 As String * 5 FME2 As String * 5 FME3 As String * 5 DME1 As String * 8 DME2 As String * 8 DME3 As String * 8 Bemerkung As String * 256 Art As Long Standort As Long End Type

    Read the article

  • How do I use the html 'title' attribute with Html.Encode()?

    - by Kai
    Hello, I've been tryin to find an example of the syntax for getting an html 'title' for a string when using Html.Encode(). I want to display the full name in the mouseover title, if it's too long. Is there a way to do this without wrapping the string in a < span , i.e. <span title = "<%=Html.Encode(model.Name) %>"> //displays the full name on mouseover <%=Html.Encode(model.Name.Substring(0, 10))%>... //displays the name up to a max length </span> Or should I just do it this way? Thanks!

    Read the article

  • Programmatically set ICQ status

    - by Kai
    I'd like to edit/set icq status with a c# app when a certain action occurs. I know there's an API that seems much too oversized for that. Can someone suggest a better way e.g. manipulating a registry value or something? How would you do this?

    Read the article

  • Blackberry Asynchronous HTTP Requests - How?

    - by Kai
    The app I'm working on has a self contained database. The only time I need HTTP request is when the user first loads the app. I do this by calling a class that verifies whether or not a local DB exists and, if not, create one with the following request: HttpRequest data = new HttpRequest("http://www.somedomain.com/xml", "GET", this); data.start(); This xml returns a list of content, all of which have images that I want to fetch AFTER the original request is complete and stored. So something like this won't work: HttpRequest data = new HttpRequest("http://www.somedomain.com/xml", "GET", this); data.start(); HttpRequest images = new HttpRequest("http://www.somedomain.com/xmlImages", "GET", this); images.start(); Since it will not treat this like an asynchronous request. I have not found much information on adding callbacks to httpRequest, or any other method I could use to ensure operation 2 does not execute until operation 1 is complete. Any help would be appreciated. Thanks

    Read the article

  • UI fonts and languages

    - by Kai Sellgren
    I am developing a multilingual web application that has a nice looking UI. I thought using CSS 3's font-face property to make it even nicer UI, but I'm not really sure if that's a good idea. According to some people I have talked to, different languages need different fonts. This means that there is no single font that can display characters of all languages, because the same character may look different across languages. For example, according to Wikipedia, the Unicode code point U+4EE4 looks different in Korean and Japanese languages. So my question is, would it make most sense to contain the fonts within the language packs -- or within the themes of my UI?

    Read the article

  • Flash - playing video

    - by Yippie-Kai-Yay
    Hello! I'm developing a Flash-only application and I want to integrate the flowplayer directly into it, but not on the webpage using some swfobject-like approach. So, at some moment (for example, when arbitrary event fires), I would like to add the flowplayer object to the scene so that it starts streaming the specified video. Does someone know if that is possible? Would the following API (http://releases.flowplayer.org/apidoc-latest/index.html) help me somehow? Thank you.

    Read the article

  • Replace xml tag with regex

    - by Kai
    How can I replace a certain part in a xml file with a definied string? <tag1></tag2> <tag2></tag2> ...etc <soundcard num=0> <name>test123</name> </soundcard> <soundcard num=1> <name>test123</name> </soundcard> <soundcard num=2> <name>test123</name> </soundcard> <tag5></tag5> replace all soundcard parts that the result looks like that: <tag1></tag2> <tag2></tag2> ...etc {0} <tag5></tag5> I'm using c# .net 3.5 and I thougt of a regex solution

    Read the article

  • Are there built-in issue tracking and task management in IDEs that integrate into SourceForge, Googl

    - by Kai Sellgren
    Hi, This question may not be exactly programming related, but this is about development. I have been trying to find IDEs that support JIRA/Bugzilla so that I could simply integrate the IDE with SourceForge. I do not like to refresh my browser to see issues, bug reports, security problems, etc. I would like to send issues, resolve issues, right from the IDE. I am currently developing with NetBeans, but I see no ways of integrating into any of the services provided by SourceForge. Am I missing something?

    Read the article

  • Determining linkage dependencies in Flex applications

    - by Kai
    I have a large Flex project with two Applications in it. A lot of code is shared between these Applications. However, the smaller of the Applications does not require much of the code that the larger one does. I'm trying to ensure that code that isn't required by the smaller application isn't getting compiled into it. Is there an easy way for me to determine which files within my project are being compiled into a particular Application?

    Read the article

  • What (tf) are the secrets behind PDF memory allocation (CGPDFDocumentRef)

    - by Kai
    For a PDF reader I want to prepare a document by taking 'screenshots' of each page and save them to disc. First approach is CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef) someURL); for (int i = 1; i<=pageCount; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; CGPDFPageRef page = CGPDFDocumentGetPage(document, i); ...//getting + manipulating graphics context etc. ... CGContextDrawPDFPage(context, page); ... UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); ...//saving the image to disc [pool drain]; } CGPDFDocumentRelease(document); This results in a lot of memory which seems not to be released after the first run of the loop (preparing the 1st document), but no more unreleased memory in additional runs: MEMORY BEFORE: 6 MB MEMORY DURING 1ST DOC: 40 MB MEMORY AFTER 1ST DOC: 25 MB MEMORY DURING 2ND DOC: 40 MB MEMORY AFTER 2ND DOC: 25 MB .... Changing the code to for (int i = 1; i<=pageCount; i++) { CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef) someURL); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; CGPDFPageRef page = CGPDFDocumentGetPage(document, i); ...//getting + manipulating graphics context etc. ... CGContextDrawPDFPage(context, page); ... UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); ...//saving the image to disc CGPDFDocumentRelease(document); [pool drain]; } changes the memory usage to MEMORY BEFORE: 6 MB MEMORY DURING 1ST DOC: 9 MB MEMORY AFTER 1ST DOC: 7 MB MEMORY DURING 2ND DOC: 9 MB MEMORY AFTER 2ND DOC: 7 MB .... but is obviously a step backwards in performance. When I start reading a PDF (later in time, different thread) in the first case no more memory is allocated (staying at 25 MB), while in the second case memory goes up to 20 MB (from 7). In both cases, when I remove the CGContextDrawPDFPage(context, page); line memory is (nearly) constant at 6 MB during and after all preparations of documents. Can anybody explain whats going on there?

    Read the article

  • Release an object without a pointer?

    - by Kai Friis
    I’ve just started developing for iPhone and am trying to get my head around memory management. I made a small program that shows a map and an annotation on the map. For the annotation I made a simple class that implements the MKAnnotation protocol. To create and add the annotation I wrote this: [self.myMapView addAnnotation:[[MyAnnotation alloc] init]]; It worked fine until I tried to release the object. Nothing to release. This is what I would have done in C#, I guess it doesn’t work without garbage collection? So is this the only way to do it? MyAnnotation *myAnnotation = [[MyAnnotation alloc] init]; [self.myMapView addAnnotation: myAnnotation]; [myAnnotation release];

    Read the article

  • Can I force WPF rendering tier?

    - by Kai Wang
    Is there any way I can force WPF rendering tiers mentioned here? http://msdn.microsoft.com/en-us/library/ms742196.aspx For example I am on tier 2, but I want to simulate the application in tier 1 or 0 scenario.

    Read the article

  • How to save event handlers, when we set new html for element?

    - by Kai
    I have simple html markup: <div id="cont">Some text here <div class="wrap" style="border: 1px solid black;display: inline;"> block element here </div> and another text</div> And jQuery code: $(function(){ $(".wrap").click(function(){ $("#cont").html($("#cont").html().replace(/text/g, "letter")); alert("Click!"); }); $("#d1").click(function(){ alert("#d1 clicked!"); }); }); I expect that click event will be fire any time you clicked by the #d1 div, but when we clicked by .wrap it neve fire again. I understand why it has such behavior, but how to solve it? In my code I can't set click event for #d1 after $("#cont").html($("#cont").html().replace(/text/g, "letter")) because I don't now at execution time if event was set. You can try example on JSBin

    Read the article

  • (Weak) ETags and Last-Modified

    - by Kai Moritz
    As far as I understand the specs, the ETag, which was introduced in RFC 2616 (HTTP/1.1) is a predecessor of the Last-Modified-Header, which is proposet to give the software-architect more controll over the cache-revalidating process. If both Cache-Validation-Headers (If-None-Match and If-Modified-Since) are present, according to RFC 2616, the client (i.e. the browser) should use the ETag when checking, if a resource has changed. According to section 14.26 of RFC 2616, the server MUST NOT respond with a 304 Not Modified, if the ETag presented in a If-None-Match-Header has changed, and the server has to ignore an additional If-Modified-Since-Header, if present. If the presented ETag matches, he MUST NOT perform the request, unless the Date in the Last-Modified-Header says so. (If the presented ETag matches, the server should respond with a 304 Not Modified in case of a GET- or HEAD-request...) This section leaves room for some speculations: A strong ETag is supposed to change ''everytime'', the resource changes. So, having to responde with something else as 304 Not Modified to a request with an unchanged ETag and an If-Modified-Since-Header, which dose not match is a bit of a contradiction, because the strong ETag says, that the resource was not modified. (Though, this is not that fatal, because the server can send the same unchanged resource again.) ... ... o.k. While I was writing this, the question was boiling down to this answer: The (small) contradiction stated above, was made because of Weak ETags. A resource marked with a Weak ETag may have changed, although the ETag has not. So, in case of a Weak ETag it would be wrong, to answer with 304 Not Modified, when the ETag has not changed, but the date presented in the If-Modified-Since does not match, right?

    Read the article

  • Listfield layout question - blackberry

    - by Kai
    I'm having an interesting anomaly when displaying a listfield on the blackberry simulator: The top item is the height of a single line of text (about 12 pixels) while the rest are fine. Does anyone know why only the top item is being drawn this way? Also, when I add an empty venue in position 0, it still displays the first actual venue this way (item in position 1). Not sure what to do. Thanks for any help. The layout looks like this: ----------------------------------- | *part of image* | title | ----------------------------------- | | title | | * full image * | address | | | city, zip | ----------------------------------- The object is called like so: listField = new ListField( venueList.size() ); listField.setCallback( this ); listField.setSelectedIndex(-1); _middle.add( listField ); Here is the drawListRow code: public void drawListRow( ListField listField, Graphics graphics, int index, int y, int width ) { listField.setRowHeight(90); Hashtable item = (Hashtable) venueList.elementAt( index ); String venue_name = (String) item.get("name"); String image_url = (String) item.get("image_url"); String address = (String) item.get("address"); String city = (String) item.get("city"); String zip = (String) item.get("zip"); EncodedImage img = null; try { String filename = image_url.substring( image_url.indexOf("crop/") + 5, image_url.length() ); FileConnection fconn = (FileConnection) Connector.open( "file:///SDCard/Blackberry/project1/" + filename, Connector.READ); if ( !fconn.exists() ) { } else { InputStream input = fconn.openInputStream(); byte[] data = new byte[(int)fconn.fileSize()]; input.read(data); input.close(); if(data.length > 0) { EncodedImage rawimg = EncodedImage.createEncodedImage(data, 0, data.length); int dw = Fixed32.toFP(Display.getWidth()); int iw = Fixed32.toFP(rawimg.getWidth()); int sf = Fixed32.div(iw, dw); img = rawimg.scaleImage32(sf * 4, sf * 4); } else { } } } catch(IOException ef) { } graphics.drawText( venue_name, 140, y, 0, width ); graphics.drawText( address, 140, y + 15, 0, width ); graphics.drawText( city + ", " + zip, 140, y + 30, 0, width ); if(img != null) { graphics.drawImage(0, y, img.getWidth(), img.getHeight(), img, 0, 0, 0); } }

    Read the article

  • simple proof that GUID is not unique

    - by Kai
    I'd like to prove that a GUID is not unique in a simple test program. I expected this to run for hours but it's not working. How can I make it work? BigInteger begin = new BigInteger((long)0); BigInteger end = new BigInteger("340282366920938463463374607431768211456",10); //2^128 for(begin; begin<end; begin++) Console.WriteLine(System.Guid.NewGuid().ToString()); I'm using C#

    Read the article

  • Can no longer debug ActiveX controls in Visual Studio 2008

    - by Phenglei Kai
    For a long time I would throw up a DebugBreak() or ASSERT(false) in the startup code of my ActiveX control, load up IE, go to a localhost page hosting my control, wait for the dialog to show up, then debug my application. I could also launch it under the debugger by setting IE as the container. I tried again for the first time in 2 months and now this no longer works. If I use the ASSERT(false) method, when I get the Visual C++ Debug dialog and click "retry", IE simply closes without any debugger activity. When I try launching from VS2008 and hoping the DebugBreak() will kick in after I load the page, VS2008 does break, but it says either the "RPC Server is Unavailable" or the "RPC Client Call failed." I am never allowed to have my application in the debugger and it doesn't show up in the modules list of VS. The stack trace in VS2008 only contains Microsoft DLLs and modules and not a hint of my code. I assume it's something I've picked up through Windows Update that broke this. Has anyone else ever seen this issue and know how to make it go away? As it stands, I'm now completely unable to debug my ActiveX control.

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >