Thursday, April 28, 2011

Need a storage solution that is scalable, distributed and can read data extremely fast and works with .NET

I currently have a data solution in RDBMS. The load on the server will grow by 10x, and I do not believe it will scale.

I believe what I need is a data store that can provide fault tolerant, scalable and that can retrieve data extremely fast.

The Stats
    Records: 200 million
    Total Data Size (not including indexes):  381 GB
    New records per day: 200,000
    Queries per Sec:  5,000
    Query Result: 1 - 2000 records


Requirements
    Very fast reads
    Scalable 
    Fault tolerant
    Able to execute complex queries (conditions across many columns)
    Range Queries
    Distributed
    Partition – Is this required for 381 GB of data?
    Able to Reload from file
    In-Memory (not sure)

Not Required
    ACID - Transactions

The primary purpose of the data store is retrieve data very fast. The queries that will access this data will have conditions across many different columns (30 columns and probably many more). I hope this is enough info.

I have read about many different types of data stores that include NoSQL, In-Memory, Distributed Hashed, Key-Value, Information Retrieval Library, Document Store, Structured Storage, Distributed Database, Tabular and others. And then there are over 2 dozen products that implement these database types. This is a lot of stuff to digest and figure out which would provide the best solution.

It would be preferred that the solution run on Windows and is compatible with Microsoft .NET.

Base on the information above, does any one have any suggestions and why?

Thanks

From stackoverflow
  • So, what is your problem? I do not really see anything even nontrivial here.

    • Fast and scaling: Grab a database (sorry, complex queries, columns = database) and get some NICE SAN - a HP EVA is great. I have seen it, in a database, deliver 800mb of random IO reads per seconds..... using 190 SAS discs. Fast enough for you? Sorry, but THIS is scalability.

    • 400gb database size are not remarakble by any means.

      • Grab a decent server. Supermicro has one with space for 24 discs in 2 rack units height.
      • Grab a higher end SAS raid controller - Adaptec.
      • Plug in ReadSSD drives in a RAID 10 configuration. YOu will be surprised - you will saturate the IO bus faster than you can see "ouch". Scalability is there with 24 discs space. And an IO bus that can handle 1.2 Gigabyte per second.

    Finally, get a pro to tune your database server(s). That simple. SQL Server is a lot more complicated to properly use than "ok, I just know how a select should look" (without really knmowing).

    BarDev : Thanks for your input and you may be total correct, but the problem doesn’t seems to be the amount of data that is stored, but the 5,000 queries per sec against 200 million records. One possible problem with our current solution is that the data resides in a database that is over 2 TB in size. So there could be contentions there. There is the possibility of moving the table to its own database and a separate lung on the SAN. If anything this is a good process for me to learn about other databases.
    TomTom : What is the problem here? Get a proper computer. It is easy to get a computer with 24 cores those days from AMD. Actually 48 cores is easy, too, from AMD. Plus replication or something like that and you are more than ok with that amount of queries. DO the queries have to be EXACT to that moment, or is a variation ok (which allows for replication to kick in).

algorithm for making a red black tree from a binary search tree

Hi is there any clear algorithm that make a red black tree from a binary search tree? please help me thanks

From stackoverflow
  • One way to do it is traverse the nodes in the binary tree, and add each one to a new red-black tree.

How can I return an array from a function in classic asp?

Tried this

Function myfunction()
Dim myArray(1)
myArray(0) = "1"
myArray(1) = "2"

myfunction = myArray
End Function

Dim newarray = myfunction()

And I get 500 error.

I'm using IIS7 with .NET runtime ASP.Net 2.0/3.0/3.5 On Godaddy's free economy hosting if that helps.

From stackoverflow
  • In VBScript, you can't assign a value to a variable on the same line that you declare it. You'll have to change

    Dim newarray = myfunction()
    

    to

    Dim newarray
    newarray = myfunction()
    

Django query to get next previous item by date in category...

Hello. First time poster to Stack Overflow...

I suspect my answer lies in this solution: http://stackoverflow.com/questions/2074514/django-query-that-get-most-recent-objects-from-different-categories but I am having trouble 'getting' Django's annotate() functionality.

I've gotten this far:

previous = Item.objects.filter(date_added__lte=item.date_added).filter(???)[0:1]

My Items are manytomany with Categories. I'm trying to figure out how to use the second filter to test that the item's current category (based on a url parameter) is in items.categories of the queryset returned by the first filter.

Could use a push in the right direction.

Thanks. Dan J.

Of course.

class Category(models.Model):
    section = models.ForeignKey(Section)
    name = models.CharField(max_length=50)
    slug = models.SlugField()
    ....

class Item(models.Model):
    categories = models.ManyToManyField(Category)
    name = models.CharField(max_length=256)
    date_added = models.DateTimeField(default=datetime.datetime.today)
    ....
