Daily Archives

Articles indexed Sunday March 14 2010

Page 1/89 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • do-while loop in Python?

    - by Eye of Hell
    I need to emulate a do-while loop in a python. But, unfortunately, following straightforward code does not work: l = [ 1, 2, 3 ] i = l.__iter__() s = None while True : if s : print s try : s = i.next() except StopIteration : break print "done" Instead of "1,2,3,done" I have the following output: [stdout:]1 [stdout:]2 [stdout:]3 None['Traceback (most recent call last): ', ' File "test_python.py", line 8, in <module> s = i.next() ', 'StopIteration '] What can I do in order to catch 'stop iteration' excepton and break a while loop properly? Example why such thing may be needed. State machine: s = "" while True : if state is STATE_CODE : if "//" in s : tokens.add( TOKEN_COMMENT, s.split( "//" )[1] ) state = STATE_COMMENT else : tokens.add( TOKEN_CODE, s ) if state is STATE_COMMENT : if "//" in s : tokens.append( TOKEN_COMMENT, s.split( "//" )[1] ) else state = STATE_CODE # re-evaluate same line continue try : s = i.next() except StopIteration : break

    Read the article

  • function to get the file name of an URL

    - by user262325
    Hello everyone I have some source code to get the file name of an url for example: http://www.google.com/a.pdf I hope to get a.pdf because the way to join 2 NSStrings I can get is 'appendString' which only for adding a string at right side, so I planned to check each char one by one from the right side of string 'http://www.google.com/a.pdf', when it reach at the char '/', stop the checking, return string fdp.a , after that I change fdp.a to a.pdf source codes are below -(NSMutableString *) getSubStringAfterH : originalString:(NSString *)s0 { NSInteger i,l; l=[s0 length]; NSMutableString *h=[[NSMutableString alloc] init]; NSMutableString *ttt=[[NSMutableString alloc] init ]; for(i=l-1;i>=0;i--) //check each char one by one from the right side of string 'http://www.google.com/a.pdf', when it reach at the char '/', stop { ttt=[s0 substringWithRange:NSMakeRange(i, 1)]; if([ttt isEqualToString:@"/"]) { break; } else { [h appendString:ttt]; } } [ttt release]; //below are to change the sequence of char in h // txt.edcba -> abcde.txt NSMutableString *h1=[[[NSMutableString alloc] initWithFormat:@""] autorelease]; for (i=[h length]-1;i>=0;i--) { NSMutableString *t1=[[NSMutableString alloc] init ]; t1=[h substringWithRange:NSMakeRange(i, 1)]; [h1 appendString:t1]; [t1 release]; } [h release]; return h1; } h1 can reuturn the coorect string a.pdf, but if it returns to the codes where it was called, after a while system reports 'double free * set a breakpoint in malloc_error_break to debug' I checked a long time and foudn that if I removed the code ttt=[s0 substringWithRange:NSMakeRange(i, 1)]; everything will be Ok (of course getSubStringAfterH can not returns the corrent result I expected.), no error reported. I try to fix the bug a few hours, but still no clue. Welcome any comment Thanks interdev

    Read the article

  • Managed server not starting up however Admin console is up.

    - by Preet
    Hi, Scenario: If i try to start the server as a window service it gives an error stating that ceradentials are not correct.However on correcting the credentials in boot.properties when i try to start the server again it gives the same error.Any alternative for starting the server.I gave the same username and password in my startup Script and Boot.properties. Scenario 2: If i start the server remotely through console then will it come up? Thanks in advance. Regards, Preet

    Read the article

  • The file is damaged and could not be repaired

    - by acadia
    Hello Experts, I am trying to display a PDF file in my ASP.net page based on the binary data received from the ASP.net Web service. Below is the code. though I am getting the data from the Web Service for some reason, if I run the below mentioned code on page load I am getting the above mentioned error. Please help Response.Buffer = True Response.ContentType = "application/pdf" Response.AddHeader("Content-Disposition", "Inline") Dim ws As New imageGenService.Service1 Dim imagebyte As Byte() = Nothing imagebyte = ws.generateSamplePDF() If imagebyte IsNot Nothing Then '"attachment; filename=Whatever.pdf" Dim MemStream As New System.IO.MemoryStream Dim doc As New iTextSharp.text.Document Dim reader As iTextSharp.text.pdf.PdfReader Dim numberOfPages As Integer Dim currentPageNumber As Integer Dim writer As iTextSharp.text.pdf.PdfWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, MemStream) doc.Open() Dim cb As iTextSharp.text.pdf.PdfContentByte = writer.DirectContent Dim page As iTextSharp.text.pdf.PdfImportedPage Dim rotation As Integer reader = New iTextSharp.text.pdf.PdfReader(imagebyte) numberOfPages = reader.NumberOfPages currentPageNumber = 0 Do While (currentPageNumber < numberOfPages) currentPageNumber += 1 doc.SetPageSize(PageSize.LETTER) doc.NewPage() page = writer.GetImportedPage(reader, currentPageNumber) rotation = reader.GetPageRotation(currentPageNumber) If (rotation = 90) Or (rotation = 270) Then cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(currentPageNumber).Height) Else cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0) End If Loop If MemStream Is Nothing Then Response.Write("No Data is available for output") Else Response.BinaryWrite(MemStream.GetBuffer()) End If End If

    Read the article

  • Ruby Irb reacts strangely to control keys

    - by eegg
    Hi. I'm (extremely) new to Ruby, having started today. I just moved from my system's Ruby 1.8 installation to Ruby 1.9, compiled from source. In doing so, irb has taken a turn for the worse. It reacts in a most unfriendly way to the non-alphanumeric control keys: UP key prints: ^[[A DOWN key prints: ^[[B DELETE key prints: ^[[3~ ...and so on. The main result of this for me is that I have no access to previously issued commands. Nor does tab-completion work; though none of this seems to be an issue with Wirble - the same happens when I remove my ~/.irbrc. I'm using: Ubuntu 9.10 GNOME Terminal 2.28.1 ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux] Irb version 0.9.5 (05/04/13) Any ideas? :(

    Read the article

  • Android Gallery View Update Images

    - by xger86x
    Hi, i have a question about using GalleryView. At first, i set five "default images" to show from drawable directory. But after, i want to run an Async Task in which i download the images, save them and show them in the gallery. For that i created the following Adapter: public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private ArrayList<Integer> mImageIds = new ArrayList<Integer>(); private ArrayList<Drawable> mImageDrawables = new ArrayList<Drawable>(); public ImageAdapter(Context c) { mContext = c; TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); mGalleryItemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } public void setPlaces(int count) { for (int i = 0; i < count; i++) { mImageIds.add(R.drawable.tournoimg); mImageDrawables.add(null); } } public void setDrawable(String resource, int position) { Drawable image = Drawable.createFromPath(resource); mImageDrawables.add(position, image); } public int getCount() { return mImageIds.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); if (mImageDrawables.get(position) == null) i.setImageResource(mImageIds.get(position)); else i.setImageDrawable(mImageDrawables.get(position)); i.setLayoutParams(new Gallery.LayoutParams(60, 78)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); return i; } } } and the following Async Task private class FillImages extends AsyncTask<ArrayList<Place>, Void, Void> { protected Void doInBackground(ArrayList<Place>... listplaces) { ArrayList<Place> places = listplaces[0]; Iterator<Place> it = places.iterator(); int position = 0; while (it.hasNext()) { Place p = it.next(); saveImage(p.getImage(), p.getURLImage()); // Gallery g = (Gallery) findViewById(R.id.gallery); mImageAdapter.setDrawable(p.getImage(), position); position++; mImageAdapter.notifyDataSetChanged(); } return (null); } But when i run it i have this error: Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. Any idea? Thanks

    Read the article

  • How to set child unordered list position?

    - by Joel
    Hi folks. I have a nav bar with children unordered lists nested under the main navbar items. My problem is on the inner list, when I position absolute, the inner list is centered to the page, and when I position relative, it is positioning inline with the parent list. I'm trying to get the first child item to line up directly under it's parent. /* OUTER LIST STYLING */ div#navbar2 { position:relative; width: 100%; border-top: solid #000 1px; border-bottom: solid #546F8B 1px; background-color: #546F8B; } div#navbar2 ul#navbar { padding: 0; margin: 10px 0; font-family: Arial, Helvetica, sans-serif; font-size: 16px; letter-spacing:1px; color: #FFF; white-space: nowrap; } div#navbar2 ul#navbar li { margin: 0 2px; list-style-type: none; display: inline; } div#navbar2 li a { text-decoration: none; color: #fff; padding: 10px 10px; } div#navbar2 li a:link { color: #FFF: } div#navbar2 li a:visited { color: #ffffff; } div#navbar2 li a:hover { color: #000; background-color: #FDFFC9; } /* INNER LIST STYLING */ div#navbar2 ul#navbar li ul.innerlist{ display: none; color:#000; } div#navbar2 ul#navbar li ul.innerlist li{ color:#000; } div#navbar2 ul#navbar li:hover ul.innerlist { position: absolute; display: inline; left: 0; width: 100%; margin: 40px 0 0px 0px; padding: 0px; color:#000; } div#navbar2 li.innerlist a { text-decoration: none; color: #000; padding: 10px 10px; } div#navbar2 li.innerlist a:link { color: #000: } div#navbar2 li.innerlist a:visited { color: #000; } div#navbar2 li.innerlist a:hover { color: #000; background-color: #FDFFC9; } And my html: <div id="navbar2"> <ul id="navbar"> <li id="index"><a href="index.php">About Rattletree</a></li> <li id="upcomingshows"><a href="upcomingshows.php">Calendar</a></li> <li id="booking"><a href="booking.php">Contact</a> <ul class="innerlist"> <li class="innerlist"><a href="#">Booking</a></li> <li class="innerlist"><a href="#">press</a></li> </ul> </li> <li id="instruments"><a href="instruments.php">The Band</a> <ul class="innerlist"> <li class="innerlist"><a href="#">The Instruments</a></li> <li class="innerlist"><a href="#">The Players</a></li> </ul> </li> <li id="classes"><a href="classes.php">Sights &amp; Sounds</a> <ul class="innerlist"> <li class="innerlist"><a href="#">Listen</a></li> <li class="innerlist"><a href="#">photos</a></li> <li class="innerlist"><a href="#">video</a></li> </ul> </li> <li id"classes"><a href="classes.php">Workshops &amp; Classes</a></li> </ul> </div> Thanks for any help!

    Read the article

  • Exam 70-448 - TS: Microsoft SQL Server 2008, Business Intelligence Development and Maintenance

    - by DigiMortal
    The another exam I passed was 70-448 - TS: Microsoft SQL Server 2008, Business Intelligence Development and Maintenance. This exam covers Business Intelligence (BI) solutions development and maintenance on SQL Server 2008 platform. It was not easy exam, but if you study then you can do it. To get prepared for 70-488 it is strongly recommended to read self-paced training kit and also make through all examples it contains. If you don’t have strong experiences on Microsoft BI platform and SQL Server then this exam is hard to pass when you just go there and hope to pass somehow. Self-paced training kit is interesting reading and you learn a lot of new stuff for sure when preparing for exam. Questions in exam are divided into topics as follows: SSIS – 32% SSAS – 38% SSRS – 30% Exam 70-448 gives you Microsoft Certified Technology Specialist certificate.

    Read the article

  • Launchpad autobuild fails when trying to access Maven component

    - by Jauder Ho
    I'm trying to build thrift as a package for the first time on Launchpad and it is failing. It appears that it is failing access repo2.maven.org for some reason. It may be that there is some access restriction but I'm not sure. I will note that the package successfully built locally. Link to build log. Search for the string "repo2.maven.org" and you will see that there is a java.net.UnknownHostException. The repo packages are here. PS. These packages are an update to the thrift package as packaged by the txAMQP team using v0.2.0 of thrift.

    Read the article

  • JAVASCRIPT ENABLED

    - by kirchoffs415
    HI, I hope somebody can help, i keep getting the following message when i log on-- Your Javascript is disabled. Limited functionality is available. it will stay for maybe a day sometimes two.I have uninstalled javascript and reinstalled but still the same. Iam using chrome. any help would be gratefull many thanks Dominic p.s. my system spec is as follows System InformationOS Name Microsoft® Windows Vista™ Home Premium Version 6.0.6002 Service Pack 2 Build 6002 Other OS Description Not Available OS Manufacturer Microsoft Corporation System Name DOM-PC System Manufacturer Dell Inc. System Model Inspiron 1545 System Type X86-based PC Processor Pentium(R) Dual-Core CPU T4200 @ 2.00GHz, 2000 Mhz, 2 Core(s), 2 Logical Processor(s) BIOS Version/Date Dell Inc. A05, 25/02/2009 SMBIOS Version 2.4 Windows Directory C:\Windows System Directory C:\Windows\system32 Boot Device \Device\HarddiskVolume3 Locale United Kingdom Hardware Abstraction Layer Version = "6.0.6002.18005" User Name DOM-PC\DOM Time Zone GMT Standard Time Installed Physical Memory (RAM) 3.00 GB Total Physical Memory 2.96 GB Available Physical Memory 1.38 GB Total Virtual Memory 5.89 GB Available Virtual Memory 4.25 GB Page File Space 3.00 GB Page File C:\pagefile.sys My System Specs

    Read the article

  • fork() in perl on windows

    - by Darioush
    I'm using fork() on PERL in windows (activeperl) for a basic socket server, but apparently there are problems (it won't accept connections after a few times), is there any workaround? while($client = $bind->accept()) { $client->autoflush(); if(fork()){ $client->close(); } else { $bind->close(); new_client($client); exit(); } } is the portion of the relevant code.

    Read the article

  • Get formatted HTML from CKEditor

    - by sslepian
    I'm using CKEditor in my web app, and I'm at a loss as to how to get the contents of the editor with HTML formatting. var objEditor = CKEDITOR.instances["sectionTextArea"]; var q = objEditor.getData(); This will get me the text entered in CKEditor, without any markup. However, var q = objEditor.getHTML(); will return a null value. What am I doing wrong?

    Read the article

  • Can't figure out jQuery ajax call parameters

    - by chad larson
    I am learning jQuery and trying the following but the parameters are so foreign to me with all the embedded quotes I think that is my problem. Can someone explain the parameters and where quotes go and possibly rewrite my parameters line? (This is a live site to see the required parms). function AirportInfo() { var divToBeWorkedOn = '#detail'; var webMethod = "'http://ws.geonames.org/citiesJSON'"; var parameters = "{'north':'44.1','south':'9.9','east':'22.4','west':'55.2','lang':'de'}"; $.ajax({ type: "POST", url: webMethod, data: parameters, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert(msg.d); $(divToBeWorkedOn).html(msg.d); }, error: function(xhr) { alert(xhr); alert(xhr.statusText); alert(xhr.responseText); $(divToBeWorkedOn).html("Unavailable"); } }); }

    Read the article

  • Android "Hello, MapView" Tutorial - Map Tiles Do Not Load

    - by Onyx
    I am new to Android software development and new to this site. I am hoping someone might have some experience with the problem I am having. I've been following the Hello, MapView tutorial in order to not only learn the Android framework, but also the Google Maps library. I've tried my best to implement things exactly as the tutorial has instructed. My problem is that the application does load in my emulator (or even on my phone for that matter), but the map tiles do not load. Searching Google I found a post by someone else on another site having the same issue, but his/her problem was that the important elements added to the AndroidManifest.xml file were not in the right order. I double-checked this in mine, but everything seems to be right. So, I am not sure what the issue is and was hoping others have seen this before. I can provide any snippets of code, if that would help. Thank you.

    Read the article

  • Using a Mac for cross platform development?

    - by mdec
    Who uses Macs for cross-platform development? By cross platform I essentially mean you can compile to target Windows or Unix (not necessarily both at the same time). I understand that this also has a lot to do with writing portable code, but I am more interested in people's experience with Mac OS X to develop software. I understand that there are a range of IDEs to choose from, I would probably use Eclipse (I like the GCC toolchain) however Xcode seems to be quite popular. Could it be used as described above? At a pinch I could always virtualise with VirtualBox or VMware Player or parallels to use Visual Studio (or dual boot for that matter). Having said that I am open to any other suggested compilers (with preferably an IDE that uses GCC.) Also with the range of Macs available, which one would you recommend? I would prefer a laptop (as I already have a desktop) but am unsure of reasonable specifications. If you are currently using a Mac to do development, I would love to hear what you develop on your Mac and what you like and don't like about it. I would primarily be developing in C/C++/Java. I am also looking to experiment with Boost and Qt, so I'm interested in hearing about any (potential) compatibility issues. If you have any other tips I'd love you hear what you have to say.

    Read the article

  • simple onmouseover to call javascript not working

    - by tic
    In a simple html page I have: <SCRIPT> function Clicker(number){ if (number == 1) document.write ('<style type="text/css">body {background-color: #cccccc;}</style>'); } </SCRIPT> and in the html body: <a onmouseclick="Clicker(1)" href="#">clic</a> But when I click on the link nothing happens. Where am I wrong?

    Read the article

  • weblogic 10.3 custom authenticator

    - by hbagchi
    we are migrating weblogic from 8.1 to 10.3. We had custom authenticator provider. Is there any standard way to migrate custom authenticator from 8.1 to 10.3? In fact, I could not find the wlManagement.jar in 10.3. I did find a wlManagement.jar file but it only contains .java files, no .class files. Please advise.

    Read the article

  • How to close/hide the Android Soft Keyboard?

    - by PHP_Jedi
    Im having an EditText and a Button in my layout. After writing inside the edit field and click on the Button, i want to hide the virtual keyboard. I guess there should be a simple, one or two liner to make this happen, but cant find any example of it. Anyone with a suggestion?

    Read the article

  • What is the performance hit of enabling sessions on Google App Engine?

    - by Spines
    What is the performance hit of enabling sessions on the Google App Engine? I just turned on <sessions-enabled>true</sessions-enabled> in my Google App Engine app and now my requests are consistently using 100 more ms of CPU time than before I enabled it. It also makes the user wait an additional 100ms for the server to respond on each request. This seems to be quite a significant cost, I'm not even calling getSession or using it in any way yet and it still adds this extra latency. Is there something I can do to speed this up?

    Read the article

  • JQuery Datatable filter css

    - by Bugzy bug
    Hey guys, I have a really dumb question if you don't mind me to ask :( the thing is that I would like to customise the filter in my datatable to the search field similar to stackoverflow's but i've been struggling so much recently so not sure if i can do it. my datatable looks like the one from the example in the link below: link text Thanks for the help!

    Read the article

  • Before data is entered, is there a way to make a grouped table graphic placeholder?

    - by Matt Winters
    I have a grouped table with 3 sections, each section with a title. The 1st and 3rd sections always have only 1 row of information so before any user data is entered, I just put some words like "Enter Data Here..." as placeholder text. This text is edited (replaced) by the user with their own actual data. No problem. The 2nd section however will contain several rows of information entered by user and I'd prefer not to enter placeholder data in row 0, having the user Edit the first row of data then Add subsequent rows. If the numberOfRowsInSection is set to 0, the title for the 3rd section comes close to the title for the 2nd section and it looks ugly. The best that I could come with, and I don't know to do it, is to have a fake graphic placeholder on the striped background (between the 2nd and third titles) that looks like a single row in the 2nd section, put "Enter Data Here..." text in the graphic, and then the first row of actual data entered and all subsequent rows will cover it up. Can anyone tell me how to do this or offer a better suggestion. Thanks.

    Read the article

  • What is the target color profile in Image.FromFile?

    - by Jan Zich
    I am curious what the useEmbeddedColorManagement parameter in System.Drawing.Image.FromFile actually does. This parameter directory corresponds to a GDI+ parameter in the same method of the same class. So debugging .NET source does not lead anywhere. If my understanding of color profiles is correct, a color profile is basically a mapping which describes how particular RGB triples (or CMYK or something else) map into the so called Profile Connection Space (CIELAB or CIEXYZ). Now, if I open an image with embedded color in .NET setting useEmbeddedColorManagement to true, my experience is I get an image whose RGB values are not exactly the same as the original values in the file, i.e. is transformed. Since the original image was an RGB and the new is also an RGB, there must have been a transformation from the embedded color profile to a Profile Connection Space and the back to RGB. The thing which I don’t understand is what is the target color system? Is it some default Windows color profile? Is the current monitor profile? Is it sRGB?

    Read the article

  • Best Firewall product for hosting/housing environment?

    - by Raffael Luthiger
    I am searching for a firewall product (appliance or software) for an hosting/housing environment. The biggest problem is that the rules get very complex as more customers are behind the firewall. Some have only one server, others have a whole subnet. Some need NAT, some a VPN endpoint. Some customers want to only allow port http, others ssh as well. So the device needs to be able to support VLANs and it should be possible to group the rules per customer. Speed is another important point. And being able to manage redundant devices easily. I am searching for something that doesn't have all the extras like spam filter etc. I was searching a lot on the net but either they had all those extras as well (and with is an overloaded configuration interface) or they missed some of the features I need (e.g. VLAN). The VPN endpoint is not the an important criteria. We were thinking about a separate machine for it.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >