Friday, April 29, 2011

JQuery Boxy plugin resize and access

How exactly does one resize a Boxy.load()? I can resize using: var tmp = new Boxy(); tmp.resize(40,40);

But if I then try to use tmp.load('somefile.php'); it states that tmp.load is not a function. I've also tried:

var tmp = Boxy.load('somefile.php'); tmp.resize(100,100); // Says that tmp.resize is not a function.

How can I resize a boxy window after it has been created using Boxy.load(). Thanks in advance.

From stackoverflow
  • I read through the documentation and I think I get it:

    http://onehackoranother.com/projects/jquery/boxy/

    Basically, you need to set a callback in the afterShow option for Boxy.load.

    Boxy.load() does not return an instance because it's an ajax call, so it returns immediately but can't draw anything, so it's pointless to hand back a Boxy instance. So, in your callback, you'll have full access to the whole Boxy object and you'll be able to call resize. It looks like this:

    Boxy.load("whereever.html", {
      afterShow: function() {
        this.resize(40,40);
      }
    });
    

    Tada! I tested it, it seemed to almost do the trick. It didn't quite handle vertical resizing very well, but horizontal was what I sort of expected. (but I was trying to cram a lot of stuff into the window, so it's likely that it just re-resized it to fit the content.

  • erewreewewe gdsfsdf rgfdg fggfdg ggg fgfg gsdgdgd

Classic ASP: posting with content of PDF file to a .NET page

So the problem is half the app is written in classic asp and half is in asp.net. There's a PDF file (in memory) that is generated by classic asp code that I need to share with the .NET half. I thought of saving the PDF to the FS or DB, which I am pretty sure most of you wouldn't recommend because it would need to go through a very slow process of saving to IO, and then I would need to manually clean up after -- unnecessarily creating more bottlenecks and failure points.

I thought of mimicking a post from the classic asp page to .NET by using Server.Transfer or Microsoft.XMLHTTP objects, but neither exactly fits the scenario as I really do want the URL on the client side to be pointing at the .NET aspx page. So is there a simple way to manufacture a POST from classic ASP to a .NET page with a PDF file embedded?

Thanks in advance for any comments or suggestions.

From stackoverflow
  • Your best bet is probably the FS or DB considering the difficulties ASP.NET and ASP interaction. That's my "path of least resistance".

  • Somewhat of a hack, but...

    Create a form in classic ASP with a field that you populate with the data from the PDF file. The action of the form would be the ASP.NET page. Something like:

    <body onload="pdfsenderform.submit()">
        <form name="pdfsenderform" action="pdf.aspx" method="post">
           <input type="hidden" name="pdffiledata" value="<%...output your PDF data here...%>" />
       </form>
    </body>
    

    You might need to encode the binary PDF data prior to writing it to the form field (Base64 or something).

    Haoest : I ended up doing it this way. It takes some extra bandwidth but least maintenance headache.
    Mark Brackett : Ouch...so, instead of writing to disk you're round-tripping it to the client? I can't think of many scenarios where that would be faster....
    squillman : Yeah, never said it was pretty...
  • Just write it to disk, store the filename in a cookie or querystring, and Response.Redirect the user. It's likely to be "fast enough" and much easier than writing a least common denominator State Server accessible over TCP to both of them - which is the only in memory way of doing I can think of.

.Net COM DLL not working from vb6 across appdomains

We have a large vb6 application, and as we need to change/fix things, we are moving sections to .net, targeting the framework 2.0. We have moved a bunch of classes to a .net dll, and they are set up properly to be exposed to com.

Here's the problem: MainAppVB6.exe instantiates DOTNET_COM.ComClass. It passes this to a method in a differen .net dll, which passes it across an appdomain. This is no issue at all for COM objects written in vb6.

.net see the appdomain boundary, and wants the objects to be serializable or marshalbyref. Since we need the .net portion to change data that gets back to vb6, serializable doesn't work. If we mark the classes at Inherits MarshalByRefObject, then we get "This remoting proxy has no channel sink which means either the server has no registered server channels are listening, or the application has no suitable client channel to talk to the server".

There are no channels -- we are just going across an appdomain in the same dll. It seems that .net is not treating the object as COM, which it should be doing.

If I remove both marshalbyref and serializable, things work only if the com object is instantiated by vb6. If the .net functionality in the appdomain creates the object and assigns to to be passed back to vb6, vb6 gives me automation errors.

A very ugly kludge is to serialize the object in the new appdomain, send back the xml, and let vb6 deserialize, but that seems ridiculous.

Anyone have any ideas?

Thank you.

Seth

From stackoverflow
  • You could create a delegate to the appropriate mutator method on your COM class in your first .NET method, pass that delegate across the AppDomain boundary, use that delegate to mutate your COM object in the second .NET method and then return the mutated object back to VB6. The methods in the Marshal Class might come in handy. :)

    Edit from comment: What about creating a .net copy of the vb6 class in the first .net call, passing that new object around to all the .net calls you need to make and then fix your com object going back. That might be easier than the de-serialization in vb6.

How to create a floating menu

Need some advice on creating a floating menu that behaves very similar to what is used on the apple website shopping cart. I've seen some scripts that do something like this (and we've tried one) but they tend to "lag" behind the movement while apple's version gives the appearance of being stationary. A jQuery solution would be preferable.

From stackoverflow
  • Well, looks like they are switching from relative positioning to fixed. Works better than what most people do, which is simply scroll it down more as the window is scrolled down more.

    You can detect how scrolled down the window is by following what is done in the following link.

    Stevo : did you forgot to add the link?
    altCognito : Ah, thank you. It's in there now.
    Akeem : This is what I was guessing by looking at how apple's version blips into place when you get to the top. Thanks for the link and I'll give it a shot
  • Once the div's y-position is equivalent to the top of the current window view, make it fixed position. You will have to use logic to make sure it moves back to non-fixed after they scroll back up, but it should be trivial.

  • Here is a plugin called scroll-follow that will help. Essentially you define a DIV with ul for your menu options. The plugin will allow you to set the speed, appearance, and a toggle switch.

Implementing search on an ASP.NET MVC website

I've created a content-managed website using ASP.NET MVC. All content is stored in the 'Content' table in a SQL Server database, with the text itself stored in a column of datatype 'XML'.

I want to add a search feature to the site that will search all the XML content and return a list of results, each of which links to the content item.

Any ideas on which technology would be most appropriate?

Should I be using SQL Server full-text indexing, or something else such as DotLucene?

From stackoverflow

Git commit permissions error when working on a remote host

I'm trying to get my website under version control. I work directly on the server with ExpanDrive, which uses MacFUSE to mount the SFTP connection as a local volume which I can access with the terminal and other local applications.

Anyway, everything goes smoothly until I try to commit, when I receive this message:

fatal: exec .git/hooks/pre-commit failed.

If I try to run the exec command manually, I see this:

-bash: /Volumes/1&1 Internet/website/.git/hooks/pre-commit: Permission denied
-bash: exec: /Volumes/1&1 Internet/website/.git/hooks/pre-commit: cannot execute: Unknown error: 0

I've tried using my SFTP client to give everything under the .git directory full (777) permissions, and still no luck. Does anyone know of anything else I could try?

From stackoverflow
  • By giving everything under the .git directory full (777) permissions, you have enabled all of the example scripts that ship with Git in .git/hooks, normally with their execute bits off. When you try to commit the now executable sample pre-commit script tries to run to format the commit as a patch.

    Unless this is what you are trying to do, I suggest you chmod /git/hooks/* to 644, so that the hook scripts do not execute.

    Edit -- Resetting the hook permissions gets you back the condition where you had the problem first. Next try the commit with the --no-verify flag, which is supposed to bypass the pre-commit hook (and also some minor checks on the commit message). This may be a workaround, but I still don't see why you had the initial problem. The code looks very straightforward -- I don't see how it could try to execute that hook if it's not enabled. If that fails in the same way, then I would think that the ExpanDrive/MacFuse system is not handling permissions properly (but that's pretty unlikely).

    Marc Charbonneau : Thanks for the advice, unfortunately I'm still seeing the error after trying this.
    Paul : I think my brain was already on the way to the airport when my fingers were still on the keyboard. Obviously resetting the permissions only gets you back to where you originally had the problem.
    Marc Charbonneau : Unfortunately I had trouble even with --no-verify, now I'm getting an error just adding files in a fresh repo. I'm giving up on this one.
  • I ended up setting up a local development environment on my laptop, I'm giving up on trying to use git through ExpanDrive. After spending some more time with it it seems like these tools just weren't meant to work together.

  • I believe recent versions of git use a different mechanism than permissions to enable hooks. So if you are using a recent version, you might remove everything from the .git/hooks directory (or move it somewhere else), and see if that is the problem.

getting selected text from another frame

I have a frameset where I would like to have someone be able to click a button in one frame that does something with the text selected in the other frame. The button in frame[0] invokes the following javascript to get the selected text from frame[1]:

self.parent.frames[1].getSelection()

The problem, I believe, is that the very act of clicking on the button in frame[0] unselects the text in frame[1], so getSelection returns an empty string. What can I do about this?

From stackoverflow
  • Try using onmousedown rather than onclick as the handler for the button. I believe it will get handled before focus is given to the button and the selection is lost.

  • Your problem is in something else. Previous selection survives long enough to be recorded on click. It may help you to look at the working code that does what you want to do.

    I coded a smart quote plugin for FCKEditor. It may seem complicated, but basicly it does what you want: user selects something, clicks a button, editor reacts onclick and executes function from this javascript. The code uses some FCKEditor function to get to the edit window, but this part is of no interest for you.

    Bottom line, your plan works.

Licensing software as open source but charging for compiled executables?

As I understand it software being open source does not prevent you from selling it (does this depend on the type of license?) but is this a good idea?

For my pet project the target audience is for the most part non-programmers who wouldn't know how to compile the source anyway, but I still want to keep it open mostly for possible future employers to view my "portfolio" as well as to get critique from others, or just for others to learn from.

I don't expect to quit my day job from it or anything, mostly just to defray minor costs like web hosting, domain and other misc stuff, and hopefully some pocket change.

Providing support isn't really an option, it's and end-user app and one of the primary objectives is to make it as easy to use as possible.

The closest license that sounds like it'd be friendly to this is the Ms-RSL but Google Code which I'm currently using doesn't support that license, and a quick search looks like Sourceforge doesn't either (I could be wrong). It's currently GPL, but I just have a few classes stubbed out right now, so changing isn't an issue.

Are there any examples of other people doing this (success or failure)? Am I better off just asking for donations? Should I just not license it as open source (is it automatically closed source if I don't have any license but just distribute it upon request?) Any other options I haven't thought of?

Edit: What I'm more interested aside from the legal aspect is whether the practice of straight selling open source software is generally frowned upon, i.e. will I piss off customers that bought it and later found out it was open source. Should I announce it on the site or keep a one-way link from source-code to retail site but not the other way around? Announce it but not make it prominent?

From stackoverflow
  • If you share it without a licence, normal copyright laws applies. And I don't see anything wrong with charging for open source software. Most open source licences (like GPL) just requires that you supply the sourcecode to the people that got the binary, and that they can do anything they want with that sourcecode. Including selling their own compiled binaries.

    Davy8 : I realize I'm allowed to, but I'm more interested whether it's a good idea (somewhat subjective question I suppose, but I'd like to hear some different views and angles on it
    elzapp : Yeah, I understood that. I know people are doing this, but I don't know if they regard it as successfull or not...
  • Depends on the license. You can technically sell a GPL program, but you must also give the source with the binary, and the recipient can modify and redistribute it for free. It's not an economically sustainable model.

    Portfolio: Just give the code to the employer for their evaluation only. No need for open source.

    Critique from others: You probably want some license that forbids redistribution there. If you intend to sell. At first glance, this is what MS-RSL seems to provide, but I am not familiar with it.

    Remember it is your code. You are free to distribute it under an unlimited number of licenses to different people.

    mipadi : Just a small note: You don't _have_ to give the source _with_ the binary -- you just have to provide it if requested.
  • Red Hat Enterprise Linux is probably a good example of something like this: they are open-source and you can download every source package from their FTP site; however, they charge for their own build.

  • Nobody will care if you try to sell your own code, even if it is opensource. The only time people get riled up is when you try to sell somebody else's opensourced code, and then only if it's in violation of the license (in letter or in spirit)

    seanhodges : I find people get riled up even if it's not in violation of the license, though thats not to say they are right to. For example, Transgaming with the Wine source code.
  • Free software isn't about “not charging a fee”. Selling free software is an excellent way to fund more work on free software.

    What you probably can't do is treat it like loaves of bread; nothing strictly prevents you from trying, but your customers have their own perfectly functional loaf-duplication machines, so they're not likely to pay you if that's all you're doing for them.

    Your consideration should be, then, how to add value on an ongoing basis, without making the software non-free. Being the most-reputable and most-knowledgeable vendor for the software is one proven method; charging a fee for customisations (and, let's face it, all users want customisations, it's just a matter of how much they want them) that then get released into a future version is another. There are lots of ways to sell free software.

    You're asking about business, though: be innovative! Work within the boundaries (don't make the software any less free for any of its recipients) and come up with something new.

How can I add a ribbon menu to an existing MFC application?

Microsoft Visual C++ 2008 Feature Pack has ribbon menu support. Is it possible to make use of that in an existing MFC application that was not created with a ribbon menu?

From stackoverflow
  • Yes, it is surely possible to use the ribbon classes provided with the MFC Feature Pack.

    A basic introduction is available here: Quick Tour Of New MFC Functionality and a more detailed tutorial can be found here: MFC Feature Pack Tutorial.

    However, be aware that there is a rather strict license attached to it. For the conditions see Licensing the 2007 Microsoft Office User Interface and this related discussion on SO.

  • It certainly is possible to take an existing MFC application and update it to use the ribbon in the MFC Feature Pack, and I've done this myself.

    There are a couple of walkthrough articles on MSDN here that show how to do it, using the Scribble MFC sample application that you may be familiar with.

    In essence, what you need to do is change your code to use the Feature Pack base classes instead of the standard MFC base classes - for example, replace CWinApp with CWinAppEx, CFrameWnd with CFrameWndEx, etc. Then you can add CMFCRibbonBar and CMFCRibbonApplicationButton objects to your main window class to create the ribbon itself. To get started I'd suggest downloading the Scribble sample and following the walkthough articles.

    I hope this helps!

  • In addition to the resources pointed out by ChrisN, I recommend creating a new MFC application that includes a ribbon and examining the generated code..

  • I found problem in ribbon with right to left language like Arabic.

How to capture enter key being pressed on pages containing multiple forms?

I have inherited a web application where the usual ability to press return in any of the input fields has been disabled for the very good reason that the page contains multiple forms, and the application would not be able to determine (or, so I am told) which form to action. The application has been designed so there are no submit buttons (as in input type="submit") and, instead, the designers have gone for onclick handling. Here are two buttons that are defined on one of the pages, included for illustration (opening and closing angle brackets omitted deliberately)

input type="button" value="LOGIN" name="btnLoginOk" onclick="submit();"

input type="button" class="button-click-grey" value="Find Link Partners" onclick="raiseEvent('SubmitForm','',this);" style="cursor:pointer;"

But I really want to be able to allow users to press return if they wish e.g. if they've just typed into a field associated with the LOGIN, then detect that and action the onclick="submit();"

Perhaps there is a solution with jQuery.

From stackoverflow
  • Fingers crossed this'll work

    $(document).ready(function() {
      var focussed_form;
      $('input').focus(focus_form);
      $('input').blur(unfocus_form);
      $('textarea').focus(focus_form);
      $('textarea').blur(unfocus_form);
      $('select').focus(focus_form);
      $('select').blur(unfocus_form);
    
      $(document).keypress(function(e) {
        if(e.keyCode == 13) 
        {
          $(focussed_form).trigger('submit'); 
        }
      });
    
      function focus_form(){
        focussed_form = $(this).closest('form');
      }
    
      function unfocus_form(){
        focussed_form = NULL;
      }
    
    });
    
    Matt : I think you can consolidate some of that with: $(['input','textarea','select']).focus(focus_form).end().blur(unfocus_form); // Not sure if that end is needed or will work
    Dana the Sane : This is what I was thinking as well.
  • I don't think you need jQuery or javascript for this. You can indeed detect which Form a user hits submit on, or even which submit button is hit (in case there are more than one submit button per form).

    Here's the code you would use:

    <form action="http://foo.com/uri" method="POST">
      <input type="submit" name="action1a" value="add" />
      <input type="submit" name="action1b" value="delete" />
    </form>
    <form action="http://foo.com/uri" method="POST">
      <input type="submit" name="action2a" value="add" />
      <input type="submit" name="action2b" value="delete" />
      <input type="submit" name="action2c" value="someOtherAction" />
    </form>
    

    Then for the form-processing script, you would simply check the name of the submit button, for example:

    if (isset($_POST['action1a'])) ... // PHP syntax
    

    Alternatively, you can use images as submit buttons, then you can use the same name for all the submit buttons and just check their values--you can also do this with normal submit buttons if every button has a unique value attribute.


    Edit: One more method is to combine POST and GET values, i.e.:

    <form action="http://foo.com/uri?form=1" method="POST">
      <input type="submit" name="action" value="add" />
      <input type="submit" name="action" value="delete" />
    </form>
    <form action="http://foo.com/uri?form=2" method="POST">
      <input type="submit" name="action" value="add" />
      <input type="submit" name="action" value="delete" />
    </form>
    
  • page contains multiple forms, and the application would not be able to determine (or, so I am told) which form to action.

    When you press enter on an input control the browser seeks the first submit button in that form and simulates a click on it. In the case of multiple buttons, the first one will be pressed on keyboard enter (this is by no means written in stone and browsers may deviate from this).

    If you have two forms, the one that got a keypress will have it's first submit button pressed. Therefore you don't really need any special handling of this. You just have to stop being in the way.

    You can simulate this in code, on a form:

     $( 'form' ).bind('keypress', function(e){
       if ( e.keyCode == 13 ) {
         $( this ).find( 'input[type=submit]:first' ).click();
       }
     });
    

    Or window (for a demonstration of what is roughly happening):

     $( window ).bind('keypress', function(e){
       if ( $( e.originalTarget ).is( ':input' ) && e.keyCode == 13 ) {
         $(  e.originalTarget )
           .closest( 'form' )
             .find( 'input[type=submit]:first' )
               .click();
       }
     });
    

    Assuming of course that .preventDefault() has not been called on the event.

    Bottom line: If you have the event you can divine from it what element it came from and therefore which form it belongs to. Even in this case:

    <input type="button" value="LOGIN" name="btnLoginOk" onclick="submit();">
    

    Here submit() is a global function, but when it is called, its context (this) will be the element and you may do submit(e){ this.form.submit(); }.

    The application has been designed so there are no submit buttons (as in input type="submit") and, instead, the designers have gone for onclick handling.

    This sounds to me like the designer doesn't fully comprehend DOM / form events and is going the long way around the problem. Another likely reason could be that the program is old and was designed back when these things weren't quite as stable, or properly documented, as they are today.

    Replace this:

    <form action="/login/" method="POST">
      [...]
      <input type="button" value="LOGIN" name="btnLoginOk" onclick="submit();">
    </form>
    

    With this:

    <form action="/login/" method="POST">
      [...]
      <input type="submit" value="LOGIN" name="btnLoginOk">
    </form>
    

    Then add a key handler to all forms that need it, that detects and suppresses enter if some condition is met (for the forms that you actually do want to disable this on).

    // for all forms that POST that have 2+ submit buttons
    $( 'form[method=post]:has(:submit:eq(1))' ).bind('keydown', function(e){
      // if target is an enter key, input element, and not a button
      if ( e.keyCode == 13 && e.target.tagName == 'INPUT' && 
           !/^(button|reset|submit)$/i.test( e.target.type ) ) {
        return false;  // kill event
      }
    });
    

    Or better still: Use a form validation library (or jQuery plugin) that knows how to do this for you.

    MysticBrook : It all sounds like excellent advice. I will reserve some time early this week to try out the suggestions. Watch this space if I have any further comments! I will comment on how I get on, at least.

Is Lego MindStorms a good choice for basic robotics development?

I would like to learn how to write software for controlling robots.

Is Lego MindStorms a good choice for this? Are there better alternatives?

I'd prefer MindStorms, but after reading a couple of articles I get the impression that Lego has stopped research and development of MindStorms.

What are your suggestions?

From stackoverflow
  • I can't give you a good side-by-side comparison vs other robotics kits (I know MS has one), but I've spent a lot of time with mindstorms (to the point where I gave a user group presentation) and I think that it makes the programming enjoyable and teaches you the basics of sensors, input and output that you'd need to know with any kit.

    It gives you the foundation and makes it fun which is a great way to start. There are probably more sophisticated alternatives though...

  • I own the first release the the Lego MindStorms robotics kit, and I can not praise it enough. It's easy to get started with, and the possibilities are endless. Not only is it fun constructing things, it's a joy bringing them to life. It challenges you as an engineer and as a software developer. It makes you truly appreciate and understand the fragility of robotics research and development.

    The new NXT set is out as well. Largely developed by user feedback, it is the best Lego robotics kit yet.

    Arnold Zokas : Thanks for the info. I think I will buy the NXT set.
    Louis Davis : I have owned the NXT since it's release and I think it is an excellent way to get started in robotics. You can work on hardware or software. It allows you to quickly prototype ideas.
  • I coached a First Lego League team for a couple of years and we used the NXT robots. The team consisted of 6th, 7th and 8th graders and they were readily able to learn learn the graphical programming environment and to develop some pretty sophisticated programs with it. As coaches we guided them in good software practices (requirements, design, modularity, documentation, testing etc.) but the kids did the work and they learned a lot. The standard NXT software is basically a stripped down version of LabView and it's reasonably easy to use but a bit buggy. That was a good feature for the kids though - they learned the hard way to save their work often because the software can and does crash while you're editing.

    If you want to have a blast playing with robots and especially if you want to involve kids too, this is a great environment for it. But the standard software is a graphical programming language so you're wiring up and configuring function blocks not writing code and some people don't consider that "real" software. It all depends on what you want to learn. We only used the standard NXT software with the kids because of FLL contest rules.If you prefer using procedural languages the NXT is still a great platform for learning but you'd need to switch to an alternative development environment like one of these.

    Arnold Zokas : I am thinking of using Microsoft's Robotics Studio
  • You don't indicate if you are more interested in the hardware or software aspects of robotics. If you are primarly interested in software and don't want to spend money on hardware, you should consider a simulation environment.

    Think of things like flight simulators or game programs. You can "fly" a plane without having to buy one. You can also learn alot in the process.

    Microsoft's Robotics Studio has a version you can download for free which allows you to simulate the Lego Mindstorms as well as write programs for it. If you are a student you can get the full version for free as well.

    Of course if you want to spend the money there is nothing quite like the real thing and I am sure you will have a lot of fun with it.

    I just learned that LabView can also be used to program Lego Mindstorms. Take a a look at: http://www.ni.com/academic/mindstorms/ They have a version of LabView for students with deeply discounted pricing.

    Arnold Zokas : I am interested in both hardware and software aspects.
  • If you're just starting out, the most important thing will be the support community behind whatever kit you choose. MindStorms is very popular and I'm sure you'll have no problem finding answers to the (many) questions you will have as you work with it.

  • I don't know what kind of software you're interested in using, but MATLAB actually has a LEGO MINDSTORMS NXT Toolkit. It's been discussed on some of the MathWorks blogs, and there are some demos posted on the MathWorks File Exchange (here's one).

  • Yes, Lego Mindstorms is great, but don't use the default LabView G language interface to do your programming.

    Use something more advanced like LeJos.

  • Assuming you choose the Lego path, for Mindstorms I'd definitely recommend NQC.

    NQC is a programming language that you can use to program the Lego Mindstorms robots, and I found it much easier than dragging nodes around in a WYSIWYG-style environment (which is how the bundled software and LabView-based version worked).

    I haven't had any experience with the NXT robot, but if NQC sounds interesting, there's an equivalent for the NXT: NBC/NXC.

    Steve

Use SQL to Filter Drupal Views

I have a content type with a CCK integer field which takes a unix timestamp. I would like to create a view with a filter that takes the MySQL function "UNIX_TIMESTAMP":

alt text

If there is no way of doing this, how can I alter the SQL generated for the view?

From stackoverflow
  • I found a temporary solution which involves implementing the views_pre_execute hook inside the views module.

    I've documented it here in the comment labeled "Use SQL value for filter value on CCK integer field".

    I'm not very happy with this solution, though, because it seems a bit of a hack.

    Henrik Opel : Sidenote: The comment 'label' is actually a link to the comment itself, so you can link directly to it: http://drupal.org/node/409808#comment-1492672
  • You really ought to be using a date field, then you'd have "Now" in all of your filter options.

    If Views and CCK know your field is a date, they give you a lot more flexibility in how they filter and display the field.

Municipal datasets?

I'm looking for some data to create lookup tables with. Specifically, all the counties in each state in the US, and all the cities in each county.

Where might I find municipal datasets like this?

EDIT: I'm looking at census.gov and this appears like it may be the ticket.

From stackoverflow

Which Gantt chart/Project management tool would you recommend for linux?

I need a Project management tool that works in Linux, and has Gantt charts.

  1. It doesn't have to be free, just not expensive.
  2. I don't care how it stores the information I give it, as long as I can access it.
  3. I must be able to print the Gantt charts.
  4. Must work in Linux.

With those requirements, what can you recommend?

TheObserver asked a windows specific version of this question here.

Thanks for the help everyone.

From stackoverflow
  • The answers to http://stackoverflow.com/questions/171809/is-there-any-latex-package-for-drawing-gantt-diagrams. may be viable.

    J.J. : Interesting. Is "gantt" the proper spelling? If so, that would explain why I didn't find that question.
    Aaron Maenpaa : [Wikipedia says yes!](http://en.wikipedia.org/wiki/Gantt_chart)
  • You could try http://live.gnome.org/Planner maybe it satisfy your needs. :)

  • Planner, and OpenSched, in that order. There are some decent online Gantt (this is the correct spelling) chart tools online as well, usually integrated within a project management or bug-tracking web app or software package.

  • I use TaskJuggler - it's more powerful than other OSS software I've tried, but it's very complicated. It's the only software I found that could do what I needed, but I still consider it to be "best of a bad bunch". I too wouldn't mind paying, if I could be sure the software would do everything I needed.

    The big flaw with planner seems to be around resource leveling/allocation but I admit I haven't looked deeply into it. Planner would be my second choice.

  • You could also try some of the web-based project management tools. These days they fare quite well to the desktop alternatives. I can recommend dotProject. It's a nice, easy to use tool and it has printable gantt charts.

    Amos : Although I like and use dotProject, it has issues with Gantt Charts when the project gets above a certain level of complexity (it just fails to generate them).
    Ivan Peevski : You can increase the memory allowed in PHP (System Configuration has a setting to set how much memory to use for gantt chart generation) and it should be fine after that.
  • Also check Redmine.

  • Ganttproject is written in java and works on every platform.

  • Tthese guys, http://www.planningforce.com/ have used this pretty excellently. check it out.

  • I also use pf to make my plans ;) (http://www.planningforce.com)

  • If you are looking for simple Gantt Chart control in asp.net i recommend jsGantt.It's purely written in javascript ript,html,css and very fast.Also easy to integrate with any of the language in web. Here is a good tutorial of using jsGantt in ASP.net Here in CodeGlobe

  • Also, check out Clarizen online project management software. You can access work management over the web anytime, anywhere.

mod_wsgi/python sys.path.exend problems

I'm working on a mod_wsgi script.. at the beginning is:

sys.path.extend(map(os.path.abspath, ['/media/server/www/webroot/']))

But I've noticed, that every time I update the script the sys.path var keeps growing with duplicates of this extension:

['/usr/lib64/python25.zip'
'/usr/lib64/python2.5'
'/usr/lib64/python2.5/plat-linux2'
'/usr/lib64/python2.5/lib-tk'
'/usr/lib64/python2.5/lib-dynload'
'/usr/lib64/python2.5/site-packages'
'/usr/lib64/python2.5/site-packages/Numeric'
'/usr/lib64/python2.5/site-packages/gtk-2.0'
'/usr/lib64/python2.5/site-packages/scim-0.1'
'/usr/lib/python2.5/site-packages'
'/media/server/www/webroot'
'/media/server/www/webroot'
'/media/server/www/webroot'
'/media/server/www/webroot']

It resets every time I restart apache.. is there any way to make sure this doesn't happen? I want the module path to be loaded only once..

From stackoverflow
  • One fairly simple way to do this is to check to see if the path has already been extended before extending it::

    path_extension = map(os.path.abspath,['/media/server/www/webroot/']) 
    if path_extension[0] not in sys.path:
        sys.path.extend(path_extension)
    

    This has the disadvantage, however, of always scanning through most of sys.path when checking to see if it's been extended. A faster, though more complex, version is below::

    path_extension = map(os.path.abspath,['/media/server/www/webroot/']) 
    if path_extension[-1] not in reversed(sys.path):
        sys.path.extend(path_extension)
    

    A better solution, however, is probably to either add the path extensions to your PYTHONPATH environment variable or put a .pth file into your site-packages directory:

    http://docs.python.org/install/index.html

    David Berger : +1 .pth files are awesome. So are environment variables set from apache config.
  • No need to worry about checking or using abspath yourself. Use the ‘site’ module's built-in addsitedir function. It will take care of these issues and others (eg. pth files) automatically:

    import site
    site.addsitedir('/media/server/www/webroot/')
    

    (This function is only documented in Python 2.6, but it has pretty much always existed.)

  • The mod_wsgi documentation on code reloading covers this.

How to extend the "less" command behavior?

In normal cases, I suppose everyone only uses the "less" command to read the content of plain text files.

But on Gentoo, it seems that the less command line is a little more powerful than the one I use on other Linux distributions, or Cygwin, Mac OS X... the less command on Gentoo is able to list the content of compressed archive files, the ELF header and other information of executable files, and maybe more... I can't remember on what platform it was, but I think it is also possible to read PDF files with some versions of "less" (or maybe was it just a dream?).

So I wonder if there is a way to easily make extensions for the less command, for example to make it able to read (display in a nice way) some format of binary files. I searched for information about this on Google, but didn't find anything.

From stackoverflow
  • less is open, if you don't like the one you have, just grab a more up to date one.

  • According to this page and this page, less already has PDF support, at least in that version

    I tried less'ing a couple different PDF files, at it looks like some are graphics based and some are text based. I was able to read the text based ones, but not so much the graphics ones as they were all commands an not so much text.

  • Just did a "man less" on my Mac. less can work with input preprocessors. The man page had an example of setting up a preprocessor shell script to work with archives. The preprocessor recognizes the extension and fed the uncompressed file into less. You specify the preprocessor script with environment variables LESSOPEN and LESSCLOSE.

    Maybe your full-featured system had some scripts specified by LESSOPEN. Look in your environment for LESSOPEN.

    Cool, I learned something new looking for an answer.

    Note: I usually use "readelf -h" to dump ELF headers. Very useful when I am cross-compiling and need to verify the library format.

  • Have you looked at lesspipe.sh?

    Actually, lesspipe.sh only processes file or url before piping to less. BTW, I'm not using this, but I often type ps2ascii some.pdf | less to read pdf files.

  • Try "man lessfile" and "man lesspipe" for documentation on this behaviour.

    On Ubuntu, less processes PDFs into plain text by default. (I actually find this annoying since when I type "less something.pdf" it's usually because I want to look at the raw PDF. Easily worked around with "less < something.pdf" for the single-file case, though.)

Are there any open source filesystems for Windows that support encryption?

I know that NTFS supports encryption but otherwise is closed source. Likewise, I am aware of add-ins such as truecrypt but I am interested in encryption being built-in vs being bolted on.

From stackoverflow
  • No.

    There's Bitlocker, but it's implementation is closed source. Everything else not manufactured by Microsoft will, by definition, be "bolted on". Microsoft doesn't provide any open source filesystems in their OSes, AFAIK.

  • Keep in mind that encryption is often not done at the filesystem level. It's done at the block level, where sectors are actually read/written to disk. This allows one to use any filesystem with the encryption, as the filesystem sits on top of the encryption layer.

  • Any specific use cases?

    TrueCrypt supports full volume encryption, with a boot password. I have been unable to confirm this, but I believe that BitLocker also requires a password at boot. TrueCrypt is the only option I've been able to find, and it is relatively mature. Full disk encryption with TrueCrypt would be transparent - I'm not sure what you mean by "bolted-on", but I assume you mean not having to mount an encrypted volume each time you log in.

    Edit: Unfortunately there is no version of FUSE for Windows. There are the Dokan libraries, but they're not widely used AFAIK.

  • Personally, I use TrueCrypt, but PGP is excellent too.

How can I replace Ant with Maven?

What are the minimum steps I should follow to replace Ant with Maven?

From stackoverflow

Does hacking make you a better programmer?

You've heard about all the hackers who got caught and then received a killer job offering.

But then again, you've probably heard about IT workers who sabotaged their systems after being fired. Some people also argue that hacking is much easier than securing a system.

The question is, would you hire a hacker? And does hacking make a better programmer?

Addendum

The reason I ask this is that I know a few people who first became interested in programming because of hacking, and they seem to be fairly confident of their programming ability. As a result, it feels like people respect them as the best, but I always felt at least as capable even though I don't know as much about hacking as they do.

From stackoverflow
  • I would be cautious about hiring a hacker (just because I would be cautious of hiring anybody conducting criminal or quasi-criminal activities). I would look towards hiring one (especially for network security reasons) because they are familiar with finding holes others normally wouldn't, so their expertise in breaking into systems can be integral in learning how to make those systems better.

    The other question concerning hackers making better programmers...that's iffy. There are so many different types of hackers out there that it would be hard to say whether or not it would make them a better programmer. You could argue that hackers can become good programmers because a mind geared towards analysis would translate well into the analytical mind necessary for a good programmer.

    Dana the Sane : Good points, and the qualities that make a good hacker do not necessarily carry over to being a good team member. Also, I think it's particularly important to consider if the person will have problems ethically, i.e. following the rules, and representing your company in general.
    TheTXI : Agreed Dana. Whatever technical merits the hacker may have could possibly be overshadowed by personal red flags.
    Noldorin : There's no simple answer to this question (nor anything close really), but I think you've given a fair overview. Indeed, I wouldn't think there's any clear reason to consider a "hacker" to be an especially good programmer, in general. You might even consider their skills to be narrow and poorly suited to those required for a programming job.
  • Hacking teaches you about flawed software and introduces you to pragmatic difficulties in designing secure software. Per the original question I would hire a hacker to test out the security of my systems. I would likely avoid hiring a notorious hacker in projects involving HIPPA, PCI, or PII data.

  • I would definitely hire a hacker, but I'm not sure our definitions of hacker are identical. To me, a hacker is a passionate, driven, jack-of-all-trades coder who knows enough about everything to at least know where to look to figure out how to do anything. At my company we regularly hire hackers as we do a lot of things with scripting languages and low-level Unixy stuff (at least our team does.)

    Your question is actually whether or not you should hire a cracker. And it really depends on what the job description is, but as long as you trust him/her not to do anything illegal, I would hire if he or she is a good engineer. That's all that really matters to me.

    Dr. Zim : Haacked, but not hacked :D.
    Henrik Paul : +1 for the (oft confused) distinction between a hackaer and a cracker
  • Those are two completely different questions, but here goes:

    Would you hire a hacker?

    Seriously, why not? If your application is absolutely mission critical and security is of utmost concern, this is a great way to test your application for security flaws.

    Of course the more difficult part is finding out whether the hacker is the real thing or just a wanabe script kiddie.

    In my country a senator recently proposed to put up a hacking contest to test our country's new automated poll system, and I think it's a great way to find the weaknesses and establish the credibility of that system.

    Does hacking make a better programmer?

    Well, there are hackers and there are script kiddies. The difference between the two is while the first one is truly intelligible in finding flaws in the system, the other one only exploits known vulnerabilities using publicly available code.

    If that doesn't sound familiar, that's quite the same as difference between an Einstein and a Mort.

    Also, many hackers follow some kind of ethics wherein they vow to do no harm -- script kiddies simply don't care and "just want to have fun".

  • I would not hire a "hacker" (in the sense you mean: a suspected or convicted criminal) for one simple reason: If they are morally and ethically flexible enough to attack one system, what's to stop them from doing it again, and when they do, it's my company and my reputation that's on the line.

    Does hacking make you a better programmer?

    I would agree with TheTXI that some of the traits possessed by a hacker lend themselves to the making of a good programmer. These would include research ability, thinking outside the box, and logical analysis.

    On the other hand, a "hacker" is generally not a team player. They are often seeking their own fame, and not the success of their company or product.

  • Just my experience in "reverse engineering". I spent some time analyzing DLL entry points, parsing raw data files, and IP packet sniffing.

    I was able through logic and some creative guessing to figure out what was going over the wire, and what the bits in the files meant. From there I could hijack the wire protocol or intercept the external calls.

    It was fun, it was challenging, but it emphatically did NOT make me a better programmer. Didn't make me a worse one either. Exploiting weaknesses in compiled code is fundamentally different than good professional programming. I did learn a few things about program surface area, and methods of attack, but then I had to translate those into the program architecture. Those are more about structure than content.

    What is important to me in a "good" programmer is being able to produce code that is as complex as it needs to be, but no more. Being able to parse bits inside of an IP packet in your head is a good and fun skill, but tells me nothing about your software design skills.

    To answer the OP's question, I would hire a hacker if they were good at writing software. I don't think it makes you a better programmer. It may help in overall system design, but you can learn those lessons without the experience of being an attacker.

  • It's a lot easier to knock down the sand castle than it is to build one.

    The same applies to building software systems or criticizing legacy code.

  • Much hinges here on the agreed upon definition of "hacker".

    //Hackety hack hack hack.

    ;)

    Consider: coder vs. hacker vs. cracker vs. script kiddie vs. jedi vs. cyberpunk vs. ninja vs. code monkey vs. reverse engineer vs. criminal vs. mischevious person vs. felon vs. convicted felon vs. suspected felon vs. mastermind vs. chaotic good characters vs. chaotic evil doers vs. dictators vs. emperor vs. insurgent vs. terrorist vs. agents vs. neo vs. copyright violators vs. copy writers vs. spammers vs. marketers vs. telemarketers vs. spyware creators vs. computer virus creators, etc. etc., for example.

    Excellent programmers necessarily have done hacking before, in the "jedi" sense. Jedis rebelled against the empire, but were overall, good, though not technically law abiding.

    Most great programmers certainly associate themselves as being a hacker in the romantic cyberpunk sense of the word, however being a hacker does not imply a lack of morals or ethics.

    Some hackers may find that their conscience does not prohibit them from executing technological deeds that the general societal concensus may deem as questionable at best or worse reprehensible or worst yet, literally flat out unlawful. Free will does exist, of course.

    Reverse engineers and crackers are usually better than your average hacker at hacking.

    Personally I would never hire anyone who didn't at least know how to do some reverse engineering. It is necessarily a part of being a good engineer, from my perspective. Then again, I consider myself a fairly veteran coder/manager and have seen an abnormally high number of instances that completely justify reverse engineering for corporate gain and/or the avoidance of corporate death.

    I have never had a problem not doing cool/mischeivous things that I know I "could" do, if I "really wanted to". Free time is a good instant reward for moderate amounts of laziness. Who wants to go out of one's way to break laws? Come on. I have never identified what makes a criminal organization tick, except for the profit motive.

    Much depends on what you consider "profit". What you value. What you prize.

    Not all hackers are criminals. In fact, the vast majority are not.

    Someone intent on remaining a hardened criminal is probably not going to be someone you want to hire, but it depends on your situation. First of all, you may not even have the choice to hire a convicted felon depending on your industry or for your application. Are you in Government?

    Then again if you are dealing specifically with security and counter-security and counter-counter-security, it is virtually a requirement that you truly are "as smart as a fox" and that you have the salt to outsmart foxes should you be given a chance to accept such a mission.

    True masterminds would never get caught. If they ever got caught, they would have lost their prior status as a mastermind. Masterminds could be criminals but not felons, and probably wouldn't need to be hired by you for your measly bread. Some good masterminds probably are out there. I don't know any.

    You do want those jedis. You want the ninjas. You want cyberpunks. You want sleuths. You want vast gobs and gobs of intelligence. You want people who can fix any problem and are undeterred by bugs. You want people who know that anything truly is possible.

    It's just code.

    Highly intelligent systems of logic consider all options. So you're never going to find smart people to work for you who have not even considered doing something wrong in their entire life.

    If you are looking for law abiding citizens to work for you, it is best to look for people who at least portray outwardly some behavior that seems to imply an nice, common, internal value system that generally jives with what you think of as normal. You never know what is going on in peoples' heads. Just because someone has never been caught does not mean that everything that they do in their personal life is perfectly legal or ethical or moral. But there are lines.

    You probably don't want to hire people who are doing very bad things even on their own time. What you consider to be very bad things may vary, a lot.

    So called "ethical hacking" may not be illegal in your country, but could still be unethical.

    For Ego, For Self, For Family, For Country, For Humankind, For Earth, For the Time-Space Continuum / For God

    For God / For the Time-Space Continuum, For Earth, For Humankind, For Country, For Family, For Self, For Ego

    See also: Dungeons and Dragons Alignments.

    See also: Religion

    Generally, you want to hire people who fit your "Alignment", whether you be government or some sort of a crime boss.

    I consider myself sort of white/gray hat hacker. I have done black hat kinds of things before, never gotten caught, and don't plan on engaging in those kinds of activities on a regular basis.

    Doing anything in your personal or professional life that people could blackmail you for or put you behind bars for is generally dumb all the way around, whether you are a criminal mastermind, or a jedi knight, or just looking to hire one.

    Blackmailing people or collecting information that could be used to blackmail people is the worst offense, and certainly far worse than breaking into any system.

    I have worked in carrier scale email, job boards, banking and have had access to extremely ridiculous amounts of extremely sensitive data and have written apps against that stuff. I didn't get to do that by being a dodo brain in the first place.

    Whether you should have access to lots of data is kind of like asking whether or not you should have The One Ring from the the Lord of the Rings. Only those who you know have no interest in using it should have high levels of access.

    I have felt comfortable having been given official professional access to lots and lots of data on the premise that I could spider most of it myself anyways off the internet for free, were I ever in a real bind. Mostly it's like, why bother? What me worry? Who cares. I'm the type of person who wouldn't use The One Ring, even if I had it. That's why usually I have had to share the burden of being on the side of Good and have had to hope that the baddies never got in and have had to try my hardest to make sure that's how things have tended to gravitate. Who's really a baddie anyway though? I would like to think of you as my friend, and not my enemy. I don't want to see you to go to jail for anything you did with some ones and and with some zeroes. If you however, ever directly or indirectly knowingly put people's lives or liberties in jeopardy, whether in the name of the empire or in the name of the rebellion, shame on you. Don't do that. The fact is, there are lots of systems on which the safety of peoples' lives directly depend. No bad people should be running those systems. No people who could ever turn bad should be running those systems. Think about that. Should anyone have the keys to the kingdom?

    Triumvirates rock.

    Multikey systems rock.

    "You won't know who to trust." -Sneakers

    To build a truly secure system, trust no one -- not even yourself.

    Also, never invite a vampire into your home.

    Also, don't be like Mr. Smith from the Matrix.

    Also, don't bite the hand that feeds you.

    People are people. Find the heart to forgive.

    Strive to remember everything and to never delete anything.

    ;)

    Unknown : I don't think anyone can agree on the term hacker. But what I can tell you is that some of the people I know have rooted boxes behind proxies, but have never claimed to do anything irreversible like formatting the hd.