Search Results

Search found 14182 results on 568 pages for 'andrew answer'.

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

  • I am trying to deploy my first rails app using Capistrano and am getting an error.

    - by Andrew Bucknell
    My deployment of a rails app with capistrano is failing and I hoping someone can provide me with pointers to troubleshoot. The following is the command output andrew@melb-web:~/projects/rails/guestbook2$ cap deploy:setup * executing `deploy:setup' * executing "mkdir -p /var/www/dev/guestbook2 /var/www/dev/guestbook2/releases /var/www/dev/guestbook2/shared /var/www/dev/guestbook2/shared/system /var/www/dev/guestbook2/shared/log /var/www/dev/guestbook2/shared/pids && chmod g+w /var/www/dev/guestbook2 /var/www/dev/guestbook2/releases /var/www/dev/guestbook2/shared /var/www/dev/guestbook2/shared/system /var/www/dev/guestbook2/shared/log /var/www/dev/guestbook2/shared/pids" servers: ["dev.andrewbucknell.com"] Enter passphrase for /home/andrew/.ssh/id_dsa: Enter passphrase for /home/andrew/.ssh/id_dsa: [dev.andrewbucknell.com] executing command command finished andrew@melb-web:~/projects/rails/guestbook2$ cap deploy:check * executing `deploy:check' * executing "test -d /var/www/dev/guestbook2/releases" servers: ["dev.andrewbucknell.com"] Enter passphrase for /home/andrew/.ssh/id_dsa: [dev.andrewbucknell.com] executing command command finished * executing "test -w /var/www/dev/guestbook2" servers: ["dev.andrewbucknell.com"] [dev.andrewbucknell.com] executing command command finished * executing "test -w /var/www/dev/guestbook2/releases" servers: ["dev.andrewbucknell.com"] [dev.andrewbucknell.com] executing command command finished * executing "which git" servers: ["dev.andrewbucknell.com"] [dev.andrewbucknell.com] executing command command finished * executing "test -w /var/www/dev/guestbook2/shared" servers: ["dev.andrewbucknell.com"] [dev.andrewbucknell.com] executing command command finished You appear to have all necessary dependencies installed andrew@melb-web:~/projects/rails/guestbook2$ cap deploy:migrations * executing `deploy:migrations' * executing `deploy:update_code' updating the cached checkout on all servers executing locally: "git ls-remote [email protected]:/home/andrew/git/guestbook2.git master" Enter passphrase for key '/home/andrew/.ssh/id_dsa': * executing "if [ -d /var/www/dev/guestbook2/shared/cached-copy ]; then cd /var/www/dev/guestbook2/shared/cached-copy && git fetch origin && git reset --hard 369c5e04aaf83ad77efbfba0141001ac90915029 && git clean -d -x -f; else git clone [email protected]:/home/andrew/git/guestbook2.git /var/www/dev/guestbook2/shared/cached-copy && cd /var/www/dev/guestbook2/shared/cached-copy && git checkout -b deploy 369c5e04aaf83ad77efbfba0141001ac90915029; fi" servers: ["dev.andrewbucknell.com"] Enter passphrase for /home/andrew/.ssh/id_dsa: [dev.andrewbucknell.com] executing command ** [dev.andrewbucknell.com :: err] Permission denied, please try again. ** Permission denied, please try again. ** Permission denied (publickey,password). ** [dev.andrewbucknell.com :: err] fatal: The remote end hung up unexpectedly ** [dev.andrewbucknell.com :: out] Initialized empty Git repository in /var/www/dev/guestbook2/shared/cached-copy/.git/ command finished failed: "sh -c 'if [ -d /var/www/dev/guestbook2/shared/cached-copy ]; then cd /var/www/dev/guestbook2/shared/cached-copy && git fetch origin && git reset --hard 369c5e04aaf83ad77efbfba0141001ac90915029 && git clean -d -x -f; else git clone [email protected]:/home/andrew/git/guestbook2.git /var/www/dev/guestbook2/shared/cached-copy && cd /var/www/dev/guestbook2/shared/cached-copy && git checkout -b deploy 369c5e04aaf83ad77efbfba0141001ac90915029; fi'" on dev.andrewbucknell.com andrew@melb-web:~/projects/rails/guestbook2$ The following fragment is from cap -d deploy:migrations Preparing to execute command: "find /var/www/dev/guestbook2/releases/20100305124415/public/images /var/www/dev/guestbook2/releases/20100305124415/public/stylesheets /var/www/dev/guestbook2/releases/20100305124415/public/javascripts -exec touch -t 201003051244.22 {} ';'; true" Execute ([Yes], No, Abort) ? |y| yes * executing `deploy:migrate' * executing "ls -x /var/www/dev/guestbook2/releases" Preparing to execute command: "ls -x /var/www/dev/guestbook2/releases" Execute ([Yes], No, Abort) ? |y| yes /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.17/lib/capistrano/recipes/deploy.rb:55:in `join': can't convert nil into String (TypeError) from /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.17/lib/capistrano/recipes/deploy.rb:55:in `load'

    Read the article

  • What will be correct answer to "why is NoSQL faster than SQL" on interview?

    - by Cynede
    It's just nonsense for me personally. I can't see any performance boost by using NoSQL instead of SQL. Maybe SQL over NoSQL, yes but not in that way. I think that if I answer "I have no idea" or something like that it will be bad answer because this doesn't really look like a fake-question, it's a serious question on interview but how should be looking correct answer on this question? Or am I missing something about NoSQL?

    Read the article

  • codility challenge, test case OK , Evaluation report Wrong Answer

    - by Hussein Fawzy
    the aluminium 2014 gives me wrong answer [3 , 9 , -6 , 7 ,-3 , 9 , -6 , -10] got 25 expected 28 but when i repeated the challenge with the same code and make case test it gives me the correct answer Your test case [3, 9, -6, 7, -3, 9, -6, -10] : NO RUNTIME ERRORS (returned value: 28) what is the wrong with it ??? the challenge :- A non-empty zero-indexed array A consisting of N integers is given. A pair of integers (P, Q), such that 0 = P = Q < N, is called a slice of array A. The sum of a slice (P, Q) is the total of A[P] + A[P+1] + ... + A[Q]. The maximum sum is the maximum sum of any slice of A. For example, consider array A such that: A[0] = 3 A[1] = 2 A[2] = -6 A[3] = 3 A[4] = 1 For example (0, 1) is a slice of A that has sum A[0] + A[1] = 5. This is the maximum sum of A. You can perform a single swap operation in array A. This operation takes two indices I and J, such that 0 = I = J < N, and exchanges the values of A[I] and A[J]. To goal is to find the maximum sum you can achieve after performing a single swap. For example, after swapping elements 2 and 4, you will get the following array A: A[0] = 3 A[1] = 2 A[2] = 1 A[3] = 3 A[4] = -6 After that, (0, 3) is a slice of A that has the sum A[0] + A[1] + A[2] + A[3] = 9. This is the maximum sum of A after a single swap. Write a function: class Solution { public int solution(int[] A); } that, given a non-empty zero-indexed array A of N integers, returns the maximum sum of any slice of A after a single swap operation. For example, given: A[0] = 3 A[1] = 2 A[2] = -6 A[3] = 3 A[4] = 1 the function should return 9, as explained above. and my code is :- import java.math.*; class Solution { public int solution(int[] A) { if(A.length == 1) return A[0]; else if (A.length==2) return A[0]+A[1]; else{ int finalMaxSum = A[0]; for (int l=0 ; l<A.length ; l++){ for (int k = l+1 ; k<A.length ; k++ ){ int [] newA = A; int temp = newA[l]; newA [l] = newA[k]; newA[k]=temp; int maxSum = newA[0]; int current_max = newA[0]; for(int i = 1; i < newA.length; i++) { current_max = Math.max(A[i], current_max + newA[i]); maxSum = Math.max(maxSum, current_max); } finalMaxSum = Math.max(finalMaxSum , maxSum); } } return finalMaxSum; } } } i don't know what's the wrong with it ??

    Read the article

  • How to programmatically answer "Yes" to WebBrowser control security alert

    - by ih8ie8
    I am using WebBrowser control to programmatically access a single website, but whenever I login, I receive this certificate security alert: Since I trust that website and since I need to programmatically automate the login as well, this dialog box gets in the way. I searched SO for a solution and found a question similar to mine, but the accepted answer does not work! I defined a static member in the form that contains the WebControl: public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } In my form's constructor I added: ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); But that didn't get rid of the certificate security alert. Is there any way to get rid of this warning? Is there an IE equivalent to Firefox's Add Security Exception??? Note: The owner's certificate works perfectly fine (without exhibiting this security alert) with standalone browsers (IE, FF, Chrome, Safari). It only exhibits the problem with the WebBroswer control.

    Read the article

  • Is FastCGI still a right answer?

    - by Ted Henry
    FastCGI is old but it still seems like it must be the right answer in some cases. It seems like the preferred deployment of Perl/Catalyst web applications is with FastCGI. FastCGI was popular with Rails but seems to no longer be. (Why?) The Java world doesn't seem to have anything to do with FastCGI. Is something like Tomcat way better than Apache+FastCGI? Is choosing FastCGI still a good idea or just a lingering technology? Ted

    Read the article

  • RESTful Question/Answer design?

    - by Kirschstein
    This is a toy project I'm working on at the moment. My app contains questions with multiple choice answers. The question url is in the following format, with GET & POST mapping to different actions on the questions controller. GET: url.com/questions/:category/:difficulty => 'ask' POST: url.com/questions/:category/:difficulty => 'answer' I'm wondering if it's worth redesigning this into a RESTful style. I know I'd need to introduce answers as a resource, but I'm struggling to think of a url that would look natural for answering that question. Would a redesign be worthwhile? How would you go about structuring the urls?

    Read the article

  • Probability distribution for sms answer delays

    - by Thomas Ahle
    I'm writing an app using sms as communication. I have chosen to subscribe to an sms-gateway, which provides me with an API for doing so. The API has functions for sending as well as pulling new messages. It does however not have any kind of push functionality. In order to do my queries most efficient, I'm seeking data on how long time people wait before they answer a text message - as a probability function. Extra info: The application is interactive (as can be), so I suppose the times will be pretty similar to real life human-human communication. I don't believe differences in personal style will play a big impact on the right times and frequencies to query, so average data should be fine.

    Read the article

  • What question(s) does an object's behavior answer?

    - by Corwin
    Reading a book I have found the following statement: (Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten. In my understanding of object behaviour the statement above is correct regarding the first question and is incorrect in case of the second. However, I often see classes with methods like Orange::eat(), and this makes me uncertain about my design skills. So I would like to ask is it a design mistake to give oranges a behaviour eat? (oranges and eat are used just for example)

    Read the article

  • Asterisk: Originate API - Which card to use to detect busy/ringing/answer event for FXO

    - by spkhaira
    I want to use Originate API of Asterisk to place an outbound call on a FXO channel, for testing purpose I am using X100P card and, as expected, card is not able to detect if the number is busy/ringing or when it is answered. I want to know which card should I use so that I can get such basic events ... I am not really interested in detailed call progress analysis for answering machine or live voice. I just need basic busy/ringing and answer events and maybe a dis-connect event. Thanks.

    Read the article

  • Javascript for a prompt which accepts simple math as a value and then returns the answer

    - by user1139403
    I have written a snippet of code in javascript, for a prompt to appear when clicked. I want to be able to enter a simple math problem (i.e. 230/2) and have it output the answer, rather than the math problem I just entered. Your help will be much appreciated. <!DOCTYPE html> <html> <body> <button onclick="myFunction()">Click me</button> <p id="demo"></p> <script type="text/javascript"> function myFunction() { var x; var mathProblem=prompt("Enter your math problem",""); if (name!=null) { x = mathProblem; document.getElementById("demo").innerHTML = x; } } </script> </body> </html>

    Read the article

  • Is jQuery always the answer?

    - by Kibbee
    I've come across a couple questions, such as this one, and I really have to wonder why "Use jQuery" seems to be the answer when somebody asks how to do something in JavaScript. I understand that jQuery can save you a lot of time, and can help you out a lot, especially when you are doing a lot of fancy JavaScript in your site. However, in instances like this, and in many other instances, it seems like it's just jumping around the problem instead of answering the question. I also feel like this builds too much dependency into libraries. I've seen way too many developers that simply rely too much on libraries, and if they encounter a situation where they didn't have the library, they would be completely unable to function. I feel like there are already enough developers who don't know JavaScript, without just telling everybody to not learn JavaScript, and use jQuery. So, just to reiterate the question. Do you think there's too much of a tendency to use jQuery, for small pieces of JavaScript, when most of the functionality of jQuery isn't being used. Should developers be fluent in the use of bare JavaScript so they don't get too dependent on using libraries? [Additional related conversation topic] Does the existence of jQuery give too much slack to web browser developers who write the JavaScript engines? If we just have workarounds to cover all the inconsistencies in JavaScript, what pressure is there on browser makers to ensure that their JavaScript library works as it should. I feel like this extrapolates the same problem discussed in SO Podcast #36 of "be conservative in what you send, liberal in what you accept". By being so liberal with bad JavaScript engines, and using a common library to work around the flaws, we are promoting their use, and extending the problem.

    Read the article

  • How would you design a question/answer view (iPhone SDK)

    - by Aurélien Vallée
    I'm new to iPhone development, and I have a question on how to create a view for my application. The view should display a problem (using formatted/syntax highlighted text), and multiple possible answers. The user should be able to click on an answer to validate it. Currently, I am trying to use a UITableView embedding UIWebView as contentView. That allows me to display formatted text easily. The problem is that it is a real pain to compute and adjust the height of the cells. I have to preload the webview, call sizeToFit, get its height, and update the cell accordingly. This process should be done for the problem and the answers (as they are HTML formatted text too). It's such a pain that I am planning to switch to something else. I thought using only a big UIWebView and design everything in HTML. But I looked at some articles describing how to communicate between the HTML page and the ObjectiveC code. This seems to involve some awful tricks too... So... that's it, I don't really know what I should do. I guess some of you dealt with such things before, and would provide some greatly appreciated tips :)

    Read the article

  • java - codesprint2 programming contest answer

    - by arya
    I recently took part in Codesprint2. I was unable to submit the solution to the following question. http://www.spoj.pl/problems/COINTOSS/ ( I have posted the link to the problem statement at spoj because the codesprint link requires login ) I checked out one of the successful solutions, ( url : http://pastebin.com/uQhNh9Rc ) and the logic used is exactly the same as mine, yet I am still getting "Wrong Answer" I would be very thankful if someone could please tell me what error I have made, as I am unable to find it. Thank you. My code : import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.util.StringTokenizer; public class Solution { static double solve( int n, int m ) { if( m==n ) return 0; if( m==0 ) return ( Math.pow( 2, n+1 ) - 2 ); else { double res = 1 + ( Double )( solve( n, m+1 ) + solve( n, 0 ))/2; return res; } } public static void main( String[] args ) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader( System.in )); int n, m; int t = Integer.parseInt( br.readLine() ); StringTokenizer tok; String s; for( int T=0; T<t; T++ ) { s = br.readLine(); tok = new StringTokenizer( s ); n = Integer.parseInt( tok.nextToken() ); m = Integer.parseInt( tok.nextToken() ); DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); System.out.println( df.format ( solve( n, m ) )); } } }

    Read the article

  • C#: Wrong answer when finding "cool" numbers.

    - by user300484
    Hello you all! In my application, a "cool" number is a number that is both a square and a cube, like for example: 64 = 8^2 and 64 = 4^3. My application is supposed to find the number of "cool numbers" between a range given by the user. I wrote my code and the application runs fine, but it is giving me the wrong answer. Can you help me here please? for example: IMPUT 1 100 OUTPUT 1 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { double a = Convert.ToDouble(Console.ReadLine()); // first number in the range double b = Convert.ToDouble(Console.ReadLine()); // second number in the range long x = 0; for (double i = a; i <= b; i++) { double cube = 1.0 / 3.0; double cuad = 1.0 / 2.0; double crt = Math.Pow(i, cube); // cube root double sqrt = Math.Pow(i, cuad); // square root if ((crt * 10) % 10 == 0 || (sqrt * 10) % 10 == 0) // condition to determine if it is a cool number. x++; } Console.WriteLine(x); Console.ReadLine(); } } }

    Read the article

  • Why does the answer print out twice?

    - by rEgonicS
    I made a program that returns the product a*b*c where a,b,c are pythagorean triples and add up to 1000. The program does output the correct answer but does it twice. I was curious as to why this is so.After playing around with it a bit I found out that it prints out when a = 200 b = 375 c = 425. And once again when a = 375 b = 200 c = 425. *How do you put your code into a "code" block? It does it automatically for part of the code but as you can see the top portion and bottom line is left out. bool isPythagTriple(int a, int b, int c); int main() { for(int a = 1; a < 1000; a++) { for(int b = 1; b < 1000; b++) { for(int c = 1; c < 1000; c++) { if( ((a+b+c)==1000) && isPythagTriple(a,b,c) ) { cout << a*b*c << " "; break; } } } } return 0; } bool isPythagTriple(int a, int b, int c) { if( (a*a)+(b*b)-(c*c) == 0 ) return true; else return false; }

    Read the article

  • Displaying pic for user through a question's answer

    - by bgadoci
    Ok, I am trying to display the profile pic of a user. The application I have set up allows users to create questions and answers (I am calling answers 'sites' in the code) the view in which I am trying to do so is in the /views/questions/show.html.erb file. It might also be of note that I am using the Paperclip gem. Here is the set up: Associations Users class User < ActiveRecord::Base has_many :questions, :dependent => :destroy has_many :sites, :dependent => :destroy has_many :notes, :dependent => :destroy has_many :likes, :through => :sites , :dependent => :destroy has_many :pics, :dependent => :destroy has_many :likes, :dependent => :destroy end Questions class Question < ActiveRecord::Base has_many :sites, :dependent => :destroy has_many :notes, :dependent => :destroy has_many :likes, :dependent => :destroy belongs_to :user end Answers (sites) class Site < ActiveRecord::Base belongs_to :question belongs_to :user has_many :notes, :dependent => :destroy has_many :likes, :dependent => :destroy has_attached_file :photo, :styles => { :small => "250x250>" } end Pics class Pic < ActiveRecord::Base has_attached_file :profile_pic, :styles => { :small => "100x100" } belongs_to :user end The /views/questions/show.html.erb is rendering the partial /views/sites/_site.html.erb which is calling the Answer (site) with: <% div_for site do %> <%=h site.description %> <% end %> I have been trying to do things like: <%=image_tag site.user.pic.profile_pic.url(:small) %> <%=image_tag site.user.profile_pic.url(:small) %> etc. But that is obviously wrong. My error directs me to the Questions#show action so I am imagining that I need to define something in there but not sure what. Is is possible to call the pic given the current associations, placement of the call, and if so what Controller additions do I need to make, and what line of code will call the pic? UPDATE: Here is the QuestionsController#show code: def show @question = Question.find(params[:id]) @sites = @question.sites.all(:select => "sites.*, SUM(likes.like) as like_total", :joins => "LEFT JOIN likes AS likes ON likes.site_id = sites.id", :group => "sites.id", :order => "like_total DESC") respond_to do |format| format.html # show.html.erb format.xml { render :xml => @question } end end

    Read the article

  • async_write/async_read problems while trying to implement question-answer logic

    - by Max
    Good day. I'm trying to implement a question - answer logic using boost::asio. On the Client I have: void Send_Message() { .... boost::asio::async_write(server_socket, boost::asio::buffer(&Message, sizeof(Message)), boost::bind(&Client::Handle_Write_Message, this, boost::asio::placeholders::error)); .... } void Handle_Write_Message(const boost::system::error_code& error) { .... std::cout << "Message was sent.\n"; .... boost::asio::async_read(server_socket_,boost::asio::buffer(&Message, sizeof(Message)), boost::bind(&Client::Handle_Read_Message, this, boost::asio::placeholders::error)); .... } void Handle_Read_Message(const boost::system::error_code& error) { .... std::cout << "I have a new message.\n"; .... } And on the Server i have the "same - logic" code: void Read_Message() { .... boost::asio::async_read(client_socket, boost::asio::buffer(&Message, sizeof(Message)), boost::bind(&Server::Handle_Read_Message, this, boost::asio::placeholders::error)); .... } void Handle_Read_Message(const boost::system::error_code& error) { .... std::cout << "I have a new message.\n"; .... boost::asio::async_write(client_socket_,boost::asio::buffer(&Message, sizeof(Message)), boost::bind(&Server::Handle_Write_Message, this, boost::asio::placeholders::error)); .... } void Handle_Write_Message(const boost::system::error_code& error) { .... std::cout << "Message was sent back.\n"; .... } Message it's just a structure. And the output on the Client is: Message was sent. Output on the Server is: I have a new message. And that's all. After this both programs are still working but nothing happens. I tried to implement code like: if (!error) { .... } else { // close sockets and etc. } But there are no errors in reading or writing. Both programs are just running normally, but doesn't interact with each other. This code is quite obvious but i can't understand why it's not working. Thanks in advance for any advice.

    Read the article

  • MS Access 2003 - Message Box: How can I answer "ok" automatically through code

    - by Justin
    So a couple silly questions: If I include this in some event: MsgBox " ", vbOkOnly, "This little message box" could I then with some more code turn around and 'click the ok button. So that basically the message boox automatically pops up, and then automatically goes away? I know its silly because you want to know, why do you want the message box then..... well a) i just want to know if you can do that, and what would be the command b) i have some basic shapes (shape objects) that are made visible when the message box appears. But without having the message box there, there is no temporary disruption of code while waiting for the button to be clicked, and therefor those pretty image objects being made visible does take effect on the the form. So I really do not need the message box, just the temp disruption that shows the objects. Thanks!

    Read the article

  • MySQL "OR MATCH" hangs (long pause with no answer) on multiple tables

    - by Kerry
    After learning how to do MySQL Full-Text search, the recommended solution for multiple tables was OR MATCH and then do the other database call. You can see that in my query below. When I do this, it just gets stuck in a "busy" state, and I can't access the MySQL database. SELECT a.`product_id`, a.`name`, a.`slug`, a.`description`, b.`list_price`, b.`price`, c.`image`, c.`swatch`, e.`name` AS industry, MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) AS relevance FROM `products` AS a LEFT JOIN `website_products` AS b ON (a.`product_id` = b.`product_id`) LEFT JOIN ( SELECT `product_id`, `image`, `swatch` FROM `product_images` WHERE `sequence` = 0) AS c ON (a.`product_id` = c.`product_id`) LEFT JOIN `brands` AS d ON (a.`brand_id` = d.`brand_id`) INNER JOIN `industries` AS e ON (a.`industry_id` = e.`industry_id`) WHERE b.`website_id` = %d AND b.`status` = %d AND b.`active` = %d AND MATCH( a.`name`, a.`sku`, a.`description` ) AGAINST ( '%s' IN BOOLEAN MODE ) OR MATCH ( d.`name` ) AGAINST ( '%s' IN BOOLEAN MODE ) GROUP BY a.`product_id` ORDER BY relevance DESC LIMIT 0, 9 Any help would be greatly appreciated.

    Read the article

  • How would you answer Joel's sample programming questions?

    - by Khorkrak
    I recently interviewed a candidate for a new position here. I wish though that I'd read Joel's Guerrilla Guide to Interviewing prior to that interview - naturally I happened upon it the night afterwards :P http://www.joelonsoftware.com/articles/GuerrillaInterviewing3.html So I tried answering the easy questions myself - yeah I used the python interpreter to type stuff in and tested the results a bit - I didn't look up any solutions beforehand though and I also thought about how long it took me to come up with answers for each one and what I'd look for the next time I interview someone. I'd let them type stuff into the interpreter and see how did used python's introspection capabilities too to find out things like what's the re module's method for building a regex etc. Here are my answers - these are in python of course - what are yours in your favourite language? Do you see any issues with the answers I came up with - i.e. how could they be improved upon - what did I miss? Joel's example questions: Write a function that determines if a string starts with an upper-case letter A-Z. import re upper_regex = re.compile("^[A-Z]") def starts_with_upper(text): return upper_regex.match(text) is not None Write a function that determines the area of a circle given the radius. from math import pi def area(radius): return pi * radius**2 Add up all the values in an array. sum([1, 2, 3, 4, 5]) Harder Question: Write an example of a recursive function - so how about the classic factorial one: def factorial(num): if num > 1: return num * factorial(num - 1) else: return 1

    Read the article

  • Optimized Publish/Subcribe JMS Broker Cluster and Conflicting Posts on StackOverFlow for the Answer

    - by Gene
    Hi, I am looking to build a publish/subscribe distributed messaging framework that can manage huge volumes of message traffic with some intelligence at the broker level. I don't know if there's a topology that describes this, but this is the model I'm going after: EXAMPLE MODEL A A) There are two running message brokers (ideally all on localhost if possible, for easier demo-ing) : Broker-A Broker-B B) Each broker will have 2 listeners and 1 publisher. Example Figure [subscriber A1, subscriber A2, publisher A1] <-- BrokerA <-- BrokerB <-- [publisher B1, subscriber B1, subscriber B2] IF a message-X is published to broker A and there no subscribers for it among the listeners on Broker-B (via criteria in Message Selectors or Broker routing rules), then that message-X will never be published to Broker-B. ELSE, broker A will publish the message to broker B, where one of the broker B listeners/subscribers/services is expecting that message based on the subscription criteria. Is Clustering the Correct Approach? At first, I concluded that the "Broker Clustering" concept is what I needed to support this. However, as I have come to understand it, the typical use of clustering entails either: message redundancy across all brokers ... or Competing Consumers pattern ... and neither of these satisfy the requirement in the EXAMPLE MODEL A. What is the Correct Approach? My question is, does anyone know of a JMS implementation that supports the model I described? I scanned through all the stackoverflow post titles for the search: JMS and Cluster. I found these two informative, but seemingly conflicting posts: Says the EXAMPLE MODEL A is/should-be implicitly supported: http://stackoverflow.com/questions/2255816/jms-consumer-with-activemq-network-of-brokers " this means you pick a broker, connect to it, and let the broker network sort it out amongst themselves. In theory." Says the EXAMPLE MODEL A IS NOT suported: http://stackoverflow.com/questions/2017520/how-does-a-jms-topic-subscriber-in-a-clustered-application-server-recieve-message "All the instances of PropertiesSubscriber running on different app servers WILL get that message." Any suggestions would be greatly appreciated. Thanks very much for reading my post, Gene

    Read the article

  • Ruby Gem Install question + answer(on windows vista Home Basic environment)

    - by Vamsi
    Recently I am having problems with installing rcov gem on my windows (vista Home Basic environment), so after googling I found one solution and that is gem install rcov -v 0.8.1.1.0 #version that installs without errors gem update rcov #update to the latest version, in my case rcov-0.8.1.2.0-x86-mswin32 But this solution didn't worked on my colleague's system (windows xp) and after that we came to know about RubyInstaller devkit for winddows But that dev kit is not working on my vista, when I tried gem install rcov in my command prompt, it game me this error, C:\Users\Vamsi>gem install rcov Building native extensions. This could take a while... ERROR: Error installing rcov: ERROR: Failed to build gem native extension.ERROR: Failed to build gem native extension. D:/Spritle/Programs/Ruby/bin/ruby.exe extconf.rb creating Makefile nmake 'nmake' is not recognized as an internal or external command, operable program or batch file. Gem files will remain installed in D:/Spritle/Programs/Ruby/lib/ruby/gems/1.8/ge ms/rcov-0.9.8 for inspection. Results logged to D:/Spritle/Programs/Ruby/lib/ruby/gems/1.8/gems/rcov-0.9.8/ext /rcovrt/gem_make.out So after that my colleague tried to install nmake as well but it was throwing some other error. Can some one suggest a better solution for solving this problems for all windows environments? I am aware of cygwin for windows but I am not sure that is an 100% solution either.

    Read the article

  • Why does multiplying a double by -1 not give the negative of the current answer

    - by Ankur
    I am trying to multiply a double value by -1 to get the negative value. It continues to give me a positive value double man = Double.parseDouble(mantissa); double exp; if(sign.equals("plus")){ exp = Double.parseDouble(exponent); } else { exp = Double.parseDouble(exponent); exp = exp*-1; } System.out.println(man+" - "+sign+" - "+exp); The printed result is 13.93 - minus - 2.0 which is correct except that 2.0 should be -2.0

    Read the article

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