Search Results

Search found 782 results on 32 pages for 'bart van heukelom'.

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

  • How to find out if an object's type implements IEnumerable<X> where X derives from Base using Reflec

    - by Dave Van den Eynde
    Give a base class "Base", I want to write a method Test, like this: private static bool Test(IEnumerable enumerable) { ... } such that Test returns true if the type of o implements any interface of IEnumerable where X derives from Base, so that if I would do this: public static IEnumerable<string> Convert(IEnumerable enumerable) { if (Test(enumerable)) { return enumerable.Cast<Base>().Select(b => b.SomePropertyThatIsString); } return enumerable.Cast<object>().Select(o => o.ToString()); } ...that it would do the right thing, using Reflection. I'm sure that its a matter of walking across all the interfaces of the type to find the first that matches the requirements, but I'm having a hard time finding the generic IEnumerable< among them. Of course, I could consider this: public static IEnumerable<string> Convert(IEnumerable enumerable) { return enumerable.Cast<object>().Select(o => o is Base ? ((Base)o).SomePropertyThatIsString : o.ToString()); } ...but think of it as a thought experiment.

    Read the article

  • Can a single developer still make money with shareware?

    - by Wouter van Nifterick
    I'm wondering if the shareware concept is dead nowadays. Like most developers, I've built up quite a collection of self-made tools and code libraries that help me to be productive. Some examples to give you an idea of the type of thing I'm talking about: A self-learning program that renames and orders all my mp3 files and adds information to the id3 tags; A Delphi component that wraps the Google Maps API; A text-to-singing-voice converter for musical purposes; A program to control a music synthesizer; A Gps-log <- KML <- ESRI-shapefile converter; I've got one of these already freely downloadable on my website, and on average it gets downloaded about a 150 times per month. Let's say I'd start charging 15 euro's for it; would there actually be people who buy it? How many? What would it depend on? If I could get some money for some of these, I'd finish them up a bit and put them online, but without that, I probably won't bother. Maintaining a SourceForge project is not very rewarding by itself. Is there anyone who is making money with shareware? How much? Any tips?

    Read the article

  • Implement F3 Find Next using TFindDialog

    - by Pieter van Wyk
    Hi I've implemented a search using the TFindDialog on my form. Everything works well except that I cannot find a way to mimic the "F3 - Find Next" behaviour as in Notepad. Once you have entered a search string, pressing F3 finds the next instance without opening the search dialog. Regards, Pieter.

    Read the article

  • How does one properly redefine self while avoiding the "Multiple methods named ..." warning?

    - by Elise van Looij
    In Apple's The Objective-C Programming Language: Defining a Class the section named "Redifining self" recommends that that class methods allocate and return instances use 'self' only to allocate an instance and then refer only to that instance. Thus, I have a number of subclasses, that have class methods along the lines of: + (id)scrollViewWithFrame: (NSRect)rectFrame { id newInstance = [[[self alloc] initWithFrame:rectFrame] autorelease]; [newInstance setHasHorizontalScroller: YES]; [newInstance setHasVerticalScroller: YES]; [newInstance setBorderType: NSNoBorder]; [newInstance setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; return newInstance; } The above is, of course, a subclass of NSScrollView. Unfortunately, Xcode 3.x all these NSView subclasses now raise warnings: "Warning: Multiple methods named '-setAutoresizingMask' found". I believe it has something to do with GCC 4.2, the settings of which I have not changed. The warning is correct, of course, since NSView and its various subclasses all implement setAutoresizingMask, but it is also unnecessary. Since they're only warnings, I ignore them but there is a risk that in between the thirty or so unnecessary ones, a really useful warning lurks which I simply don't see. So, what to do? I do want to adhere to good coding practices and I want to build warning-free apps -- how can I do both?

    Read the article

  • EXEC_BAD_ACCESS in UITableView cellForRowAtIndexPath

    - by David van Dugteren
    My UITable is returning EXEC_BAD_ACCESS, but why! See this code snippet! Loading the UITableView works fine, so allXYZArray != nil and is populated! Then scrolling the tableview to the bottom and back up causes it to crash, as it goes to reload the method cellForRowAtIndexPath It fails on line: "NSLog(@"allXYZArray::count: %i", [allXYZArray count]);" - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; @try { if (allAdviceArray == nil) { NSLog(@"nil"); allXYZArray = [ToolBox getMergedSortedDictionaries:allXYZGiven SecondDictionary:allXYZSought]; } NSLog(@"%i", [indexPath row]); NSLog(@"allXYZArray::count: %i", [allXYZArray count]);

    Read the article

  • asp.net InsertCommand to return latest insert ID

    - by Stijn Van Loo
    Dear all, I'm unable to retrieve the latest inserted id from my SQL Server 2000 db using a typed dataset in asp.NET I have created a tableadapter and I ticked the "Refresh datatable" and "Generate Insert, Update and Delete statements". This auto-generates the Fill and GetData methods, and the Insert, Update, Select and Delete statements. I have tried every possible solution in this thread http://forums.asp.net/t/990365.aspx but I'm still unsuccesfull, it always returns 1(=number of affected rows). I do not want to create a seperate insert method as the auto-generated insertCommand perfectly suits my needs. As suggested in the thread above, I have tried to update the InsertCommand SQL syntax to add SELECT SCOPY_IDENTITY() or something similar, I have tried to add a parameter of type ReturnValue, but all I get is the number of affected rows. Does anyone has a different take on this? Thanks in advance! Stijn

    Read the article

  • iPhone - Have the keyboard slide into view from the right like when editing a note in Contacts

    - by Toon Van Acker
    Hello, I'm looking for a way to slide the keyboard into view from the right, like what happens in the Contacts application when you edit a note. My problem is that when I call [someTextView becomeFirstResponder] in viewWillAppear, the keyboard immediatly pops up with no animation. And when I call it in viewDidAppear, the view first slides in from the right (UINavigationController does the sliding), and then the keyboard slides in from the bottom. Is it possible to have the keyboard slide in from the right, together with the view?

    Read the article

  • Websql to google maps markers

    - by Roy van Neden
    I am busy with my web application for a school project. It has has two pages. The first page uploads the location(latitude and longitude), price, date and kind of fuel. It works and i saved it with websql.(see screenshot) Now i want to get everything out of the web database and put it as a marker on my google maps card. I have my own location already. But i dont know how to get everything from the database to the map as a marker. I'm using jquery mobile/html5/css/javascript only. Code to put it in a array or something else that will work. db.transaction(function(tx){ tx.executeSql('SELECT brandstofsoort, literprijs, datum, latitude, longitude FROM brandstofstatus', [], function (tx, results) { var lengte = results.rows.length, i; for(var i = 0; i< lengte; i++){ var locations = [ [ ], [ ], [ ], [ ], [ ] ]; } // / for loop });// /tx.executeSql });// /db.transaction Thanks in advance!

    Read the article

  • NSXMLParser rss issue NSXMLParserInvalidCharacterError

    - by Chris Van Buskirk
    NSXMLParserInvalidCharacterError # 9 This is the error I get when I hit a weird character (like quotes copied and pasted from word to the web form, that end up in the feed). The feed I am using is not giving an encoding, and their is no hope for me to get them to change that. This is all I get in the header: < ?xml version="1.0"? < rss version="2.0" What can I do about illegal characters when parsing feeds? Do I sweep the data prior to the parse? Is there something I am missing in the API? Has anyone dealt with this issue?

    Read the article

  • How can SAP tRFC server tell client through JCo that function has been carried out?

    - by Hendrik Jan van Randen
    SAPs "Transactional RFC Technical Description" document (release 4.0, see http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/ee6bca90-0201-0010-5792-d9693e2eac83?QuickLink=index&overridelayout=true ) says in section Transactional RFC on page 6: "Finally, the server tells the client, that the function has been carried out and the client acknowledges this.". How can the server tell this to the client when the server communicates with the client through JCo (Java Connector)?

    Read the article

  • Inherit a parent class docstring as __doc__ attribute

    - by Reinout van Rees
    There is a question about Inherit docstrings in Python class inheritance, but the answers there deal with method docstrings. My question is how to inherit a docstring of a parent class as the __doc__ attribute. The usecase is that Django rest framework generates nice documentation in the html version of your API based on your view classes' docstrings. But when inheriting a base class (with a docstring) in a class without a docstring, the API doesn't show the docstring. It might very well be that sphinx and other tools do the right thing and handle the docstring inheritance for me, but django rest framework looks at the (empty) .__doc__ attribute. class ParentWithDocstring(object): """Parent docstring""" pass class SubClassWithoutDoctring(ParentWithDocstring): pass parent = ParentWithDocstring() print parent.__doc__ # Prints "Parent docstring". subclass = SubClassWithoutDoctring() print subclass.__doc__ # Prints "None" I've tried something like super(SubClassWithoutDocstring, self).__doc__, but that also only got me a None.

    Read the article

  • iPhone: NSHTTPCookie is not saved across app restarts

    - by Tom van Zummeren
    In my iPhone app, I want to be able to reuse the same server-side session when my app restarts. A session on the server is identified by a cookie, which is sent on each request. When I restart the app, that cookie is gone and I can't use the same session anymore. What I noticed when I used the NSHTTPCookieStorage to look up the cookie I got from the server, is that [cookie isSessionOnly] returns YES. I get the impression that this is why cookies are not saved across restarts of my app. What would I have to do to make my cookie NOT session only? What HTTP headers do I have to send from the server?

    Read the article

  • Circular Shifts on Strings in Bash

    - by Kyle Van Koevering
    I have a homework assignment where I need to take input from a file and continuously remove the first word in a line and append it to the end of the line until all combinations have been done. I really don't know where to begin and would be thankful for any sort of direction. The part that has me confused is that this is suppose to be performed without the use of arrays. I'm not just fishing for someone to solve the problem for me, I'm just looking for some direction. Thank you very much for your time and help. SAMPlE INPUT: Pipes and Filters Java Swing Software Requirements Analysis SAMPLE OUTPUT: Analysis Software Requirements Filters Pipes and Java Swing Pipes and Filters Requirements Analysis Software Software Requirements Analysis Swing Java

    Read the article

  • How to get this Qt state machine to work?

    - by Ton van den Heuvel
    I have two widgets that can be checked, and a numeric entry field that should contain a value greater than zero. Whenever both widgets have been checked, and the numeric entry field contains a value greater than zero, a button should be enabled. I am struggling with defining a proper state machine for this situation. So far I have the following: QStateMachine *machine = new QStateMachine(this); QState *buttonDisabled = new QState(QState::ParallelStates); buttonDisabled->assignProperty(ui_->button, "enabled", false); QState *a = new QState(buttonDisabled); QState *aUnchecked = new QState(a); QFinalState *aChecked = new QFinalState(a); aUnchecked->addTransition(wa, SIGNAL(checked()), aChecked); a->setInitialState(aUnchecked); QState *b = new QState(buttonDisabled); QState *bUnchecked = new QState(b); QFinalState *bChecked = new QFinalState(b); employeeUnchecked->addTransition(wb, SIGNAL(checked()), bChecked); b->setInitialState(bUnchecked); QState *weight = new QState(registerButtonDisabled); QState *weightZero = new QState(weight); QFinalState *weightGreaterThanZero = new QFinalState(weight); weightZero->addTransition(this, SIGNAL(validWeight()), weightGreaterThanZero); weight->setInitialState(weightZero); QState *buttonEnabled = new QState(); buttonEnabled->assignProperty(ui_->registerButton, "enabled", true); buttonDisabled->addTransition(buttonDisabled, SIGNAL(finished()), buttonEnabled); buttonEnabled->addTransition(this, SIGNAL(invalidWeight()), weightZero); machine->addState(registerButtonDisabled); machine->addState(registerButtonEnabled); machine->setInitialState(registerButtonDisabled); machine->start(); The problem here is that the following transition: buttonEnabled->addTransition(this, SIGNAL(invalidWeight()), weightZero); causes all the child states in the registerButtonDisabled state to be reverted to their initial state. This is unwanted behaviour, as I want the a and b states to remain in the same state. How do I prevent this?

    Read the article

  • rotating bitmaps. In code.

    - by Marco van de Voort
    Is there a faster way to rotate a large bitmap by 90 or 270 degrees than simply doing a nested loop with inverted coordinates? The bitmaps are 8bpp and typically 2048*2400*8bpp Currently I do this by simply copying with argument inversion, roughly (pseudo code: for x = 0 to 2048-1 for y = 0 to 2048-1 dest[x][y]=src[y][x]; (In reality I do it with pointers, for a bit more speed, but that is roughly the same magnitude) GDI is quite slow with large images, and GPU load/store times for textures (GF7 cards) are in the same magnitude as the current CPU time. Any tips, pointers? An in-place algorithm would even be better, but speed is more important than being in-place. Target is Delphi, but it is more an algorithmic question. SSE(2) vectorization no problem, it is a big enough problem for me to code it in assembler Duplicates How do you rotate a two dimensional array?. Follow up to Nils' answer Image 2048x2700 - 2700x2048 Compiler Turbo Explorer 2006 with optimization on. Windows: Power scheme set to "Always on". (important!!!!) Machine: Core2 6600 (2.4 GHz) time with old routine: 32ms (step 1) time with stepsize 8 : 12ms time with stepsize 16 : 10ms time with stepsize 32+ : 9ms Meanwhile I also tested on a Athlon 64 X2 (5200+ iirc), and the speed up there was slightly more than a factor four (80 to 19 ms). The speed up is well worth it, thanks. Maybe that during the summer months I'll torture myself with a SSE(2) version. However I already thought about how to tackle that, and I think I'll run out of SSE2 registers for an straight implementation: for n:=0 to 7 do begin load r0, <source+n*rowsize> shift byte from r0 into r1 shift byte from r0 into r2 .. shift byte from r0 into r8 end; store r1, <target> store r2, <target+1*<rowsize> .. store r8, <target+7*<rowsize> So 8x8 needs 9 registers, but 32-bits SSE only has 8. Anyway that is something for the summer months :-) Note that the pointer thing is something that I do out of instinct, but it could be there is actually something to it, if your dimensions are not hardcoded, the compiler can't turn the mul into a shift. While muls an sich are cheap nowadays, they also generate more register pressure afaik. The code (validated by subtracting result from the "naieve" rotate1 implementation): const stepsize = 32; procedure rotatealign(Source: tbw8image; Target:tbw8image); var stepsx,stepsy,restx,resty : Integer; RowPitchSource, RowPitchTarget : Integer; pSource, pTarget,ps1,ps2 : pchar; x,y,i,j: integer; rpstep : integer; begin RowPitchSource := source.RowPitch; // bytes to jump to next line. Can be negative (includes alignment) RowPitchTarget := target.RowPitch; rpstep:=RowPitchTarget*stepsize; stepsx:=source.ImageWidth div stepsize; stepsy:=source.ImageHeight div stepsize; // check if mod 16=0 here for both dimensions, if so -> SSE2. for y := 0 to stepsy - 1 do begin psource:=source.GetImagePointer(0,y*stepsize); // gets pointer to pixel x,y ptarget:=Target.GetImagePointer(target.imagewidth-(y+1)*stepsize,0); for x := 0 to stepsx - 1 do begin for i := 0 to stepsize - 1 do begin ps1:=@psource[rowpitchsource*i]; // ( 0,i) ps2:=@ptarget[stepsize-1-i]; // (maxx-i,0); for j := 0 to stepsize - 1 do begin ps2[0]:=ps1[j]; inc(ps2,RowPitchTarget); end; end; inc(psource,stepsize); inc(ptarget,rpstep); end; end; // 3 more areas to do, with dimensions // - stepsy*stepsize * restx // right most column of restx width // - stepsx*stepsize * resty // bottom row with resty height // - restx*resty // bottom-right rectangle. restx:=source.ImageWidth mod stepsize; // typically zero because width is // typically 1024 or 2048 resty:=source.Imageheight mod stepsize; if restx>0 then begin // one loop less, since we know this fits in one line of "blocks" psource:=source.GetImagePointer(source.ImageWidth-restx,0); // gets pointer to pixel x,y ptarget:=Target.GetImagePointer(Target.imagewidth-stepsize,Target.imageheight-restx); for y := 0 to stepsy - 1 do begin for i := 0 to stepsize - 1 do begin ps1:=@psource[rowpitchsource*i]; // ( 0,i) ps2:=@ptarget[stepsize-1-i]; // (maxx-i,0); for j := 0 to restx - 1 do begin ps2[0]:=ps1[j]; inc(ps2,RowPitchTarget); end; end; inc(psource,stepsize*RowPitchSource); dec(ptarget,stepsize); end; end; if resty>0 then begin // one loop less, since we know this fits in one line of "blocks" psource:=source.GetImagePointer(0,source.ImageHeight-resty); // gets pointer to pixel x,y ptarget:=Target.GetImagePointer(0,0); for x := 0 to stepsx - 1 do begin for i := 0 to resty- 1 do begin ps1:=@psource[rowpitchsource*i]; // ( 0,i) ps2:=@ptarget[resty-1-i]; // (maxx-i,0); for j := 0 to stepsize - 1 do begin ps2[0]:=ps1[j]; inc(ps2,RowPitchTarget); end; end; inc(psource,stepsize); inc(ptarget,rpstep); end; end; if (resty>0) and (restx>0) then begin // another loop less, since only one block psource:=source.GetImagePointer(source.ImageWidth-restx,source.ImageHeight-resty); // gets pointer to pixel x,y ptarget:=Target.GetImagePointer(0,target.ImageHeight-restx); for i := 0 to resty- 1 do begin ps1:=@psource[rowpitchsource*i]; // ( 0,i) ps2:=@ptarget[resty-1-i]; // (maxx-i,0); for j := 0 to restx - 1 do begin ps2[0]:=ps1[j]; inc(ps2,RowPitchTarget); end; end; end; end;

    Read the article

  • Maven String Replace of Text Web Resources

    - by Jaco van Niekerk
    I have a Maven web application with text files in src/main/webapp/textfilesdir As I understand it, during the package phase this textfilesdir directory will be copied into the target/project-1.0-SNAPSHOT directory, which is then zipped up into a target/project-1.0-SNAPSHOT.war Problem Now, I need to do a string replacement on the contents of the text files in target/project-1.0-SNAPSHOT/textfilesdir. This must then be done after the textfilesdir is copied into target/project-1.0-SNAPSHOT, but prior to the target/project-1.0-SNAPSHOT.war file being created. I believe this is all done during the package phase. How can a plugin (potentially maven-antrun-plugin), plug into the package phase to do this. The text files don't contain properties, like ${property-name} to filter on. String replacement is likely the only option. Options Modify the text files after the copy into target/project-1.0-SNAPSHOT directory, yet prior to the WAR creation. After packaging, extract the text files from WAR, modify them, and add them back into the WAR. I'm thinking there is another option here I'm missing. Thoughts anyone?

    Read the article

  • Webreference vs servicereference. Why ony one works ?

    - by phenevo
    Hi, I've got two applications. One uses webreference to my webservice, and second use servicereference to my webservice. There is metohod which I'm invoking: [WebMethod] public Car[] GetCars(string carCode) { Cars[] cars= ModelToContract.ToCars(MyFacade.GetCars(carCode); return cars; } Car has two pools: string Code {get;set;} CarType Type {get;set;} public enum CarType { Van=0, Pickup=1 } I'm debuging this webMethod, and... at the end webservice throw good collection of cars, which has one car: code="bmw",Type.Van But... Application with webrefence receives the same collection and application with servicereference gets collection, where field code is null... Invoking servicereference: MyService myService=new MyService() Cars[] cars= client.GetCars(carcode); Invoking webservice: MyService.MyServiceSoapClient client = new MyServiceS.MyServiceSoapClient(); Cars[] cars= client.GetCars(carcode);

    Read the article

  • Eclipse does not start on Windows 7

    - by van
    Suddenly Eclipse today has decides to stop working. The last thing I did was close all perspectives and close Eclipse. When loading eclipse from the command prompt, using: "eclipse.exe -clean" the splash screen loads for a split second then exits. When I run the command: eclipsec -consoleLog -debug it results in the following output: Start VM: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene.tokenizer=standard -Xms4096m -Xmx4096m -XX:MaxPermSize=512m -Djava.class.path=d:\devtools\eclipse\\plugins/org.eclipse.equinox.launcher_1.3. 0.v20130327-1440.jar -os win32 -ws win32 -arch x86_64 -showsplash d:\devtools\eclipse\\plugins\org.eclipse.platform_4.3.0.v20130605-20 00\splash.bmp -launcher d:\devtools\eclipse\eclipsec.exe -name Eclipsec --launcher.library d:\devtools\eclipse\\plugins/org.eclipse.equinox.launcher.win 32.win32.x86_64_1.1.200.v20130521-0416\eclipse_1503.dll -startup d:\devtools\eclipse\\plugins/org.eclipse.equinox.launcher_1.3.0.v201303 27-1440.jar --launcher.appendVmargs -product org.eclipse.epp.package.standard.product -consoleLog -debug -vm C:/Program Files/Java/jdk1.6.0_37/bin\..\jre\bin\server\jvm.dll -vmargs -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene.tokenizer=standard -Xms4096m -Xmx4096m -XX:MaxPermSize=512m -Djava.class.path=d:\devtools\eclipse\\plugins/org.eclipse.equinox.launcher_1.3. 0.v20130327-1440.jar Error occurred during initialization of VM Incompatible minimum and maximum heap sizes specified Checking Task Manager shows no Java process running and both the CPU and memory usage are very low. I have tried: Re-installing Eclipse Re-starting my machine But running eclipsec -consoleLog -debug from the command prompt still results in the issue: Error occurred during initialization of VM Incompatible minimum and maximum heap sizes specified

    Read the article

  • PList Chicken/Egg Scenario

    - by David van Dugteren
    Hi, I want to read/write to cache.plist If I want to read an existing premade plist file stored in the resources folder I can go: path = [[NSBundle mainBundle] bundlePath]; NSString *finalPath = [path stringByAppendingPathWithComponent@"cache.plist"]; NSMutableDictionary *root = ... But then I wish to read it from the iPhone. Can't, the Resources folder is only readable. So I need to use: NSDocumentDirectory, NSUserDomain,YES So how can I have my plist file preinstalled to the Document Directory location? Thus meaning I don't have to mess around with untidy code copying the plist file over at startup. (Unless that's the only way).

    Read the article

  • Is a red-black tree my ideal data structure?

    - by Hugo van der Sanden
    I have a collection of items (big rationals) that I'll be processing. In each case, processing will consist of removing the smallest item in the collection, doing some work, and then adding 0-2 new items (which will always be larger than the removed item). The collection will be initialised with one item, and work will continue until it is empty. I'm not sure what size the collection is likely to reach, but I'd expect in the range 1M-100M items. I will not need to locate any item other than the smallest. I'm currently planning to use a red-black tree, possibly tweaked to keep a pointer to the smallest item. However I've never used one before, and I'm unsure whether my pattern of use fits its characteristics well. 1) Is there a danger the pattern of deletion from the left + random insertion will affect performance, eg by requiring a significantly higher number of rotations than random deletion would? Or will delete and insert operations still be O(log n) with this pattern of use? 2) Would some other data structure give me better performance, either because of the deletion pattern or taking advantage of the fact I only ever need to find the smallest item? Update: glad I asked, the binary heap is clearly a better solution for this case, and as promised turned out to be very easy to implement. Hugo

    Read the article

  • Problem with between join for sqlalchemy orm relation.

    - by Gary van der Merwe
    I'm trying to create a relation that has a between join. Here is a shortish example of what I'm trying to do: #!/usr/bin/env python import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.engine.base import Engine from sqlalchemy.ext.declarative import declarative_base metadata = sa.MetaData() Base = declarative_base(metadata=metadata) engine = sa.create_engine('sqlite:///:memory:') class Network(Base): __tablename__ = "network" id = sa.Column(sa.Integer, primary_key=True) ip_net_addr_db = sa.Column('ip_net_addr', sa.Integer, index=True) ip_broadcast_addr_db = sa.Column('ip_broadcast_addr', sa.Integer, index=True) # This can be determined from the net address and the net mask, but we store # it in the db so that we can join with the address table. ip_net_mask_len = sa.Column(sa.SmallInteger) class Address(Base): __tablename__ = "address" ip_addr_db = sa.Column('ip_addr', sa.Integer, primary_key=True, index=True, unique=True) Network.addresses = orm.relation(Address, primaryjoin=Address.ip_addr_db.between( Network.ip_net_addr_db, Network.ip_broadcast_addr_db), foreign_keys=[Address.ip_addr_db]) metadata.create_all(engine) Session = orm.sessionmaker(bind=engine) Network() I you run this, you get this error: ArgumentError: Could not determine relation direction for primaryjoin condition 'address.ip_addr BETWEEN network.ip_net_addr AND network.ip_broadcast_addr', on relation Network.addresses. Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ? The answer to that question is Yes, but I cant figure out how to tell it that

    Read the article

  • Weird generics compile error.

    - by Jouke van der Maas
    I have two classes, a base class and a child class. In the base class i define a generic virtual method: protected virtual Bar Foo<T() where T : Bar {} Then in my child class i try to do this: protected override BarChild Foo() // BarChild inherits Bar { return base.Bar<T as BarChild() } Visual studio gives this weird error: The type 'T' cannot be used as type parameter 'T' in the generic type or method 'Foo()'. There is no boxing conversion or type parameter conversion from 'T' to 'Bar'. Repeating the where clause on the child's override also gives an error: Constraints for override and explicit interface implementation methods are inherited from the base method, so they cannot be specified directly So what am i doing wrong here?

    Read the article

  • getting base64 content string of an image from a mimepart in Java

    - by Bas van den Broek
    Hello, I am trying to get the base64 content of a MimePart in a MimeMultiPart, but I'm struggling with the Javamail package. I simply want the base64 encoded String of a certain inline image, there doesn't seem to be an easy way to do this though. I wrote a method that will take the mime content (as a string) and an image name as a parameter, and searches for the part that contains the base64 content of that image name, and in the end returns this base64 string (as well as the content type but that is irrelevant for this question) Here is the relevant code: private static String[] getBase64Content(String imageName, String mimeString) throws MessagingException, IOException { System.out.println("image name: " + imageName + "\n\n"); System.out.println("mime string: " + mimeString); String[] base64Content = new String[2]; base64Content[0] = ""; base64Content[1] = "image/jpeg"; //some default value DataSource source = new ByteArrayDataSource(new ByteArrayInputStream(mimeString.getBytes()), "multipart/mixed"); MimeMultipart mp = new MimeMultipart(source); for (int i = 0; i < mp.getCount(); i++) { MimePart part = (MimePart) mp.getBodyPart(i); String disposition = part.getDisposition(); if (disposition != null && disposition.equals(Part.INLINE)) { if (part.getContentID() != null && part.getContentID().indexOf(imageName) > -1) //check if this is the right part { if (part.getContent() instanceof BASE64DecoderStream) { BASE64DecoderStream base64DecoderStream = (BASE64DecoderStream) part.getContent(); StringWriter writer = new StringWriter(); IOUtils.copy(base64DecoderStream, writer); String base64decodedString = writer.toString(); byte[] encodedMimeByteArray = Base64.encodeBase64(base64decodedString.getBytes()); String encodedMimeString = new String(encodedMimeByteArray); System.out.println("encoded mime string: " + encodedMimeString); base64Content[0] = encodedMimeString; base64Content[1] = getContentTypeString(part); } } } } return base64Content; } I cannot paste all of the output as the post would be too long, but this is some of it: image name: [email protected] This is a part of the mimeString input, it does find this (correct) part with the image name: --_004_225726A14AF9134CB538EE7BD44373A04D9E3F3940menexch2007ex_ Content-Type: image/gif; name="image001.gif" Content-Description: image001.gif Content-Disposition: inline; filename="image001.gif"; size=1070; creation-date="Fri, 02 Apr 2010 16:19:43 GMT"; modification-date="Fri, 02 Apr 2010 16:19:43 GMT" Content-ID: <[email protected]> Content-Transfer-Encoding: base64 R0lGODlhEAAQAPcAABxuHJzSlDymHGy2XHTKbITCdNTu1FyqTHTCXJTKhLTarCSKHEy2JHy6bJza lITKfFzCPEyWPHS+XHzCbJzSjFS+NLTirBx6HHzKdOz27GzCZJTOjCyWHKzWpHy2ZJTGhHS+VLzi (more base64 string here that I'm not going to paste) But when it finally prints the encoded mime string, this is a different string than I was expecting: encoded mime string: R0lGODlhEAAQAO+/vQAAHG4c77+90pQ877+9HGzvv71cdO+/vWzvv73vv71077+977+977+9XO+/vUx077+9XO+/vcqE77+92qwk77+9HEzvv70kfO+/vWzvv73alO+ Clearly different from the one that has its output in the part above. I'm not even sure what I'm looking at here, but when I try to load this as an image in a html page, it won't work. This is fairly frustrating for me, since all I want is a piece of the text that I'm already printing, but I'd rather not have to search through the mime string myself for the correct part, introducing all kinds of bugs.So I'd really prefer to use the Javamail library but could use some help on how to actually get that correct mime string.

    Read the article

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