Daily Archives

Articles indexed Thursday April 22 2010

Page 12/123 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Check if an object is defined in html

    - by Manikanta
    In HTML, I have an object tag as follows: <OBJECT ID="objectid" CLASSID="some-class-id" CODEBASE="some-codebase"> I have written a function in JavaScript to access this object. I checked the null value as follows: if(objectid==null){-----} i want to check if the object is undefined or is empty. Do we have any functions to check so?

    Read the article

  • Is it bad use "display: table;" to organise a layout into 2 columns?

    - by Colen
    Hello, I am trying to make a 2 column layout, apparently the bane of CSS. I know you shouldn't use tables for layout, but I've settled on this CSS. Note the use of display: table etc. div.container { width: 600px; height: 300px; margin: auto; display: table; table-layout: fixed; } ul { white-space: nowrap; overflow: hidden; display: table-cell; width: 40%; } div.inner { display: table-cell; width: auto; } With this layout: <div class="container"> <ul> <li>First</li> <li>Second</li> <li>Third</li> </ul> <div class="inner"> <p>Hello world</p> </div> </div> This seems to work admirably. However, I can't help wondering - am I obeying the letter of the "don't use tables" rule, but not the spirit? I think it's ok, since there's no positioning markup in the HTML code, but I'm just not sure about the "right" way to do it. I can't use css float, because I want the columns to expand and contract with the available space. Please, stack overflow, help me resolve my existential sense of dread at these pseudo-tables.

    Read the article

  • Django: Serving Media Behind Custom URL

    - by TheLizardKing
    So I of course know that serving static files through Django will send you straight to hell but I am confused on how to use a custom url to mask the true location of the file using Django. http://stackoverflow.com/questions/2681338/django-serving-a-download-in-a-generic-view but the answer I accepted seems to be the "wrong" way of doing things. urls.py: url(r'^song/(?P<song_id>\d+)/download/$', song_download, name='song_download'), views.py: def song_download(request, song_id): song = Song.objects.get(id=song_id) fsock = open(os.path.join(song.path, song.filename)) response = HttpResponse(fsock, mimetype='audio/mpeg') response['Content-Disposition'] = "attachment; filename=%s - %s.mp3" % (song.artist, song.title) return response This solution works perfectly but not perfectly enough it turns out. How can I avoid having a direct link to the mp3 while still serving through nginx/apache? EDIT 1 - ADDITIONAL INFO Currently I can get my files by using an address such as: http://www.example.com/music/song/1692/download/ But the above mentioned method is the devil's work. How can I accomplished what I get above while still making nginx/apache serve the media? Is this something that should be done at the webserver level? Some crazy mod_rewrite? http://static.example.com/music/Aphex%20Twin%20-%20Richard%20D.%20James%20(V0)/10%20Logon-Rock%20Witch.mp3

    Read the article

  • jQuery: tabs where the tab/content can be linked to

    - by Ricardo Zea
    My issue is simple. I have already implemented a tab system, and I'd probably spend more time implementing another one with the solution I need, than giving a shot at adapting the code I have, and learn something while asking :) My problem is that the tabs can't be linked to, I need to be able to link to a tab from another website or page, and have that tab get selected upon page load. ie: I have three tabs showing different products, by default tab 1 is active/selected when the page loads. From the home page I want to link to tab 2 but I can't link to tab 2 because it doesn't get selected. Not sure if that makes sense. Tabs: <ul> <li><a href="products.php">Product 1</a></li> <li><a href="products.php">Product 2</a></li> <li><a href="products.php">Product 3</a></li> </ul> <div class="tab_container"> <div id="tab1" class="tab_content">Product 1 info...</div> <div id="tab2" class="tab_content">Product 2 info...</div> <div id="tab3" class="tab_content">Product 3 info...</div> </div> my jQuery: $(document).ready(function() { //Default Action $(".tab_content").hide(); $("ul.tabs li:first").addClass("active").show(); $(".tab_content:first").show(); //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); $(this).addClass("active"); $(".tab_content").hide(); var activeTab = $(this).find("a").attr("href"); $(activeTab).fadeIn(); return false; }); }); Is there a way this code can be adapted to be able to link to any tab from anywhere and have that tab get selected when the page loads? Thanks in advance.

    Read the article

  • File Upload multiple files in asp.net (similar to gmail)

    - by superstar
    Hi Guys, I need suggestions with regards to the multiple file upload using File Upload control in asp.net(along with C#). I have a File Upload Control, so i click the 'Browse' button and when i select a file from the select file dialog, i want the file to be shown as a link below the File Upload Control( somewhat similar to gmail). This file should be seen such a way that it can be deleted, if i wanted to. And also i should be able to upload another file from the File Upload control. All these files should be uploaded to a location when i use a button click event in the end. I think i have made myself clear. Any Suggestions are really helpful. Thanks.

    Read the article

  • Find the element with the most "neighbors" in a sequence

    - by Bao An
    Assume that we have a sequence S with n elements <x1,x2,...,xn>. A pair of elements xi,xj are considered neighbors if |xi-xj|<d, with d a given distance between two neighbors. So how can find out the element that has most neighbors in the sequence? (A simply way is sorting the sequence and then calculating number of each element but it's time complexity is quite large): O(nlogn) May you please help me find a better way to reduce time complexity?

    Read the article

  • Find numbers that equals a sum in an array

    - by valli-R
    I want to find the first set of integers in an array X that the sum equals a given number N. For example: X = {5, 13, 24, 9, 3, 3} N = 28 Solution = {13, 9, 3, 3} Here what I have so far : WARNING, I know it uses global and it is bad,that's not the point of the question. <?php function s($index = 0, $total = 0, $solution = '') { global $numbers; global $sum; echo $index; if($total == 28) { echo '<br/>'.$solution.' = '.$sum.'<br/>'; } elseif($index < count($numbers) && $total != 28) { s($index + 1, $total, $solution); s($index + 1, $total + $numbers[$index], $solution.' '.$numbers[$index]); } } $numbers = array(5, 13, 24, 9, 3, 3); $sum = 28; s(); ?> I don't get how I can stop the process when it finds the solution.. I know I am not far from good solution.. Thanks in advance

    Read the article

  • Loading a PyML multiclass classifier... why isn't this working?

    - by Michael Aaron Safyan
    This is a followup from "Save PyML.classifiers.multi.OneAgainstRest(SVM()) object?". I am using PyML for a computer vision project (pyimgattr), and have been having trouble storing/loading a multiclass classifier. When attempting to load one of the SVMs in a composite classifier, with loadSVM, I am getting: ValueError: invalid literal for float(): rest Note that this does not happen with the first classifier that I load, only with the second. What is causing this error, and what can I do to get around this so that I can properly load the classifier? Details To better understand the trouble I'm running into, you may want to look at pyimgattr.py (currently revision 11). I am invoking the program with "./pyimgattr.py train" which trains the classifier (invokes train on line 571, which trains the classifier with trainmulticlassclassifier on line 490 and saves it with storemulticlassclassifier on line 529), and then invoking the program with "./pyimgattr.py test" which loads the classifier in order to test it with the testing dataset (invokes test on line 628, which invokes loadmulticlassclassifier on line 549). The multiclass classifier consists of several one-against-rest SVMs which are saved individually. The loadmulticlassclassifier function loads these individually by calling loadSVM() on several different files. It is in this call to loadSVM (done indirectly in loadclassifier on line 517) that I get an error. The first of the one-against-rest classifiers loads successfully, but the second one does not. A transcript is as follows: $ ./pyimgattr.py test [INFO] pyimgattr -- Loading attributes from "classifiers/attributes.lst"... [INFO] pyimgattr -- Loading classnames from "classifiers/classnames.lst"... [INFO] pyimgattr -- Loading dataset "attribute_data/apascal_test.txt"... [INFO] pyimgattr -- Loaded dataset "attribute_data/apascal_test.txt". [INFO] pyimgattr -- Loading multiclass classifier from "classifiers/classnames_from_attributes"... [INFO] pyimgattr -- Constructing object into which to store loaded data... [INFO] pyimgattr -- Loading manifest data... [INFO] pyimgattr -- Loading classifier from "classifiers/classnames_from_attributes/aeroplane.svm".... scanned 100 patterns scanned 200 patterns read 100 patterns read 200 patterns {'50': 38, '60': 45, '61': 46, '62': 47, '49': 37, '52': 39, '53': 40, '24': 16, '25': 17, '26': 18, '27': 19, '20': 12, '21': 13, '22': 14, '23': 15, '46': 34, '47': 35, '28': 20, '29': 21, '40': 32, '41': 33, '1': 1, '0': 0, '3': 3, '2': 2, '5': 5, '4': 4, '7': 7, '6': 6, '8': 8, '58': 44, '39': 31, '38': 30, '15': 9, '48': 36, '16': 10, '19': 11, '32': 24, '31': 23, '30': 22, '37': 29, '36': 28, '35': 27, '34': 26, '33': 25, '55': 42, '54': 41, '57': 43} read 250 patterns in LinearSparseSVModel done LinearSparseSVModel constructed model [INFO] pyimgattr -- Loaded classifier from "classifiers/classnames_from_attributes/aeroplane.svm". [INFO] pyimgattr -- Loading classifier from "classifiers/classnames_from_attributes/bicycle.svm".... label at None delimiter , Traceback (most recent call last): File "./pyimgattr.py", line 797, in sys.exit(main(sys.argv)); File "./pyimgattr.py", line 782, in main return test(attributes_file,classnames_file,testing_annotations_file,testing_dataset_path,classifiers_path,logger); File "./pyimgattr.py", line 635, in test multiclass_classnames_from_attributes_classifier = loadmulticlassclassifier(classnames_from_attributes_folder,logger); File "./pyimgattr.py", line 529, in loadmulticlassclassifier classifiers.append(loadclassifier(os.path.join(filename,label+".svm"),logger)); File "./pyimgattr.py", line 502, in loadclassifier result=loadSVM(filename,datasetClass = SparseDataSet); File "/Library/Python/2.6/site-packages/PyML/classifiers/svm.py", line 328, in loadSVM data = datasetClass(fileName, **args) File "/Library/Python/2.6/site-packages/PyML/containers/vectorDatasets.py", line 224, in __init__ BaseVectorDataSet.__init__(self, arg, **args) File "/Library/Python/2.6/site-packages/PyML/containers/baseDatasets.py", line 214, in __init__ self.constructFromFile(arg, **args) File "/Library/Python/2.6/site-packages/PyML/containers/baseDatasets.py", line 243, in constructFromFile for x in parser : File "/Library/Python/2.6/site-packages/PyML/containers/parsers.py", line 426, in next x = [float(token) for token in tokens[self._first:self._last]] ValueError: invalid literal for float(): rest

    Read the article

  • NFS using FREENAS for ESXi

    - by maruti
    trying to create NFS share for ESXi4. Using FREENAS 0.71. once setup NFS mount point is setup could this be shared to Windows clients using CIFS/SMB service? I mean sharing the backup vms on NFS datastore to Windows clients using CIFS/SMB service?

    Read the article

  • IE8 claims my page has an error, firefox doesn't, and I can't find any error. Help!

    - by Bears will eat you
    This is something of a follow-up question to my question here. You can find the HTML source in a text file here. When I load that page in IE8, I get the "Done, but with errors on page." message in my status bar. The detail view shows Expected identifier sms Line: 147 Code: 0 Char: 67 and I see absolutely no problems anywhere near there. In IE8, the page is still behaving erratically w/r/t the randomly losing focus as mentioned in my other question. When I load the same exact page in Firefox (using Firebug) the console shows no errors and the page works perfectly. Any thoughts on what's going on here? This is driving me nuts and making me want to give up on even trying to write an IE friendly page. Edit: Thanks for all the comments! This page is written as a JSP, so I edit in Eclipse. I found an Eclipse warning about the onblur event for the username field. I switched it from onblur="alert(document.activeElement + ' class:' + document.activeElement.class)" to onblur="alert(document.activeElement)" and that made the bizarre IE page error vanish. I had been trying to give more info (namely, its CSS class) about specifically which element is stealing focus - to my own detriment, apparently, since Javascript was interpreting the '.class' part in the Java(script) sense. And, no, the page doesn't validate. But the errors were mostly/all ones that just didn't make sense, such as Line 14, Column 41: Attribute "LANGUAGE" is not a valid attribute. Did you mean "language"? to which I say, WTF?! But I'm still stuck trying to figure out why, as I enter text in the username & password fields, focus randomly switches to a div (working on figuring out which div currently). Edit 2: It's the div between the two "global nav" comments, at the very top of the body. Still no idea why it's happening, though.

    Read the article

  • ScriptingBridge causes iTunes to relaunch after quit

    - by Justin Voss
    I'm working on a Cocoa app that monitors what you're listening to in iTunes, and since I'm targeting Mac OS 10.5 and higher, I've decided to use Scripting Bridge. If I try to close iTunes too close to the time that my app polls it for the current track, iTunes will immediately relaunch! The only way to reliably prevent this behavior is to quit my app first, then quit iTunes. Switching to EyeTunes solves the problem, but it's a fairly old codebase and I was hoping that I could accomplish this without an external library. Surely I'm doing something wrong that's causing the relaunch? Here's some sample code; this snippet is run every few seconds, triggered by an NSTimer. #import "iTunesBridge.h" // auto-generated according to Apple's docs -(void)updateTrackInfo { iTunesApplication *iTunes = [[SBApplication alloc] initWithBundleIdentifier:@"com.apple.iTunes"]; iTunesTrack *currentTrack = [iTunes currentTrack]; // inspect currentTrack to determine what's being played... [iTunes release]; } Is this a known issue with Scripting Bridge, or am I using it incorrectly?

    Read the article

  • WPF: Convert string to system.windows.style

    - by xscape
    Is it possible to convert string to system.windows.style? How? Example: <Style TargetType="ToggleButton" x:Key="toggleCollapsed"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <Border Background="#00FFFFFF" Width="19" Height="13" > <Border BorderThickness="1,1,1,1" CornerRadius="1,1,1,1" BorderBrush="#FF8E997D" Width="9" Height="9" > <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FFFFFFFF" Offset="0.4" /> <GradientStop Color="#FFC3BAAA" Offset="1" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> <Path Data="M0,2L0,3 2,3 2,5 3,5 3,3 5,3 5,2 3,2 3,0 2,0 2,2z" x:Name="pathToggle" Fill="#FF000000" Margin="1,1,1,1"/> </Border> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> The style above is stored in my .resx. I want to convert it back to style

    Read the article

  • Andriod Tutorials or book recommendations?

    - by chobo2
    Hi I want to an andriod application(a port from a windows mobile phone) but I need to learn a couple things How to program for different screen sizes and resolutions (so my controls get bigger smaller or whatever) How to dynamically create controls such labels and checkboxes ( and checkbox listeners) How to create a menu How to create a context menu( a menu when you right click on the screen it pops up) how to program for landscape and portrait mode How to consume a webservice Most of what I am after is mostly the display aspect as all my logic is on a webservice so I could port all my stuff to different phones faster. So I am looking for tutorials or a book to get me up to speed to do these things

    Read the article

  • Google app engine error when I login.

    - by zjm1126
    i am using http://code.google.com/p/gaema/source/browse/#hg/demos/webapp, and this is my traceback: Traceback (most recent call last): File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 510, in __call__ handler.get(*groups) File "D:\gaema\demos\webapp\main.py", line 31, in get google_auth.get_authenticated_user(self._on_auth) File "D:\gaema\demos\webapp\gaema\auth.py", line 641, in get_authenticated_user OpenIdMixin.get_authenticated_user(self, callback) File "D:\gaema\demos\webapp\gaema\auth.py", line 83, in get_authenticated_user url = self._OPENID_ENDPOINT + "?" + urllib.urlencode(args) File "D:\Python25\lib\urllib.py", line 1250, in urlencode v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) how to do this thanks updated i change the code from args = dict((k, v[-1]) for k, v in self.request.arguments.iteritems()) args["openid.mode"] = u"check_authentication" url = self._OPENID_ENDPOINT + "?" + urllib.urlencode(args) to args = dict((k, v[-1].encode('utf-8')) for k, v in self.request.arguments.iteritems()) args["openid.mode"] = u"check_authentication" url = self._OPENID_ENDPOINT + "?" + urllib.urlencode(args) but also error.

    Read the article

  • Are products like MSSQL Server and Oracle are "ORDBMS"?

    - by n10i
    According to wikipedia! http://en.wikipedia.org/wiki/ORDBMS IBM's DB2, Oracle database, and Microsoft SQL Server, make claims to support this technology and do so with varying degrees of success So, are these products true "ORDBMS" like PostgreSQL? or they are they are long way from it? can someone plz! point me to any link where i can read about the features still to be implemented by these RDBMS to become true ORDBMS!

    Read the article

  • Amazing families of algorithms over implicit graphs

    - by Diego de Estrada
    Dynamic programming is, almost by definition, to find a shortest/longest path on an implicit dag. Every DP algorithm just does this. An Holographic algorithm can be loosely described as something that counts perfect matchings in implicit planar graphs. So, my question is: are there any other families of algorithms that use well-known algorithms over implicit graphs to achieve a considerable speedup?

    Read the article

  • How do I get confidence intervals without inverting a singular Hessian matrix?

    - by AmalieNot
    Hello. I recently posted this to reddit and it was suggested I come here, so here I am. I'm a student working on an epidemiology model in R, using maximum likelihood methods. I created my negative log likelihood function. It's sort of gross looking, but here it is: NLLdiff = function(v1, CV1, v2, CV2, st1 = (czI01 - czV01), st2 = (czI02 - czV02), st01 = czI01, st02 = czI02, tt1 = czT01, tt2 = czT02) { prob1 = (1 + v1 * CV1 * tt1)^(-1/CV1) prob2 = ( 1 + v2 * CV2 * tt2)^(-1/CV2) -(sum(dbinom(st1, st01, prob1, log = T)) + sum(dbinom(st2, st02, prob2, log = T))) } The reason the first line looks so awful is because most of the data it takes is inputted there. czI01, for example, is already declared. I did this simply so that my later calls to the function don't all have to have awful vectors in them. I then optimized for CV1, CV2, v1 and v2 using mle2 (library bbmle). That's also a bit gross looking, and looks like: ml.cz.diff = mle2 (NLLdiff, start=list(v1 = vguess, CV1 = cguess, v2 = vguess, CV2 = cguess), method="L-BFGS-B", lower = 0.0001) Now, everything works fine up until here. ml.cz.diff gives me values that I can turn into a plot that reasonably fits my data. I also have several different models, and can get AICc values to compare them. However, when I try to get confidence intervals around v1, CV1, v2 and CV2 I have problems. Basically, I get a negative bound on CV1, which is impossible as it actually represents a square number in the biological model as well as some warnings. The warnings are this: http://i.imgur.com/B3H2l.png . Is there a better way to get confidence intervals? Or, really, a way to get confidence intervals that make sense here? What I see happening is that, by coincidence, my hessian matrix is singular for some values in the optimization space. But, since I'm optimizing over 4 variables and don't have overly extensive programming knowledge, I can't come up with a good method of optimization that doesn't rely on the hessian. I have googled the problem - it suggested that my model's bad, but I'm reconstructing some work done before which suggests that my model's really not awful (the plots I make using the ml.cz.diff look like the plots of the original work). I have also read the relevant parts of the manual as well as Bolker's book Ecological Models in R. I have also tried different optimization methods, which resulted in a longer run time but the same errors. The "SANN" method didn't finish running within an hour, so I didn't wait around to see the result. tl;dr : my confidence intervals are bad, is there a relatively straightforward way to fix them in R. My vectors are: czT01 = c(5, 5, 5, 5, 5, 5, 5, 25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 50, 50, 50, 50) czT02 = c(5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 25, 25, 25, 25, 25, 50, 50, 50, 50, 50, 75, 75, 75, 75, 75) czI01 = c(25, 24, 22, 22, 26, 23, 25, 25, 25, 23, 25, 18, 21, 24, 22, 23, 25, 23, 25, 25, 25) czI02 = c(13, 16, 5, 18, 16, 13, 17, 22, 13, 15, 15, 22, 12, 12, 13, 13, 11, 19, 21, 13, 21, 18, 16, 15, 11) czV01 = c(1, 4, 5, 5, 2, 3, 4, 11, 8, 1, 11, 12, 10, 16, 5, 15, 18, 12, 23, 13, 22) czV02 = c(0, 3, 1, 5, 1, 6, 3, 4, 7, 12, 2, 8, 8, 5, 3, 6, 4, 6, 11, 5, 11, 1, 13, 9, 7) and I get my guesses by: v = -log((c(czI01, czI02) - c(czV01, czV02))/c(czI01, czI02))/c(czT01, czT02) vguess = mean(v) cguess = var(v)/vguess^2 It's also possible that I'm doing something else completely wrong, but my results seem reasonable so I haven't caught it.

    Read the article

  • Why would some $_POST variables go missing for a form with PHP?

    - by Chad Johnson
    Sometimes, multiple times a day in fact, users of my web application are submitting a certain form which has about a dozen form fields, half of which are hidden fields, and half of the $_POST data is simply not present in the processing script. Note that the fields that are not present are at the very bottom of the form. I know this because this raises a fatal error, and an email is dispatched to me which includes the post data. And of course, neither I nor any of the developers on my team can reproduce the problem. Flash is involved in the process, as I'm using a library called Uploadify to display a progress meter. Here is the flow...does anyone have ANY ideas at all why some of the post data would be getting wiped out? User visits edit screen for a page in the CMS I am using. Record id for the page is put into a form as a hidden value. User clicks the Uploadify browse button and selects a file (only single file selection is allowed). User clicks Submit button for my form. jQuery intercepts the form submit action, triggers Uploadify to start uploading, and returns false for the submit action (manually cancelling the form submit event so that Uploadify can take over). Uploadify uploads to a custom process script. Uploadify finishes uploading and triggers the Javascript completion callback. The Javascript callback calls $('#myForm').submit() to submit the form. This happens on multiple browsers (Firefox 3.5, 3.6, Safari, Internet Explorer 7, 8) and multiple platforms (Mac OS 10.5, 10.6 and Windows XP, 7).

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >