Saturday, February 19, 2011

Where can I find prebuilt Subversion binaries for SGI IRIX?

We have a few SGI Onyx 350 and Orgin 350 systems running IRIX 6.5.x that we would like to install Subversion on. One of them will likely be used as a simple repository server running svnserve. The others will only need client installs.

The Subversion webpage has links to unofficial binaries for many *NIX systems, including HP-UX, Solaris, AIX, the BSDs and Linux distros. Unfortunately, there aren't any for IRIX. A Google search also comes up empty.

So, is there someplace on the web that publishes IRIX binaries for Subversion?

If not, does anyone have experience compiling SVN from source on such systems? How hard is it to track down all of the dependencies? Are there any caveats we should be aware of?

From stackoverflow
  • The guy that maintains This website sells secondhand SGI gear. He sells them with CD's of contributed software. Maybe he can do something for you.

    Also, The SGI forum on nekochan.net has postings of contributed software. You may be able to ask for something there.

    Subversion is fairly pernickety about its dependencies (as you have probably already worked out). This link gives some of the dependencies for installing on Redhat 7.3, which dates back to the early 2000's (I don't know what minor release of Irix you're using). You may find it to be a reasonable guide to the dependencies.

  • For a machine like yours, the source code build is probably the way to go(it's one of the advantages of having source). The dependencies aren't that bad. The dependencies are zlib, the Apache Portable Runtime (and the apr-utils), neon (optional), and BerkelyDB(optional also).
    Get the Apache and neon, and berkelyDB stuff first. then just ./configure --prefix=;make;make install

  • The Nekoware repository has a binary of Subversion 1.5.5.

    http://www.mechanics.citg.tudelft.nl/~everdij/nekoware/index.php?path=current/

How do you add an ActionListener onto a JButton in Java

private JButton jBtnDrawCircle = new JButton("Circle");
private JButton jBtnDrawSquare = new JButton("Square");
private JButton jBtnDrawTriangle = new JButton("Triangle");
private JButton jBtnSelection = new JButton("Selection");

I would like to add action listeners to these buttons, so from a main method I can call actionperformed on them so when they are clicked I can call them in my program

From stackoverflow
  • Your best bet is to review the Java Swing tutorials, specifically the tutorial on Buttons.

    The short code snippet is:

    jBtnDrawCircle.addActionListener( /*class that implements ActionListener*/ );
    
  • I'm didn't totally follow, but to add an action listener, you just call addActionListener (from Abstract Button). If this doesn't totally answer your question, can you provide some more details?

  • Two ways:

    1. Implement ActionListener in your class, then use jBtnSelection.addActionListener(this); Later, you'll have to define a menthod, public void actionPerformed(ActionEvent e). However, doing this for multiple buttons can be confusing, because the actionPerformed method will have to check the source of each event (e.getSource()) to see what button it came from.

    2. Use anonymous inner classes:

    jBtnSelection.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent e) { 
        selectionButtonPressed();
      } 
    } );

    Later, you'll have to define selectionButtonPressed(). This works better when you have multiple buttons, because your calls to individual methods for handling the actions are right next to the definition of the button.

    The second method also allows you to call the selection method directly. In this case, you could call selectionButtonPressed() if some other action happens, too - like, when a timer goes off or something (but in this case, your method would be named something different, maybe selectionChanged()).

Finding Rotation Angles between 3d points

I am writing a program that will draw a solid along the curve of a spline. I am using visual studio 2005, and writing in C++ for OpenGL. I'm using FLTK to open my windows (fast and light toolkit).

I currently have an algorithm that will draw a Cardinal Cubic Spline, given a set of control points, by breaking the intervals between the points up into subintervals and drawing linesegments between these sub points. The number of subintervals is variable.

The line drawing code works wonderfully, and basically works as follows: I generate a set of points along the spline curve using the spline equation and store them in an array (as a special datastructure called Pnt3f, where the coordinates are 3 floats and there are some handy functions such as distance, length, dot and crossproduct). Then i have a single loop that iterates through the array of points and draws them as so:

glBegin(GL_LINE_STRIP);
for(pt = 0; pt<=numsubsegements ; ++pt) {
    glVertex3fv(pt.v());
}
glEnd();

As stated, this code works great. Now what i want to do is, instead of drawing a line, I want to extrude a solid. My current exploration is using a 'cylinder' quadric to create a tube along the line. This is a bit trickier, as I have to orient openGL in the direction i want to draw the cylinder. My idea is to do this:

Psuedocode:

Push the current matrix,
translate to the first control point
rotate to face the next point
draw a cylinder (length = distance between the points)
Pop the matrix
repeat

My problem is getting the angles between the points. I only need yaw and pitch, roll isnt important. I know take the arc-cosine of the dot product of the two points divided by the magnitude of both points, will return the angle between them, but this is not something i can feed to OpenGL to rotate with. I've tried doing this in 2d, using the XZ plane to get x rotation, and making the points vectors from the origin, but it does not return the correct angle.

My current approach is much simpler. For each plane of rotation (X and Y), find the angle by:

arc-cosine( (difference in 'x' values)/distance between the points)

the 'x' value depends on how your set your plane up, though for my calculations I always use world x.

Barring a few issues of it making it draw in the correct quadrant that I havent worked out yet, I want to get advice to see if this was a good implementation, or to see if someone knew a better way.

From stackoverflow
  • Have you considered gluLookAt? Put your control point as the eye point, the next point as the reference point, and make the up vector perpendicular to the difference between the two.

    Avatar_Squadron : This does not not appear to work
  • A few notes:
    first of all, this:

    for(pt = 0; pt<=numsubsegements ; ++pt) {
      glBegin(GL_LINE_STRIP);
        glVertex3fv(pt.v());
    }
    glEnd();
    

    is not a good way to draw anything. You MUST have one glEnd() for every single glBegin(). you probably want to get the glBegin() out of the loop. the fact that this works is pure luck.

    second thing

    My current exploration is using a 'cylinder' quadric to create a tube along the line

    This will not work as you expect. the 'cylinder' quadric has a flat top base and a flat bottom base. Even if you success in making the correct rotations according to the spline the edges of the flat tops are going to pop out of the volume of your intended tube and it will not be smooth. You can try it in 2D with just a pen and a paper. Try to draw a smooth tube using only shorter tubes with a flat bases. This is impossible.

    Third, to your actual question, The definitive tool for such rotations are quaternions. Its a bit complex to explain in this scope but you can find plentyful information anywhere you look.
    If you'd have used QT instead of FLTK you could have also used libQGLViewer. It has an integrated Quaternion class which would save you the implementation. If you still have a choice I strongly recommend moving to QT.

    Avatar_Squadron : the glBegin was a typo. Thank you for catching that. I have corrected it.
    Avatar_Squadron : unfortunatley, this is a for a class which requires FLTK. Do you know how you would actually draw the tube? I'm guessing i'm going to have to code the quadric self as a sort of retangular prism?
  • You are correct in forming two vectors from the three points in two adjacent line segments and then using the arccosine of the dot product to get the angle between them. To make use of this angle you need to determine the axis around which the rotation should occur. Take the cross product of the same two vectors to get this axis. You can then build a transformation matrix using this axis-angle or pass it as parameters to glRotate.

  • how to draw a rotation?

how to combine a template from other processed templates?

Hi!
I have a django project pro1 with several apps: app1, app2, app3 and so on. I want to display some top level template that contains blocks from each and every app:

example_base_template.html:
[header /]
[left nav bar]{{ app1 rendered template }}[/left nav bar]
[right nav bar]{{ app2 rendered template }}[/right nav bar]
[center section]{{ app1 main functionality template }}[/center section]
[footer]{{ app3 rendered template }}{{ app4 rendered template }}[/footer]

All those app templates are dynamic, that use DB. How to do that in the most proper and elegant way? Or maybe the question is how to connect 4 different views to one url?

best regards
chriss