From stackoverflow
  • OK, I'm silly. Didn't realize it was as simple as 'categories=category' for mtm field lookup. Thought I had to check if category was 'in' categories.

    previous_items = Item.objects.filter(date_added__lt=item.date_added).filter(categories=category)
    

Website Layout Statistics

I have a client who has suggested laying out a long list of categories in a custom order. The order is to be decided by them based on product items they sell the most etc.

I tend to disagree and feel that people browsing the internet prefer to search lists of categories that are in alphabetical order or sorted by something they can take reference of such as a date.

I would like to know others thoughts on this and it would be appreciated if anyone could point me in the direction of any open source surveys that have been taken in this area.

Thanks Ben

From stackoverflow
  • What a silly stance to take regarding a simple customer request. Allow for both orderings, and other ones too. There is no survey that will demonstrate that the client is wrong as they are - by definition - correct.

    Code that allows for different orderings has greater utility anyway, and real user data will be able to show them which - if either - should be the default.

    Ben : I did not take the stance as I am well aware the customer is always right. It was just my opinion. I thought if there was some survey or stats on the matter I could offer it to them for reading, they are a reasonable client and prepared to be offered valuable advice that could help there business. The site is built on Wordpress so there are no problems changing the order of the data. I could also implement client side sorting and save it in a cookie so every user could choose their preference but seems like overkill.
    msw : Overkill? Without user metrics you actually have no idea. That you are trying to convince some anonymous schmoe on the internet (me) that your approach is correct is kinda further evidence that your thinking incorrectly about the whole matter.

jQuery ajax post to web service

$(document).ready(function() {
        $.ajax({ type: "POST",
                        url: "/getprojects.ashx",
                        data: "<formData client=\"\" year=\"\" categories=\"\" tags=\"\" freeText=\"\" count=\"34\" page=\"1\"></formData>",
                        dataType: "text/xml",
                        cache: false,
                        error: function() { alert("No data found."); },
                        success: function(xml) {
                            alert("it works");
                            alert($(xml).find("project")[0].attr("id"));
                        }
        });
    });

My problem is i get some data back but i can't seem to get it displayed.

From stackoverflow
  • Your dataType seems to be wrong. It should look like

    dataType: "xml"
    

    Your data structure also looks pretty wierd. Have a look at .serializeArray(). It should be standard query string foo=bar&test=bla etc.

    If the success handler gets executed, try to lookup your xml variable plain, without operating on it with .find() or whatever. Still empty?

    Buckley : By changing to dataType: "xml" it hits the error handler
    jAndy : @Buckley: see my post again, your `data` is also incorrect. If it still executes the error handler, lookup the error code/string by passing `function(xhr, textStatus, error)`
    Buckley : Thanks jAndy, im having a bit of trouble with the .serializeArray()
    Buckley : I get a [object XMLHttpRequest parsererror TypeError: a is null] with function(xhr, textStatus, error)
  • dataType should be the type of what you receive but contentType should be the mime-type of what you are sending, the following should be ok:

    $(document).ready(function() {
            $.ajax({ type: "POST",
                            url: "/getprojects.ashx",
                            data: "<formData client=\"\" year=\"\" categories=\"\" tags=\"\" freeText=\"\" count=\"34\" page=\"1\"></formData>",
                            contentType: "text/xml",
                            dataType: "xml",
                            cache: false,
                            error: function() { alert("No data found."); },
                            success: function(xml) {
                                alert("it works");
                                alert($(xml).find("project")[0].attr("id"));
                            }
            });
        });
    
    Buckley : Thanks but for some reason it hits the error handler
    Claude Vedovini : the error callback signature is error(XMLHttpRequest, textStatus, errorThrown) what are the values of the parameters?
    Buckley : [object XMLHttpRequest parsererror TypeError: a is null] but ive kinda given up and move on but an answer on how to get it working would still be appreciated.
    Claude Vedovini : The question now is whether the issue is while sending or receiving data. Do your server receive the request and what is its response?

HTTP status code for "success with errors"?

I've poked around a bit, but I don't see an HTTP status code for when a request's succeeds, but there is an error after the "point of no return".

e.g., Say you process a request, its committed to the database, but while returning the result you run of memory, or encounter a NPE, or what have you. It would have been a 200 response, but now, internally, you aren't able to return the proper, well-formed response.

202 Accepted doesn't seem to fit since we've already processed the request.

What status code means "Success, but errors"? Does one even exist?

