Search Results

Search found 4955 results on 199 pages for 'range'.

Page 86/199 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • How to restrict rightBarButtonItem size in UINavigationBar ?

    - by lefakir
    I create a rightBarButtonItem with this method : - (UIBarButtonItem *)customBarButtonWithSelector:(SEL)callback { UIButton *customButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; customButton.bounds = CGRectMake(0, 0, 30.0f, 30.0f); return [[[UIBarButtonItem alloc] initWithCustomView:customButton] autorelease]; } At execution time the selector is fired when the bar is touched outside the button (near the middle). Is there a way to restrict the event responder in the defined bounds or in a acceptable range ?

    Read the article

  • Downloading all ctrl alt del webcomics using terminal.

    - by Conner
    I've tried using the following commands to download the ctrl alt del comics. $ for filename in $(seq 20021023 20100503); do wget http://www.ctrlaltdel-online.com/comics/"$filename".jpg; done I get the following error code, "bash: syntax error near unexpected token 'do'" I've also tried using cURL, using this command, curl http://ctrlaltdel-online.com/comics[20021023..20100503].jpg I get the following error code, "curl: (3) [globbing] error: bad range specification after pos 37" Any help would be great.

    Read the article

  • Same OpenID code working on 1 server not working on another

    - by Frraaz
    We implemented OpenID for Google Marketplace on this online hosting and it worked perfectly fine. But its not working on another server which DOES NOT have cPanel unlike the online hosting. Its failing authentication with this message: "Nonce already used or out of range" Does anyone have any idea what could be causing this problem?

    Read the article

  • tools for quick php development

    - by YsoL8
    I'm a PHP developer looking to speed up my production time, and add a new ability to my CV. I'm after a package that provides the basic CMS features that I can build on for a wide range of purposes. I've heard of PHPcake, Drupal ect but I don't know enough about these to make an informed decision. What alternatives are there? Are they OO, MVC, producedual? If you could point me to some comparisons or give your option of which actually work.

    Read the article

  • how can I handle user defined exceptions and after handling them resume the flow of program. here is

    - by fari
    /** * An exception thrown when an illegal side pit was * specified (i.e. not in the range 1-6) for a move */ public class IllegalSidePitNumException extends RuntimeException { /** * Exception constructor. * @param sidePitNum the illegal side pit that was selected. */ public IllegalSidePitNumException(int sidePitNum) { super("No such side pit number: "+sidePitNum); } } how do i use this ina program and then resume for there. I do not want the program to end but want to handle the exception and continue.

    Read the article

  • Is there any IDE integration for JBoss AS 6?

    - by Jonathan Frank
    We have switched to JBoss 6 to make it possible to use a wider range of Java EE technologies. We chose JBoss because of its small memory footprint compared to other application servers, so we have no other choice. Do you know any developer tools that can be integrated with JBoss AS 6? Thanks in advance Jonathan Frank

    Read the article

  • Dealing with external processes

    - by Jesse Aldridge
    I've been working on a gui app that needs to manage external processes. Working with external processes leads to a lot of issues that can make a programmer's life difficult. I feel like maintenence on this app is taking an unacceptably long time. I've been trying to list the things that make working with external processes difficult so that I can come up with ways of mitigating the pain. This kind of turned into a rant which I thought I'd post here in order to get some feedback and to provide some guidance to anybody thinking about sailing into these very murky waters. Here's what I've got so far: Output from the child can get mixed up with output from the parent. This can make both outputs misleading and hard to read. It can be hard to tell what came from where. It becomes harder to figure out what's going on when things are asynchronous. Here's a contrived example: import textwrap, os, time from subprocess import Popen test_path = 'test_file.py' with open(test_path, 'w') as file: file.write(textwrap.dedent(''' import time for i in range(3): print 'Hello %i' % i time.sleep(1)''')) proc = Popen('python -B "%s"' % test_path) for i in range(3): print 'Hello %i' % i time.sleep(1) os.remove(test_path) I guess I could have the child process write its output to a file. But it can be annoying to have to open up a file every time I want to see the result of a print statement. If I have code for the child process I could add a label, something like print 'child: Hello %i', but it can be annoying to do that for every print. And it adds some noise to the output. And of course I can't do it if I don't have access to the code. I could manually manage the process output. But then you open up a huge can of worms with threads and polling and stuff like that. A simple solution is to treat processes like synchronous functions, that is, no further code executes until the process completes. In other words, make the process block. But that doesn't work if you're building a gui app. Which brings me to the next problem... Blocking processes cause the gui to become unresponsive. import textwrap, sys, os from subprocess import Popen from PyQt4.QtGui import * from PyQt4.QtCore import * test_path = 'test_file.py' with open(test_path, 'w') as file: file.write(textwrap.dedent(''' import time for i in range(3): print 'Hello %i' % i time.sleep(1)''')) app = QApplication(sys.argv) button = QPushButton('Launch process') def launch_proc(): # Can't move the window until process completes proc = Popen('python -B "%s"' % test_path) proc.communicate() button.connect(button, SIGNAL('clicked()'), launch_proc) button.show() app.exec_() os.remove(test_path) Qt provides a process wrapper of its own called QProcess which can help with this. You can connect functions to signals to capture output relatively easily. This is what I'm currently using. But I'm finding that all these signals behave suspiciously like goto statements and can lead to spaghetti code. I think I want to get sort-of blocking behavior by having the 'finished' signal from QProcess call a function containing all the code that comes after the process call. I think that should work but I'm still a bit fuzzy on the details... Stack traces get interrupted when you go from the child process back to the parent process. If a normal function screws up, you get a nice complete stack trace with filenames and line numbers. If a subprocess screws up, you'll be lucky if you get any output at all. You end up having to do a lot more detective work everytime something goes wrong. Speaking of which, output has a way of disappearing when dealing external processes. Like if you run something via the windows 'cmd' command, the console will pop up, execute the code, and then disappear before you have a chance to see the output. You have to pass the /k flag to make it stick around. Similar issues seem to crop up all the time. I suppose both problems 3 and 4 have the same root cause: no exception handling. Exception handling is meant to be used with functions, it doesn't work with processes. Maybe there's some way to get something like exception handling for processes? I guess that's what stderr is for? But dealing with two different streams can be annoying in itself. Maybe I should look into this more... Processes can hang and stick around in the background without you realizing it. So you end up yelling at your computer cuz it's going so slow until you finally bring up your task manager and see 30 instances of the same process hanging out in the background. Also, hanging background processes can interefere with other instances of the process in various fun ways, such as causing permissions errors by holding a handle to a file or someting like that. It seems like an easy solution to this would be to have the parent process kill the child process on exit if the child process didn't close itself. But if the parent process crashes, cleanup code might not get called and the child can be left hanging. Also, if the parent waits for the child to complete, and the child is in an infinite loop or something, you can end up with two hanging processes. This problem can tie in to problem 2 for extra fun, causing your gui to stop responding entirely and force you to kill everything with the task manager. F***ing quotes Parameters often need to be passed to processes. This is a headache in itself. Especially if you're dealing with file paths. Say... 'C:/My Documents/whatever/'. If you don't have quotes, the string will often be split at the space and interpreted as two arguments. If you need nested quotes you can use ' and ". But if you need to use more than two layers of quotes, you have to do some nasty escaping, for example: "cmd /k 'python \'path 1\' \'path 2\''". A good solution to this problem is passing parameters as a list rather than as a single string. Subprocess allows you to do this. Can't easily return data from a subprocess. You can use stdout of course. But what if you want to throw a print in there for debugging purposes? That's gonna screw up the parent if it's expecting output formatted a certain way. In functions you can print one string and return another and everything works just fine. Obscure command-line flags and a crappy terminal based help system. These are problems I often run into when using os level apps. Like the /k flag I mentioned, for holding a cmd window open, who's idea was that? Unix apps don't tend to be much friendlier in this regard. Hopefully you can use google or StackOverflow to find the answer you need. But if not, you've got a lot of boring reading and frusterating trial and error to do. External factors. This one's kind of fuzzy. But when you leave the relatively sheltered harbor of your own scripts to deal with external processes you find yourself having to deal with the "outside world" to a much greater extent. And that's a scary place. All sorts of things can go wrong. Just to give a random example: the cwd in which a process is run can modify it's behavior. There are probably other issues, but those are the ones I've written down so far. Any other snags you'd like to add? Any suggestions for dealing with these problems?

    Read the article

  • Project Euler #290 in python, hint please

    - by debragail
    This solution is grossly inefficient. What am I missing? #!/usr/bin/env python #coding: utf-8 import time from timestrings import * start = time.clock() maxpower = 18 count = 0 for i in range(0, 10 ** maxpower - 1): if i % 9 == 0: result1 = list(str(i)) result2 = list(str(137 * i)) sum1 = 0 for j in result1: sum1 += int(j) sum2 = 0 for j in result2: sum2 += int(j) if sum1 == sum2: print (i, sum1) count += 1 finish = time.clock() print ("Project Euler, Project 290") print () print ("Answer:", count) print ("Time:", stringifytime(finish - start))

    Read the article

  • C# asynchronous beginsend method

    - by Jatin
    I am a newbie in socket programming. I am developing a server client application. And I am using Asynchronous tcp ip socket. But now I am facing a problem. In my client side I am receiving my data by a 2kb byte array by beginReceive method. Its working perfectly if data size below or equals to 2 kb, but problem occurring when data size exceeding 2kb range. Please give me some solution.

    Read the article

  • php , SimpleXML, while loop

    - by Michael
    I'm trying to get some information from ebay api and store it in database . I used simple xml to extract the information but I have a small issue as the information is not displayed for some items . if I make a print to the simple_xml I can see very well that the information is provided by ebay api . I have $items = "220617293997,250645537939,230485306218,110537213815,180519294810"; $number_of_items = count(explode(",", $items)); $xml = $baseClass->getContent("http://open.api.ebay.com/shopping?callname=GetMultipleItems&responseencoding=XML&appid=Morcovar-c74b-47c0-954f-463afb69a4b3&siteid=0&version=525&IncludeSelector=ItemSpecifics&ItemID=$items"); writeDoc($xml, "api.xml"); //echo $xml; $getvalues = simplexml_load_file('api.xml'); // print_r($getvalue); $number = "0"; while($number < 6) { $item_number = $getvalues->Item[$number]->ItemID; $location = $getvalues->Item[$number]->Location; $title = $getvalues->Item[$number]->Title; $price = $getvalues->Item[$number]->ConvertedCurrentPrice; $manufacturer = $getvalues->Item[$number]->ItemSpecifics->NameValueList[3]->Value; $model = $getvalues->Item[$number]->ItemSpecifics->NameValueList[4]->Value; $mileage = $getvalues->Item[$number]->ItemSpecifics->NameValueList[5]->Value; echo "item number = $item_number <br>localtion = $location<br>". "title = $title<br>price = $price<br>manufacturer = $manufacturer". "<br>model = $model<br>mileage = $mileage<br>"; $number++; } the above code returns item number = localtion = title = price = manufacturer = model = mileage = item number = 230485306218 localtion = Coventry, Warwickshire title = 2001 LAND ROVER RANGE ROVER VOGUE AUTO GREEN price = 3635.07 manufacturer = Land Rover model = Range Rover mileage = 76000 item number = 220617293997 localtion = Crawley, West Sussex title = 2004 CITROEN C5 HDI LX RED price = 3115.77 manufacturer = Citroen model = C5 mileage = 76000 item number = 180519294810 localtion = London, London title = 2000 VOLKSWAGEN POLO 1.4 SILVER 16V NEED GEAR BOX price = 905.06 manufacturer = Right-hand drive model = mileage = Standard Car item number = localtion = title = price = manufacturer = model = mileage = As you can see the information is not retrieved for a few items ... If I replace the $number manually like " $item_number = $getvalues-Item[4]-ItemID;" works well for any number .

    Read the article

  • stdout and stderr anomalies

    - by momo
    from the interactive prompt: >>> import sys >>> sys.stdout.write('is the') is the6 what is '6' doing there? another example: >>> for i in range(3): ... sys.stderr.write('new black') ... 9 9 9 new blacknew blacknew black where are the numbers coming from?

    Read the article

  • Finding the nth number of primes

    - by Braxton Smith
    I can not figure out why this won't work. Please help me from math import sqrt pN = 0 numPrimes = 0 num = 1 def checkPrime(x): '''Check\'s whether a number is a prime or not''' prime = True if(x==2): prime = True elif(x%2==0): prime=False else: root=int(sqrt(x)) for i in range(3,root,2): if(x%i==0): prime=False break return prime n = int(input("Find n number of primes. N being:")) while( numPrimes != n ): if( checkPrime( num ) == True ): numPrimes += 1 pN = num print("{0}: {1}".format(numPrimes,pN)) num += 1 print("Prime {0} is: {1}".format(n,pN))

    Read the article

  • Python SUDS - problem with sending a message encoded not in UTF-8

    - by bartekb
    I need to send a SOAP message (with Python SUDS) with strings encoded in 'iso-8859-2'. Does anybody know how to do it? SUDS raises the following exception when I invoke a method on a client with parameters encoded in 'iso-8859-2': File "/home/bartek/myenv/lib/python2.5/site-packages/suds/sax/text.py", line 43, in __new__ result = super(Text, cls).__new__(cls, *args, **kwargs) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 10: ordinal not in range(128)

    Read the article

  • Convert or strip out "illegal" Unicode characters

    - by Oli
    I've got a database in MSSQL that I'm porting to SQLite/Django. I'm using pymssql to connect to the database and save a text field to the local SQLite database. However for some characters, it explodes. I get complaints like this: UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 1916: ordinal not in range(128) Is there some way I can convert the chars to proper unicode versions? Or strip them out?

    Read the article

  • Written a resharper plugin that modifies the TextControl?

    - by Ajaxx
    Resharper claims to eat it's own dogfood, specifically, they claim that many of the features of Resharper are written ontop of R# (OpenAPI). I'm writing a simple plugin to fix up comments of the current document of a selection. When this plugin is run, it throws an exception as follows: Document can be modified inside a command scope only I've researched the error and can't find anything to help with this, so I'm hoping that possibly, you've written a plugin to accomplish this. If not, I hope the snippet is enough to help others get their own plugins underway. using System; using System.IO; using System.Windows.Forms; using JetBrains.ActionManagement; using JetBrains.DocumentModel; using JetBrains.IDE; using JetBrains.TextControl; using JetBrains.Util; namespace TinkerToys.Actions { [ActionHandler("TinkerToys.RewriteComment")] public class RewriteCommentAction : IActionHandler { #region Implementation of IActionHandler /// <summary> /// Updates action visual presentation. If presentation.Enabled is set to false, Execute /// will not be called. /// </summary> /// <param name="context">DataContext</param> /// <param name="presentation">presentation to update</param> /// <param name="nextUpdate">delegate to call</param> public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate) { ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL); return textControl != null; } /// <summary> /// Executes action. Called after Update, that set ActionPresentation.Enabled to true. /// </summary> /// <param name="context">DataContext</param> /// <param name="nextExecute">delegate to call</param> public void Execute(IDataContext context, DelegateExecute nextExecute) { ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL); if (textControl != null) { TextRange textSelectRange; ISelectionModel textSelectionModel = textControl.SelectionModel; if ((textSelectionModel != null) && textSelectionModel.HasSelection()) { textSelectRange = textSelectionModel.Range; } else { textSelectRange = new TextRange(0, textControl.Document.GetTextLength()); } IDocument textDocument = textControl.Document; String textSelection = textDocument.GetText(textSelectRange); if (textSelection != null) { StringReader sReader = new StringReader(textSelection); StringWriter sWriter = new StringWriter(); Converter.Convert(sReader, sWriter); textSelection = sWriter.ToString(); textDocument.ReplaceText(textSelectRange, textSelection); } } } #endregion } } So what is this command scope it wants so badly? I had some additional logging in this prior to posting it so I'm absolutely certain that both the range and text are valid. In addition, the error seems to indicate that I'm missing some scope that I've been, as yet, unable to find.

    Read the article

  • Problem in displaying numbers in Flex AdvancedDataGrid

    - by user211607
    Hi, I am able to display any data (numbers) in Flex AdvancedDataGrid except data with lot of digits after decimal places (0.000000000029103830456733704) or exponential numbers (293E-17). Grid is displaying -17 instead of 293E-17. Is it happening because of any limit to displaying data range in grid? If yes, what is the limit? Thanks in advance ... Atul

    Read the article

  • Is there a floating point value of x, for which x-x == 0 is false?

    - by Andrew Walker
    In most cases, I understand that a floating point comparison test should be implemented using over a range of values (abs(x-y) < epsilon), but does self subtraction imply that the result will be zero? // can the assertion be triggered? float x = //?; assert( x-x == 0 ) My guess is that nan/inf might be special cases, but I'm more interested in what happens for simple values.

    Read the article

  • Algorithm to retrieve every possible combination of sublists of a two lists

    - by sgmoore
    Suppose I have two lists, how do I iterate through every possible combination of every sublist, such that each item appears once and only once. I guess an example could be if you have employees and jobs and you want split them into teams, where each employee can only be in one team and each job can only be in one team. Eg List<string> employees = new List<string>() { "Adam", "Bob"} ; List<string> jobs = new List<string>() { "1", "2", "3"}; I want Adam : 1 Bob : 2 , 3 Adam : 1 , 2 Bob : 3 Adam : 1 , 3 Bob : 2 Adam : 2 Bob : 1 , 3 Adam : 2 , 3 Bob : 1 Adam : 3 Bob : 1 , 2 Adam, Bob : 1, 2, 3 I tried using the answer to this stackoverflow question to generate a list of every possible combination of employees and every possible combination of jobs and then select one item from each from each list, but that's about as far as I got. I don't know the maximum size of the lists, but it would be certainly be less than 100 and there may be other limiting factors (such as each team can have no more than 5 employees) Update Not sure whether this can be tidied up more and/or simplified, but this is what I have ended up with so far. It uses the Group algorithm supplied by Yorye (see his answer below), but I removed the orderby which I don't need and caused problems if the keys are not comparable. var employees = new List<string>() { "Adam", "Bob" } ; var jobs = new List<string>() { "1", "2", "3" }; int c= 0; foreach (int noOfTeams in Enumerable.Range(1, employees.Count)) { var hs = new HashSet<string>(); foreach( var grouping in Group(Enumerable.Range(1, noOfTeams).ToList(), employees)) { // Generate a unique key for each group to detect duplicates. var key = string.Join(":" , grouping.Select(sub => string.Join(",", sub))); if (!hs.Add(key)) continue; List<List<string>> teams = (from r in grouping select r.ToList()).ToList(); foreach (var group in Group(teams, jobs)) { foreach (var sub in group) { Console.WriteLine(String.Join(", " , sub.Key ) + " : " + string.Join(", ", sub)); } Console.WriteLine(); c++; } } } Console.WriteLine(String.Format("{0:n0} combinations for {1} employees and {2} jobs" , c , employees.Count, jobs.Count)); Since I'm not worried about the order of the results, this seems to give me what I need.

    Read the article

  • form a number using consecutive numbers

    - by Mahesh
    Hi, I was puzzled with one of the question in Microsoft interview which is as given below: A function should accept a range( 3 - 21 ) and it should print all the consecutive numbers combination's to form each number as given below: 3=1+2 5=2+3 6=1+2+3 7=3+4 9=4+5 10=1+2+3+4 11=5+6 13=6+7 15=1+2+3+4+5 17=7+8 19=8+9 21=10+11 21=1+2+3+4+5+6 could you please help me in forming this sequence in C#? Thanks, Mahesh

    Read the article

  • What is the single most influential book every programmer should read?

    - by NotMyself
    If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide range of things. For me, the book would be Code Complete. After reading that book, I was able to get out of the immediate task mindset and begin to think about the bigger picture, quality and maintainability.

    Read the article

  • Binary to Date (C#) 64 Bit Format

    - by Veskechky
    We have a binary file from which we have identified the following dates (as Int64). We now the following facts about the Date/Time format; The 64 bit Date has a resolution to the microsecond The 64 bit Date has a range of 4095 years The Int64 9053167636875050944 (0x7DA34FFFFFFFFFC0) = 9th March 2010 The Int64 9053176432968073152 (0x7DA357FFFFFFFFC0) = 10th March 2010 The Int64 9053185229061095360 (0x7DA35FFFFFFFFFC0) = 11th March 2010 The Int64 9053194025154117568 (0x7DA367FFFFFFFFC0) = 12th March 2010 Any help on figuring out a way to convert this to a valid C# Date/Time is appreciated.

    Read the article

  • Java multiple connections downloading file

    - by weulerjunior
    Hello friends, I was wanting to add multiple connections in the code below to be able to download files faster. Could someone help me? Thanks in advance. public void run() { RandomAccessFile file = null; InputStream stream = null; try { // Open connection to URL. HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // Specify what portion of file to download. connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); // Connect to server. connection.connect(); // Make sure response code is in the 200 range. if (connection.getResponseCode() / 100 != 2) { error(); } // Check for valid content length. int contentLength = connection.getContentLength(); if (contentLength < 1) { error(); } /* Set the size for this download if it hasn't been already set. */ if (size == -1) { size = contentLength; stateChanged(); } // Open file and seek to the end of it. file = new RandomAccessFile("C:\\"+getFileName(url), "rw"); file.seek(downloaded); stream = connection.getInputStream(); while (status == DOWNLOADING) { /* Size buffer according to how much of the file is left to download. */ byte buffer[]; if (size - downloaded > MAX_BUFFER_SIZE) { buffer = new byte[MAX_BUFFER_SIZE]; } else { buffer = new byte[size - downloaded]; } // Read from server into buffer. int read = stream.read(buffer); if (read == -1) { break; } // Write buffer to file. file.write(buffer, 0, read); downloaded += read; stateChanged(); } /* Change status to complete if this point was reached because downloading has finished. */ if (status == DOWNLOADING) { status = COMPLETE; stateChanged(); } } catch (Exception e) { error(); } finally { // Close file. if (file != null) { try { file.close(); } catch (Exception e) { } } // Close connection to server. if (stream != null) { try { stream.close(); } catch (Exception e) { } } } }

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >