Wednesday, April 6, 2011

Limitation for google sitemap.xml file size

can any one please let me know the memory limitation(MB) of google sitemap.xml file size.

From stackoverflow
  • According to a claim in the Wikipedia article, the limit is 50,000 URLs and 10 MB (uncompressed) per sitemap. I think this number is from the Google Webmaster FAQ (can't find the official entry but this Google groups entry says the same.)

    Not sure whether this limit applies to the other search engine providers as well.

    Pekka : @methode the forum post I link to says that 10MB is the maximum size *after* gunzipping. Do you have a link to back up your claim? If you do, please do add it. Both the forum post and the Wikipedia entry are not necessarily 100% reliable info IMO.
    methode : i should really shut up before drinking the first coffee in the morning... yeah, you're absolutely right. I removed my comment. Then the only addition is to confirm that all major search engines follow these requirements since it's set in the Sitemaps protocol (http://sitemaps.org/protocol.php#index), and all of them rely on this protocol. (this was also tested but no link for that) Sorry for the previous, misleading comment.
    Pekka : @methode great info and link - that was the official confirmation I was looking for. Cheers!

Get the current URL within a django template

Hay, i was wondering how to get the current URL within a template.

Say my URL was

/user/profile/

How do i return this to the template?

Thanks

From stackoverflow
  • request.get_full_path

    dotty : Can i get it without passing the 'request' variable to the template?
    Brant : I believe request is always passed to the template... if not, render_to_response('template.html',{},context_instance=RequestContext(request)) .. at that point, request is definitely passed in.
    dotty : Bascially i'm making a 'logout' function which redirects back to the page they were on when a 'logout' button is clicked. I was going to append the current URL to the query string.
    Brant : Just use request.path then
    dotty : I decided to use request.META['HTTP_REFERER'] to redirect them.
    Jack M. : Be warned that HTTP_REFERRER isn't always reliable. Many of the "Internet Security Suites" will remove that variable. It is probably worth it to ensure that your site still works even when there isn't a referrer, using something like `request.META.get('HTTP_REFERRER', '/')` or similar.

Strange altered behaviour when linking from .so file with ctypes in python

I am writing a program to handle data from a high speed camera for my Ph.D. project. This camera comes with a SDK in the form a .so file on Linux, for communicating with the camera and getting images out. As said it is a high speed camera delivering lots of data, (several GB a minute). To handle this amount of data the SDK has a very handy spool function that spools data directly to the hard drive via DMA, in the form of a FITS file, a raw binary format with a header that is used in astronomy. This function works fine when I write a small C program, link the .so file in and call the spool function this way. But when I wrap the .so file with ctypes and call the functions from python, all the functions are working except the spool function. When I call the spool function it returns no errors, but the spooled data file are garbled up, the file has the right format but half of all the frames are 0's. In my world it does not make sense that a function in a .so file should behave different depending on which program its called from, my own little C program or python which after all is only a bigger C program. Does any body have any clue as to what is different when calling the .so from different programs?

I would be very thankful for any suggestions

Even though the camera is commercial, some the driver is GPLed and available, though a bit complicated. (unfortunately not the spool function it seems) I have an object in python for Handel the camera.

The begining of the class reads:

class Andor:
  def __init__(self,handle=100):
    #cdll.LoadLibrary("/usr/local/lib/libandor.so")
    self.dll = CDLL("/usr/local/lib/libandor.so")
error = self.dll.SetCurrentCamera(c_long(handle))
    error = self.dll.Initialize("/usr/local/etc/andor/")

    cw = c_int()
    ch = c_int()
    self.dll.GetDetector(byref(cw), byref(ch))

The relevant function reads:

def SetSpool(self, active, method, path, framebuffersize):
    error = self.dll.SetSpool(active, method, c_char_p(path), framebuffersize)
    self.verbose(ERROR_CODE[error], sys._getframe().f_code.co_name)
    return ERROR_CODE[error]

And in the corresponding header it reads:

unsigned int SetSingleTrackHBin(int bin);

unsigned int SetSpool(int active, int method, char * path, int framebuffersize);

unsigned int SetStorageMode(at_32 mode);

unsigned int SetTemperature(int temperature);

The code to get the camera running would read something like:

cam = andor.Andor()
cam.SetReadMode(4)
cam.SetFrameTransferMode(1)
cam.SetShutter(0,1,0,0)
cam.SetSpool(1,5,'/tmp/test.fits',10);
cam.GetStatus()
if cam.status == 'DRV_IDLE':
acquireEvent.clear()
cam.SetAcquisitionMode(3)
cam.SetExposureTime(0.0)
cam.SetNumberKinetics(exposureNumber)
cam.StartAcquisition()
From stackoverflow
  • My guess is that it isn't the call to the spooling function itself, but a call series which results in corrupted values being fed to/from the library.

    Are you on a 64-bit platform? Not specifying restype for anything which returns a 64-bit integer (long with gcc) or pointer will result in those values being silently truncated to 32 bits. Additionally, ctypes.c_voidp handling is a little surprising — restype values of ctypes.c_voidp aren't truncated, but are returned in the Python interpreter as type int, with predictably hilarious results if high pointers are fed back as parameters to other functions without a cast.

    I haven't tested it, but both these conditions might also affect 32-bit platforms for values larger than sys.maxint.

    The only way to be 100% certain you're passing and receiving the values you expect is to specify the argtypes and restype for all the functions you call. And that includes creating Structure classes and associated POINTERs for all structs those functions operate on, even opaque structs.

How to handle XML string %Like% search in C#

Hi, As I know I can search DB with Sql syntax %like%.

Now I am working with XML, how can I handle the same search condition for XML file in C#?

I want to search the string and find it with part of the Keyword. Not the full text of keyword.

   <bookstore>
     <book genre="autobiography">
       <title>The Autobiography of Benjamin Franklin</title>
       <author>
         <first-name>Benjamin</first-name>
         <last-name>Franklin</last-name>
       </author>
       <price>8.99</price>
     </book>
     <book genre="philosophy">
       <title>The Gorgias</title>
       <author>
         <name>Plato</name>
       </author>
       <price>9.99</price>
     </book>
   </bookstore>

Assume I am working with the sample XML above. How can I code in C# to search "%jami%", then return "Benjamin". Thank you.

From stackoverflow
  • Traverse the XML file and do a String.Contains(...).

    Nano HE : @PieterG,Thank you . I found a sample code about String.Containers(). It works quite well as I need.
    allonym : That'll work, but Garett's suggestion of XPath or Linq To XML is the more elegant approach.
  • There are a couple of ways this can be done, depending on the version of .NET you are working with. You can use XPath, or my preference Linq To XML.

    Here are a few useful links:

Why subtract a value from itself (x - x) in Python?

In NumPy functions, there are often initial lines that do checking of variable types, forcing them to be certain types, etc. Can someone explain the point of these lines in scipy.signal.square? What does subtracting a value from itself do?

t,w = asarray(t), asarray(duty)
w = asarray(w + (t-t))
t = asarray(t + (w-w))

source

From stackoverflow
  • I believe that this will make the final w and t have the same type. For example, if you start with float and int, you will end up with both being float arrays which is better for subsequent operations.

    Dingle : A good observation. I have used the same trick, too.
    iondiode : yes, and it will have the same dimension as well ( in case they started out with different)
    endolith : That's kind of weird considering t is an array and w is a scalar

Is it possible to access a BDB from pure Java?

Hi

I'm trying to access "cert8.db" mozilla file which is a BDB database. I know that there are bindings for languages, Java among them, but I'm trying to build a multiplatform app so I think that using JNI such as this one would be a problem.

Thanks in advance.

From stackoverflow
  • You don't need full BDB package to read that file. Check out this class,

    http://sam.nipl.net/code/mindterm/com/mindbright/bdb/DBHash.java

    ktulur : Interesting, much thanks. Reading.... What about writing?
    ZZ Coder : No. Read-only. If you are going to write, you should just convert it to the format used by Sleepycat Java library.

Evaluate or Show HTML using Javascript

Hello, I have this...portion of code in Javascript:

var description = document.createElement('P');

description.className='rssBoxDescription';

description.innerHTML = itemTokens[2];

div.appendChild(description);

I see that description gets the HTML value and displays as plain HTML coding not as HTML processing it shouldbe ... how to convert this HTML value in description to be appended to div element shown as HTML...which is not showing.

Also it has value something like:

<table><tr><td style="padding: 0 5px"><ahref="xttp://picasaweb.google.com/linktoimagepage"><imgtag style="border:1px solid #5C7FB9" s_rc="xttp://lh3.ggpht.com/imagepath" alt="image.jpg"/></a></td><td valign="top"><font color="#6B6B6B">Date: </font><font color="#333333">Jun 28, 2007 9:00 AM</font><br/><font color=\"#6B6B6B\">Number of Comments on Photo:</font><font color=\"#333333\">0</font><br/><p><ahref="xttp://picasaweb.google.com/linktoimage"><font color="#3964C2">View Photo</font></a></p></td></tr></table>

Pls help Anita

@SARFARAZ ... YES...I am using the script on dhtmlgoodies.com/scripts/rss-scroller/js/ajax.js

It worked as :: description.replace(/&lt;/g,"<"); and description.replace(/&gt;/g,">");

From stackoverflow
  • It could be that the > and the < have been encoded like &gt; and &lt;

    Try replacing &gt; with > and &lt; with < in itemTokens before assigning it as the DIV innerHTML and see if it works

  • It seems to be working for me. Try posting entire code including the div that is created dynamically.