From stackoverflow
  • If the server is aware that it has encountered a problem, it should normally return a 5xx error. The most generic one is the 500 Server Error, which the RFC 2616 defines as follows:

    500 Internal Server Error

    The server encountered an unexpected condition which prevented it from fulfilling the request.

    Then it's the client's responsibility to reattempt the request. If the previous request was partially committed, it's the server's (or the database's) responsibility to roll that back, or to handle the duplicate transaction appropriately.

    Richard Levasseur : I'm not really satisfied with this answer. What does "fulfill" mean, exactly? We've modified the resource in whatever way the client requested. If they reload the page, they'll see the changes. As far as the user is concerned, it was successful. To me, it really sounds like we've fulfilled the _request_, but haven't fulfilled the _response_.
    Daniel Vassallo : @Richard: I always understood "fulfill" to include the response as well (but I might be wrong on this). Nevertheless, this status code is very generic, and it should be used whenever the server encounters a problem which cannot be described by another more specific 5xx error. I think [@Jim](http://stackoverflow.com/users/45935/jim-ferrans) described what I intended to say better, [in the other answer](http://stackoverflow.com/questions/3066972/http-status-code-for-success-with-errors/3067090#3067090).
  • I agree with @Daniel that the proper response is an HTTP 500 (server error). The web application has to be written to roll back the transaction when there is an error, not leave things half-finished.

    One thing you can leverage in your web application is "idempotency". This is the property of a function (or operation) that you can repeat it as many times as you like with the same result. For instance if a read fails, the client can simply retry it until it succeeds. If a deletion appears to fail, the client can again retry and the server will treat the request as valid whether or not the resource being deleted is already gone. And if an update appears to fail, the client can retry that until it gets a successful return from the server. The REST approach to architecting web services makes heavy use of idempotency to make operations robust in the face of error.

    Richard Levasseur : To clarify, the transaction is already committed (e.g, consider the case when OutOfMemoryError occurs during the encoding of the response). To implement idempotency, you would need to implement revision control, no? Having the server keep track of submitted changes and clients supply and change id. There's also the case of handling non-temporary errors (say there is a bug resulting in a NPE instead of an out of memory error) - the client can retry all they'd like, but it'll never succeed (despite it having succeeded the first time, and the subsequent times being redundant).
    Jim Ferrans : @Richard: It "all depends". If it's a content management app and you don't mind if two "simultaneous" updates seem to happen out of strict order occasionally, you don't have to do versioning. But versioning or timestamping might be appropriate if you have tighter constraints. Another approach is to form as much of your response within the confines of the transaction as you can, so an OOME would cause the transaction to abort. And maybe persistent message queues holding transaction requests and results could be what you want (check out Apache's ActiveMQ). +1 for the probing questions!
  • HTTP doesn't have such a status code, but there is a best practice that allows you to handle such situations - redirect the user after a POST operation.

    Here is a break down -

    1. A POST request tries to modify data on the server
    2. If the server fails, it sends a 500 error to indicate failure
    3. If the server succeeds, it sends a 302 redirect response
    4. The browser then sends a fresh GET request to the server
    5. If this fails, you get a 500 error, otherwise you get a 200

    So, your use case of 'Saved data but can't retrieve it immediately' translates to a 302 redirect for the initial POST, followed by a 500 for the subsequent GET.

    This approach has other advantages - you get rid of the annoying 'Are you sure you want to resubmit the data?' message. Also keeps your back/forward/refresh buttons usable.

Proper use of submodules in .NET solutions

I have a library I wrote with a structure like this:

SolutionA\
--Source\
  --Core\
  --Tests\
--Tools\
  --TestFramework\
  --MockTool\
SolutionA.sln

I want to include this as a submodule for SolutionB. If I use this entire structure as a submodule, it would get a bunch of stuff that SolutionB doesn't care about; it doesn't care about SolutionA.sln; it doesn't care about Tests\; it doesn't care about Tools\. Really, SolutionB only cares about Core\.

It looks like I need a separate repository for Core\. So is it usual practice to have two repositories for .NET solutions whose source is used by other solutions? One for only the (non-test) code itself (plus needed libraries), and one for the test tools and solution file?

From stackoverflow
  • Solutions are simply containers for one or more projects; which may fall under the same "solution" folder or somewhere externally.

    If you have a project, in this case "Core" then you can reference that project source directly from one or more solutions. In this case, SolutionA and SolutionB.

    The extraneous stuff like Tests\, TestFramework\, MockTool\, etc, unless required by Core, don't have to be included in your other solution.

    Make sense?

    Sam Pearson : I see what you're saying, but I need my build server to be able to pull what it needs to build SolutionB all by itself. I could manually set up the .sln structure on the build server, and have it pull in repositories into that folder, but I'd rather have a clone-n-go strategy here. (Build server --> git clone uri/to/SolutionB.git --> go).
    Sam Pearson : (With perhaps a submodule init + update, which TeamCity's git plugin can be configured to do)
    Sam Pearson : On second thought, going forward I'll probably end up using this solution (with a couple modifications). There's simply too many shared resources among the repositories to copy into each one, and I'm writing so many bespoke applications there's going to be many more repositories.

SQL 2008 installation - Creation of builtin\administrator group

During installation of SQL2008 will the builtin\administrator group be created automatically. I observed that it didnt get created. How do we create this group manually.

Or otherwise if we want it to be created in installation itself what settings needs to be changed.

From stackoverflow

Problem with header in php

Consider the following code

<?php

 $username = "root";
 $password = "";
 $host = "localhost";
 $database = "binaries";

 @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

 @mysql_select_db($database) or die("Can not select the database: ".mysql_error());

 $id = 5;

 if(!isset($id) || empty($id)){
 die("Please select your image!");
 }else{

$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['imag'];
header('Content-type: image/jpg');
echo '<table><tr><td height="700" width="700">';// Line X
print $content;

echo '</td></tr></table>';//Line Y

}

?>  

When I comment the lines X and Y the image gets displayed, otherwise not.What could be the possible reason?

EDIT: After following Matt's advice.

show.php

 echo '<table><tr><td>
  <img src="image.php"/>
  </td></tr></table>';

image.php

$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['imag'];
header('Content-type: image/jpg');

print $content;

Even after doing this I am not getting the expected result.

EDIT: code of 'image.php' :

 <?php
  $username = "root";
  $password = "";
  $host = "localhost";
  $database = "binaries";

  @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

 @mysql_select_db($database) or die("Can not select the database: ".mysql_error());




 $query = mysql_query("SELECT * FROM tbl_images WHERE id=5");
 $row = mysql_fetch_array($query);
 $content = $row['imag'];
 header('Content-type: image/jpg');
 echo $content;

?>
From stackoverflow
  • Because when the browser is told the MIME type is image/jpg, the last thing it is expecting to see is <table ...

    When you set the MIME type, you are telling the browser "I am sending you an image." However, HTML markup is certainly not image data, so the browser doesn't know how to render it.

    MvanGeest : +1 A file/data stream is either `image/jpg` or `text/html`, not both.
    Satish : How should i display the image inside the table then?
    Matt : @Satish a separate request should be sending the table which has an ``
    Satish : @Matt:Please make me more clear where it should be written in this script.How can a path of image be determined when it is fetched from database?
    Matt : @Satish No matter what's in the database, the name of your image script is the same. Let's say your above code is in a file called `image.php`. To display it in a table, have another file send `
    `
    Satish : @matt: I have edited my question...please have a look
    Matt : @Satish can you browse to image.php directly? Do you see an image?
    Satish : @Matt:No still i don't get the image in the browser.
    Matt : @Satish Post the full image.php source? What do you see if view the source on the browser?
    Satish : @Matt: On viewing the source, the code that i see is
    Matt : @Satish - right, but when you browse to `image.php` *directly* .. you don't see an image, right? Can you view-source on *that*? Also, please post your current image.php code in its entirety ..
    Satish : code of 'image.php' :
    Matt : @Satish and what do you see when you view source that? Is this available online somewhere?
    Satish : @Matt: I dont know the specific name for such form of image but you can consider it as thumbnail displaying no image.

does it make sense to send password information during email communication from websites

Most of the online sites on registration do send a link to activate the site and on any further correspondence with the end user they provide information about the site and also provide the login credentials with password in clear text (as given below)

Username - myname@gmail.com Password - mysecretpassword

What would you do in such a case? From a usability perspective does it make sense to send the password information in clear text or should you just avoid sending this information. I was under the impression that most of the passwords are MD5 hashed before storing in the database and hence the service provider will not have any access to clear text passwords, is this a security violation?

From stackoverflow
  • Yes, this is definitely a security violation. Only a salted and hashed version of passwords should be stored.

    It is common to have reset password functionality that sends either a temporary auto-generated password (which should be good for only one login) or a one-time reset link. This does mean your other accounts are only as secure as your email.

    However, you should steer clear of any site that will email your actual password in clear text.

    Samuel : will definitely avoid clear text communication of passwords.
  • It's a commonly-held fallacy that if you receive a password in plain-text it means they aren't stored securely - passwords like any other data can be stored using reversible encryption.

    Having said that, it's pretty likely anyone that sends you a plaintext password does not have a clue about security and is probably storing them carelessly (unless the passwords are used as weak real-world identifiers, say as part of an in-store membership scheme, in which case they shouldn't be called passwords lest your customers get confused).

    If you send a password plain-text you may as well assume that if it is linked to something important then it has been compromised. There are just too many weak points. You can also do a lot more unintentional damage.

    1. The email could be intercepted giving someone else the password.
    2. Someone could see them open the email on their screen (been at mates houses and had this happen to both of us so many times, and every time is a massive headache to go change all your passwords).
    3. The email might be forwarded to other addresses which are not secure.
    4. The email might bounce/encounter a server error and then you (perhaps your untrusted staff or outsourced helpdesk too?), and the email server's system admin will probably get copies of the original email.
    5. Someone who obtains access to the user's emails through a cookie hijack or even just a briefly unattended open email account will now be able to see their password. Worse, their password is probably used elsewhere (or at least has a common stem, e.g. "password1", "password1$$" "passwordSuperSecure123") so you've now compromised more than just your own service. Worse still, it might be the password to the email account that's been hijacked and now they can steal this person's email account and thus identity for a much longer time than the expiry date on the cookie/session. (This has all happened to people I know).
    Matthew Flaschen : It's not a fallacy at all. Passwords should *not* be stored using reversible encryption. It is all too common for entire systems (including both database and key) to be compromised. If you use reversible encryption, that means the attacker gets access to the password (which users usually use repeatedly, and in more than one place). If you use salting and hashing, they don't.
    Graphain : The fallacy is that passwords sent as plaintext indicates passwords stored as plaintext. If they have access to your key and database then you probably have bigger issues at hand. If they have access to your salt and your database then they can still generate a rainbow table that shouldn't take that long to break most of the hashed passwords.
    Longpoke : @Matthew Flaschen: If you use the same password repeatedly, you are asking for it.
    Graphain : I just want to point out I wasn't encouraging reversible passwords over hashed passwords either, it's just a compromise that sometimes has to be made under business pressure. I was simply addressing the OP's question "does this mean they're stored as plaintext" before addressing "should I send passwords as plaintext".
    Matthew Flaschen : @Graphain, nobody said "passwords sent as plaintext indicates passwords stored as plaintext." The OP said, and I agree, it indicates a security violation. Obviously you don't want people cracking your systems. But in that scenario, there's no reason to also let them get decrypted passwords. @Longpoke, even if users didn't use passwords in multiple places (and it's a fact of life they do), the attacker could still use the decrypted passwords at the same site he cracked, once it was up and running again.
    Graphain : @Matthew Flaschen - Encrypted data does not indicate a security violation. By your logic all encryption is pointless.
    Matthew Flaschen : No, encryption in general is not pointless. It is essential to provide confidentiality. But here we don't want confidentiality. We want *no one* to be able to recover the passwords, even if the system is compromised.
  • There are always trade-offs, and developers have to consider useability, the savvy-ness of the intended users, the secrecy and importance of the data, the frequency that the website will be used, and so on. Of course users don't want their privacy violated, but on the other hand "ordinary" web users may be turned off by having to remember a password, or even having to invent one in the first place (some websites simplify user registration by generating a random password and emailing it). Website developers have a responsibility to keep the users' best interests in mind when designing security.

    My advice is that passwords should only be emailed in the clear when they are randomly generated. This avoids the following awkward scenario: a user registers with a password which they are already using for various other web services, and then receives a registration confirmation email containing the password they just entered. A lot of users may not be security-conscious enough to use unique passwords for every website, but they are security-conscious enough to recognize that "sensitive" passwords should not be sent around by email.