From stackoverflow
  • You can use a {% include %} tag. But It doesn't help you a lot. The better solution is to write custom inclusion tag with needed template and functionality.

    You cannot (in simple way) mix several views into one. Try tags its pretty django solution.

  • We had a problem similar to this and the key is getting the correct data into the Context. What we did was breakout the data creation/Context filling for each view into a separate build-the-context routine. The original views just call their respective routine and then render their template. The composite view calls each of the context-builders and then renders the master template, which then includes the sub-templates.

    This is where we ran into a bit of a problem with the Django templating system. We were caching template fragments and some of these fragments took data that was very expensive to generate. If the fragment was not stale, we definitely did not want to do the work. But delaying the work until we knew we needed it meant we were now in the template and:

    • You can't pass parameters to methods from within a template.
    • The django.template.__init__.Variable._resolve_lookup() method was broken in that if you passed a callable, it wouldn't call it! If you reference a method of an object in the context, that works just fine.

    The reason for needing callables to work is that it permits you to pass in a curried function -- i.e. a function that already has some (or all) of its parameters specified, but which has not yet been called. So the view (or the context build in the case) should be able to curry a full-specified function (remember, you can't pass params in the templates themselves) so that the template when it needed to could invoke the callable, get the data, and away we go.

    We took two separate approaches to this:

    Since we did this site I have learned that we might have been able to solve it by using generators as delayed data producers. The generators act sort of like a curried function (in that you can pass arbitrary params for the setup), but the template engine sees them as just another iterator. There is a great tutorial on this subject. Note: generators are not arrays and you can only consume them once, so some of your logic may need to be tweaked.

    Next time I think we'll just go with jinja2 templates and stop screwing with Django's templates.

    akaihola : Sounds like fighting against the way Django was designed. I'd definitely take the custom template tag route.
    Peter Rowell : It's not Django I'm fighting, it's the template "language" -- there is a difference. Custom tags are a PITA (I speak from experience). When you have a complex page, with multiple components, having each view do all of the necessary pre-compute logic is *not* DRY, which is a central mantra of Django.
  • I did this by writing custom template tags for each application I wanted to include. At first my template tags just passed back hard coded html. Later I found that the tags could load their own template fragments. There was also a snippet somewhere that was a generic latest content tag that worked pretty well.

  • Many reusable apps (esp. those selected into the Pinax project) serve as great examples on how to use custom template tags to insert content. James Bennett's talk in DjangoCon 2008 may also help.

Is there a test runner for .NET tests that can run multi-threaded to take advantage of multi-core machines?

I'm setting up CI at present using Thoughtworks Studios' Cruise, Gallio to run xunit.net fact/tests, and ncover 2 to do code-coverage.

I noticed that running the code-coverage pegs one of the four CPUs that our build-agent server has, and wondered whether there was a multi-threaded test-runner that I might use instead, to take advantage of the other 3 cores that are sat idle? I had a quick search around, but most hits are in reference to testing multi-threaded code, not multi-threaded test running...

From stackoverflow
  • If nothing else, I know that in CruiseControl.NET, you could multiple two operations run simultaneously. I would think the same would be true for Cruise. You could have four instances of run on 1/4 of your tests each, and then stitch the results back together. Knowing when to merge them may be difficult though.

  • In NUnit you can pass a /thread parameter which spawns test execution in a different thread. I'd imagine it wouldn't be too much more work to have a thread pool to spawn tests from. You'd have to make darn sure you don't have dependencies in your tests.

    I'd ask on either the xUnit.NET or NUnit lists. I know Charlie is working to make that part of NUnit 3.0. You can also look at PNunit as an extension. There's also an article with someone working towards getting xUnit.NET in multiple threads.

  • Just yesterday i came across this post by Damon Payne:

    http://www.damonpayne.com/2008/05/09/ConcurrentUnitTestingWithXUnitNet1.aspx

    where he walks through writing a custom test runner for xUnit.NET that explicitly distributes test cases using the class as the unit of concurrency in order to take advantage of multiple cores.

  • Gallio implements parallel test execution.

indexing large table in SQL SERVER

I have a large table (more than 10 millions records). this table is heavily used for search in the application. So, I had to create indexes on the table. However ,I experience a slow performance when a record is inserted or updated in the table. This is most likely because of the re-calculation of indexes.

Is there a way to improve this.

Thanks in advance

From stackoverflow
  • We'd need to see your indexes, but likely yes.

    Some things to keep in mind are that you don't want to just put an index on every column, and you don't generally want just one column per index.

    The best thing to do is if you can log some actual searches, track what users are actually searching for, and create indexes targeted at those specific types of searches.

  • This is a classic engineering trade-off... you can make the shovel lighter or stronger, never both... (until a breakthrough in material science. )

    More index mean more DML maintenance, means faster queries.

    Fewer indexes mean less DML maintenance, means slower queries.

    It could be possible that some of your indexes are redundant and could be combined.

    Besides what Joel wrote, you also need to define the SLA for DML. Is it ok that it's slower, you noticed that it slowed down but does it really matter vs. the query improvement you've achieved... IOW, is it ok to have a light shovel that weak?

  • There are a number of solutions you could choose

    a) You could partition the table

    b) Consider performing updates in batch at offpeak hours (like at night)

    c) Since engineering is a balancing act of trade-offs, you would have to choose which is more important (Select or Update/insert/delete) and which operation is more important. Assuming you don't need the results in real time for an "insert", you can use Sql server service broker for those operations to perform the "less important" operation asynchronously

    http://msdn.microsoft.com/en-us/library/ms166043(SQL.90).aspx

    Thanks -RVZ

  • You could try reducing the number of page splits (in your indexes) by reducing the fill factor on your indexes. By default, the fill factor is 0 (same as 100 percent). So, when you rebuild your indexes, the pages are completely filled. This works great for tables that are not modified (insert/update/delete). However, when data is modified, the indexes need to change. With a Fill Factor of 0, you are guaranteed to get page splits.

    By modifying the fill factor, you should get better performance on inserts and updates because the page won't ALWAYS have to split. I recommend you rebuild your indexes with a Fill Factor = 90. This will leave 10% of the page empty, which would cause less page splits and therefore less I/O. It's possible that 90 is not the optimal value to use, so there may be some 'trial and error' involved here.

    By using a different value for fill factor, your select queries may become slightly slower, but with a 90% fill factor, you probably won't notice it too much.

  • If you have a clustered index that is not on an identity numeric field, rearranging the pages can slow you down. If this is the case for you see if you can improve speed by making this a non-clustered index (faster than no index but tends to be a bit slower than the clustered index, so your selects may slow down but inserts improve)

    I have found users more willing to tolerate a slightly slower insert or update to a slower select. That is a general rule, but if it becomes unacceptably slow (or worse times out) well no one can deal with that well.

Why does a SolidBrush result in a patterned image?

I'm trying to dynamically generate a gif image of a specified size and color in an HttpHandler. For some reason, the image is being generated with a dithered color pattern rather than the solid color I expected the SolidBrush to create. The following code is the simplest I could find that exposes the problem.

private void GenerateSquareImage(String filename, String color, Int32 width)
{
    Bitmap img = new Bitmap(width, width);
    Graphics g = Graphics.FromImage(img);
    SolidBrush brush = new SolidBrush(ColorTranslator.FromHtml("#" + color));

    g.FillRectangle(brush, 0, 0, width, width);

    img.Save(filename, System.Drawing.Imaging.ImageFormat.Gif);
    img.Dispose();

    brush.Dispose();
    g.Dispose();
}

Here is a sample of the results I'm getting when passing "415976" in the color parameter:

imageshack

(The block on the left is an HTML SPAN with background-color set to #415976. The block on the right is my graphic, where you can see the dithered colors.)

The result is the same if I use this code:

g.Clear(ColorTranslator.FromHtml("#" + color));

in place of the g.FillRectangle call in the method above.

UPDATE: By default, GDI+ saves GIFs with the web safe palette if any programmatic changes are made to the Bitmap. This is what was causing my non safe palette color to be dithered. I was able to modify the code referenced in Marco's post below (http://msdn.microsoft.com/en-us/library/aa479306.aspx) to modify the palette on my freshly created image so that my color was respected.

From stackoverflow
  • IIRC GIF's are limited to a specific pallete on .NET. There are workarounds, but they were above my understanding.

  • GIF files are limited to 256 colors as far as I know, so it resorts to dithering. PNG is probably the format you need.

    Or you can look here for a solution using a complex quantizer to build a custom palette (I don't take responsibility for the code in the link, never tried myself).

    This other link from Microsoft has an in-depth analysis of the problem.

    Hope this helps.

    JeffK : See my update to the original question. This answer eventually pointed me to the solution.