Check if Integer is Positive or Negative - Objective C

Hello,

How can I tell in objective-c coding if an integer is positive or negative. I'm doing this so that I can write an "if" statement stating that if this integer is positive then do this, and if its negative do this.

Thanks,

Kevin

From stackoverflow
  • if (x >= 0)
    {
        // do positive stuff
    }
    else
    {
        // do negative stuff
    }
    

    If you want to treat the x == 0 case separately (since 0 is neither positive nor negative), then you can do it like this:

    if (x > 0)
    {
        // do positive stuff
    }
    else if (x == 0)
    {
        // do zero stuff
    }
    else
    {
        // do negative stuff
    }
    
    BlueRaja - Danny Pflughoeft : 0 is positive now? :)
    Deniz Acay : most mathematicians accept 0 as a positive value
    Eiko : Until they discover functions like log(x).
    Paul R : @BlueRaja - Danny Pflughoeft: well it doesn't have a `-` in front of if, so that's good enough for me. ;-)
    BlueRaja - Danny Pflughoeft : @Deniz: Mathematicians say 0 is a *non-negative* value; but it's not *positive*.
    Deniz Acay : @BlueRaja - Danny Pflughoeft: if...else statemens evaluate logical expressions as true/false, so for computer "if it is not negative, it is positive".
    Eiko : @Deniz Acay: Then please do a if(-1) printf("Wow I'm positive"); and fasten your seatbelts.... C takes everything != 0 as true.
    Deniz Acay : That's why i hate C :)
    JWWalker : @Deniz Acay: I've never heard of mathematicians accepting 0 as positive (and I used to be a math professor). Mathematicians use the word "nonnegative" all the time. They wouldn't need the word if it meant the same thing as "negative".
    Deniz Acay : Looks like i understood this "non-negative" word as "positive", so thanks for correction :)
  • Maybe I am missing something and I don't understand the quesiton but isn't this just

    if(value >= 0)
    {
    }
    else
    {
    }
    
  • -(void) tellTheSign:(int)aNumber
    {
       printf("The number is zero!\n");
       int test = 1/aNumber;
       printf("No wait... it is positive!\n");
       int test2 = 1/(aNumber - abs(aNumber));
       printf("Sorry again, it is negative!\n");
    }
    

    ;-)

    Seriously though, just use

    if (x < 0) {
    // ...
    } else if (x == 0) {
    // ...
    } else {
    // ...
    }
    

    Don't overdo methods ans properties and helper functions for trivial things.

What is "helpx_last_check" from wordpress database

I am a developer who works full time with wordpress and I came across something in my database which I have never seen before. I tried the normal search engine approach and have found nothing. Wondering if the wonderful people of stackoverflow have seen this before. I am pretty sure it isn't harmful. This is the entry in the mysql database.

Table is "_options"

option_id: 1165
blog_id: 0
option_name: helpx_last_check   
option_value: 1276628545    
autoload: yes

I am specifically wondering what "helpx_last_check" is. Thanks

From stackoverflow
  • Do you (or did you) have the MapPress Easy Google Maps plugin installed? This includes some helpx plugin options, but I haven't investigated what they check. If it's not this plugin, search your code for a class called helpx, maybe others use it too.

    bvandrunen : Thanks for your help...I actually installed it about a week ago. Perfect...now if anyone else has this question they can find it here or through google. (since they couldn't before) Thanks Jan

Drupal Form can't access javascript function (errors "not a function")

using drupal with lightbox2 to open a form. this form is from a custom module.

the module has a setting: 'onsubmit' => 'return form_submission(this);' and that appears to be working correctly.

I've included the functions.js in the theme.info file and it's showing up, i can open that file and see the function.

for some reason, i keep getting "form_submission not a function" when i do submit the form.

if(Drupal.jsEnabled)
{
$(document).ready(function() {
    // Call back function for AJAX call

        var form_submission = function(responseText) {
            alert (responseText); 
        }

        // preventing entire page from reloading
        return false;
    });

}
From stackoverflow
  • form_submission has to be a defined function.

    function form_submission(data) {
       // action code
    }
    

    or also try

    var form_submission = new function(data) {
       // action code
    }
    
    eriksays : thanks -- but something else is going on. i can add the function between script tags right above the form and still no luck. i tried both function declaration techniques you mentioned
    Kevin : If you put an alert right after if(Drupal.jsEnabled), does it appear? Is that condition true?
  • Not that this is the perfect answer, but I removed the function from within the document.ready jquery wrapper and it picked up on it.

delayed job problem in rails.

My controller data_files_controller.rb

def upload_balances
  DataFile.load_balances(params)
end

My model data_file.rb def self.load_balances(params)

#  Pull the file out of the http request, write it to file system
name =  params['Filename']
directory = "public/uploads"
errors_table_name = "snapshot_errors"
upload_file = File.join(directory, name)
File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) }
# Remove the old data from the table
Balance.destroy_all
------ more code-----
end

It's working fine. Now i want to use delayed job with my controller to call my model action like .. My controller data_files_controller.rb

def upload_balances
  DataFile.send_later(:load_balances,params)      
end

Is it possible?? What's the other way to do it? Is it create any problem?

With this send_later i am getting this error in column last_error in delayed_job table.

uninitialized stream C:/cyncabc/app/models/data_file.rb:12:in read' C:/cyncabc/app/models/data_file.rb:12:inload_balances' C:/cyncabc/app/models/data_file.rb:12:in `open'

I am getting error on line

File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) }

while reading params['Filedata'].read.

how to check i am getting proper data in params['Filedata'] or not ? Without send_later it's working fine... Is there any solution?

From stackoverflow
  • using send_later should work fine. The other way is to define your own class that responds to perform, and call Delayed::Job.enqueue YourClass.new

    Did you have errors somewhere?

    krunal shah : I have edited my post with errors. is there any solution?
  • You should check what's in the database. Delayed Job must have strings, or ids internally when running it: most probably

    params['Filedata']

    contains something that is not revivable when the job runs later.

    krunal shah : If user upload any csv file than first load_balance function will create that file in public/upload and write content in it from the original file. Than with faster csv it will enter the records from the file to database. But it's not storing anything params['Filedata'] or params['Filename'] in the database.

How can i convert simple shape bitmap to vector ( geometry)

I would to know if it's possible to convert a simple bitmap to a geometry object

From stackoverflow
  • Yes, you can using tracing. Potrace is an open source bitmap-to-vector tracer library.

    However, bitmap tracing is imperfect; for high-quality vector image, line tracer is generally only used to do the initial tracing, which would later be hand-tweaked. Inkscape, an open source vector image editor, provides built-in support for tracing (internally using potrace).

    Bgnt44 : source bitmap will be simple shape and black and white, i just need all the conversion to be automatic : people load a bitmap and i store a geomtry object , the goal is to extrude these shape to a 3d cone
    Lie Ryan : simple black and white image can be easily traced using potrace (in fact, they're the ONLY thing that can be traced, color images need to be somehow converted to black-and-white before you can trace them).
    Bgnt44 : it seam that Inkscape can convert colored bitmap to vectors ... is there any way to doing that in command line
  • Here is some example of bitmap source,

    Can this be convert to only one geometry object ( i only need the white part, don't care bout black...

    alt text

    alt text

    Lie Ryan : Yes, you can do that with Potrace. Download Inkscape, and try playing with its "Path > Trace Bitmap" tool (hint: use "brightness cutoff" mode and check the "invert bitmap") to get the stars. You can do the same thing with Potrace (since Inkscape uses Potrace internally) to do it programmatically if you want to.
    Lie Ryan : Here's what I did in less than 3 minutes http://www.mediafire.com/file/mtnwielez0d/stars.svg
    Bgnt44 : i've try it (command line), very simple to convert bmp to svg, but i don't know which format use to get xaml data ...
    Lie Ryan : You will need an SVG to XAML converters. Though I've never personally used it, there are SVG to XAML converters.
  • Hi,

    I've found a way to do what i want ...

    I take each pixel of a bitmap and make a solidbrushcolored polygon with it ( but only if the pixel is not black to get better look);

    But because of performance issue i've choose to rezize it to 32 x 32 !

    To give a light effect i've use a emmitive material but the result is quite bad with colored bitmap

    But it looks a bit pixellized .. and i'm afraid of using so much polygon to just one bitmap ... any idea to get better result or more effective???

    alt text

Does pngfix only affect images in the markup vs in the css?

I have a sprite that I'm using for rounded corners. The left corner sits on top of a gradient background, but the right corner sits on a white background. I don't want to have to put the images on the page as I'd rather have them in a sprite and just move the placement through the background property.

Will something like pngfix not work if the png is not in the markup?

Edited to incorporate OP's clarifications (posted in an answer, below) into the question:

Sorry, meaning will something like pngfix apply to png's that are in a CSS file or only when it's in the markup:

<img src="myimage.png" class="png" />

etc...

From stackoverflow
  • Yes, by adding the following line all your to your CSS background-PNG rules:

    behavior: url(/pathto/iepngfix.htc);
    
  • Sorry, meaning will something like pngfix apply to png's that are in a CSS file or only when it's in the markup:

    <img src="myimage.png" class="png" />
    

    etc...

    David Thomas : Please add details into the original question, rather than creating an 'update' answer. Click on the 'edit' link below the question's tags to do so.
  • Yes, the pngfix.htc script will apply to both markup and css background images.

    However, the more recent DD Belated PNG fix is the better option as it addresses more things than the older pngfix (namely, positioned and repeating backgrounds):

    http://www.dillerdesign.com/experiment/DD_belatedPNG/

  • NOT GOING TO WORK

    The png hack will not work on any image that has a position property in css. So basically your out of luck with sprites, unless you use a gif.

    You can get pngfix to work on images in CSS and HTML. However, they can't be positioned.

    If you want to fix pngs on IE6 you should read this article too.

    http://24ways.org/2007/supersleight-transparent-png-in-ie6

    MIGHT GO OK

    Check out Andrew Vit's Suggestion.

SVN always getting errors when I commit (Subclipse)

I have setup svn on my server and Subclipse at home. I am the only developer and am mainly using it for the backup and versioning features.

Everytime I commit my changes I get eighter:

Out Of date errors

or

Tree conflicts

Sometimes I even delete files and they don't delete on svn, in a directory hierarchy only the very last item will delete so I have to delete each folder one at a time.

How do I avoid these errors in the future?

Update: Another problem I am having is that sometimes eclipse seems to sync with the server so that when I refactor a filename it goes off to the server and does something and makes me wait, which is annoying.

And for clarity, this is a typical operation: I might change a filename, move a file to a different folder then change the contents of a file. I select the 'Team menu' and click 'commit'. Then I get all these errors above.

From stackoverflow
  • Do you always svn update before modifying your files? It is mandatory.

    When deleting, you commit the deletion? Otherwise, you only delete in local

    jax : No, I don't update. I just select the commit button. Can you tell me exactly what I should be doing?
    Llistes Sugra : Before any change, you must Right click -> Team -> Update To HEAD Otherwise, you might be modifying an already modified file
    jax : But how can it be modified as I am the only person updating?
    jax : If I have to run Update To HEAD every time this will really affect my efficiency also. Is this with every file, even if I change the contents?
    jax : If I rename a folder, it instead creates a new folder with a blue arrow and put the files inside the new folder, however, all subfolders are still under the old folder name????

What explains the term orthogonal in a more non-nerd fashion?

For example:

Cardinality and optionality are orthogonal properties of a relationship. You can specify that a relationship is optional, even if you have specified upper and/or lower bounds. This means that there do not have to be any objects at the destination, but if there are then the number of objects must lie within the bounds specified.

What exactly does "orthogonal" mean? I bet it's just a fancy soundig nerd-style word for something that could be expressed a lot easier to understand for average people ;)

From wikipedia:

In mathematics, two vectors are orthogonal if they are perpendicular, i.e., they form a right angle. The word comes from the Greek ὀρθός (orthos), meaning "straight", and γωνία (gonia), meaning "angle".

Anyone?

From stackoverflow
  • In the quoted context above you could substitute the word "independent" or "unrelated" for "orthogonal".

    dontWatchMyProfile : unrelated / independent. Perfect!! Why not in the first place, the simple way...thought Apple is going for massive simplification of all things ;) ...remembers me about a age old star trek movie where someone farted and the doctor told him something in latin with 20 words. after a long discussion it turned out that what the doctor wanted to say was simply that the patient experienced flatulence (a kind of force that makes you fart, all the time).
    Paul R : It's just human nature - when people learn a new word they look for opportunities to use it. In this particular case it's not really appropriate, since simpler words will suffice.
  • Items/concepts/values etc.. that are Orthogonal means that one does not constrain the other, so you can establish one item/concept/value without regards for how other orthogonal items are set.

    Loosely speaking, orthogonal means independent.

  • Specifically in 2d space an orthogonal line is one with bends at 90 degrees to each other.

Web Service SOAP Message Routing

I have a case where i need to route a Web Service SOAP message through an intermediary server. Can anyone point me in the direction of some good resources on how to accomplish this?

From stackoverflow
  • Are you looking to set up a WSE router? If so here is a tutorial.

    John Saunders : WSE is obsolete and should not be used unless there is no other choice.
  • WSE is obsolete and should not be used unless there is no other choice.

    Canoehead : Maybe you could expand on your answer.
    John Saunders : @Canoehead: What more is there to say?
    Canoehead : @John Saunders: anon is looking for good resources and you've essentially answered with what would be a bad resource but no good ones. Maybe you should have put your answer as a comment to Andrew Hare's answer instead.
    John Saunders : @Canoehead: good point. Done.

jQuery balancing exclusive and inclusive form options?

Has anyone found a good method to balance option lists, such that both can modify the other? I have a list of trims, and model_numbers, and either one of these can result a one to one match.. If however, there is no one to one match, I'd like trim to narrow down model_numbers and vise-versa. I don't ever want incompatable options...

I can roll my own solution but is there anything like a jQuery framework that allows me to better customize this stuff?

From stackoverflow
  • I dont know of any jquery framework to handle dynamically cascading select lists but From what it sounds like you have it repopulating the lists via ajax on change. With that your probably about 80% of the way there to your own solution.

How can I get DocId when adding a document in Lucene index?

I am indexing a row of data from database in Lucene.Net. A row is equivalent of Document.

I want to update my database with the DocId, so that I can use the DocId in the results to be able to retrieve rows quickly.

I currently first retrive the PK from the result docs which I think should be slower than retriving directly from the database using DocId.

How can I find the DocId when adding a document to Lucene?

From stackoverflow
  • Relying on Lucene's DocId is a bad policy, as even Lucene tries to avoid this. I suggest you create your own DocId. In a database I would use an auto-increment field. If your application does not use a relational database, you can create this type of field programmatically. Other than that, I suggest you read Search Engine versus DBMS - I believe that only fields that may be searched should be stored in Lucene; The rest of the row belongs in a database, so the sequence of events is:

    1. Using Lucene, search for some text and get a DocId.
    2. Use the DocId to retrieve the full row from the database.
  • As Yuval stated, leaking internal Lucene implementation details is bad, especially since Lucene doc id's change when the index is mutated.

    If looking up the primary key using doc.get("pk") is too slow for you, use a FieldCache to cache all the pk's in memory. Then the lookups will be plenty fast.

    Rohit : Any sample code snippet to use FieldCache?
    Lyle : I agree that relying on doc id is almost always poor design. However, I have a particular use case in which I have a read-only index and need to do some processing outside of what's possible with a search query so I need to store the doc id of certain documents for later reference. Can you please elaborate on using FieldCache to do so?