Search Results

Search found 1251 results on 51 pages for 'nick forge'.

Page 40/51 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • How can I merge several hashes into one hash in Perl?

    - by Nick
    In Perl, how do I get this: $VAR1 = { '999' => { '998' => [ '908', '906', '0', '998', '907' ] } }; $VAR1 = { '999' => { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } }; $VAR1 = { '999' => { '996' => [] } }; $VAR1 = { '999' => { '995' => [] } }; $VAR1 = { '999' => { '994' => [] } }; $VAR1 = { '999' => { '993' => [] } }; $VAR1 = { '999' => { '997' => [ '986', '987', '990', '984', '989', '988' ] } }; $VAR1 = { '995' => { '101' => [] } }; $VAR1 = { '995' => { '102' => [] } }; $VAR1 = { '995' => { '103' => [] } }; $VAR1 = { '995' => { '104' => [] } }; $VAR1 = { '995' => { '105' => [] } }; $VAR1 = { '995' => { '106' => [] } }; $VAR1 = { '995' => { '107' => [] } }; $VAR1 = { '994' => { '910' => [] } }; $VAR1 = { '993' => { '909' => [] } }; $VAR1 = { '993' => { '904' => [] } }; $VAR1 = { '994' => { '985' => [] } }; $VAR1 = { '994' => { '983' => [] } }; $VAR1 = { '993' => { '902' => [] } }; $VAR1 = { '999' => { '992' => [ '905' ] } }; to this: $VAR1 = { '999:' => [ { '992' => [ '905' ] }, { '993' => [ { '909' => [] }, { '904' => [] }, { '902' => [] } ] }, { '994' => [ { '910' => [] }, { '985' => [] }, { '983' => [] } ] }, { '995' => [ { '101' => [] }, { '102' => [] }, { '103' => [] }, { '104' => [] }, { '105' => [] }, { '106' => [] }, { '107' => [] } ] }, { '996' => [] }, { '997' => [ '986', '987', '990', '984', '989', '988' ] }, { '998' => [ '908', '906', '0', '998', '907' ] }, { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } ]};

    Read the article

  • Group multiple or statements within an IF in javascript

    - by nick
    The following code works: $(".valClear").each(function () { if ($(this).val().indexOf(".png") == -1) { $(this).val(''); } }); However this doesn't (the value is removed even if it contains .png or .jpeg), what am I doing wrong? $(".valClear").each(function () { if (($(this).val().indexOf(".png") == -1) || ($(this).val().indexOf(".jpeg") == -1)) { $(this).val(''); } });

    Read the article

  • Android HTTP get methods

    - by Nick
    I have written a number of applications for blackberry and am just starting in Android. It seems to me that android has a lot more built in functions. I am starting by recreating some of my BB apps on Android and on one I take a few xml sites and parse them out. On blackberry I implemented this by creating a class that extended a thread. I would construct a new instance of this class with the parameters of my http request and it would call a function back in my main class, sending it the results. I am tempted to reuse my code, but am curious if android has something better built in. I have been looking at the handler class as well as possible using a service. Bascially, I would like to start a new thread that will return a document of a specific url. Thanks!

    Read the article

  • sumList predicate needs to check to see if their Sum is equal to the sum of all the elements in the list

    - by nick bonnet
    I am implementing a method that when given Sum and a List. It will check to see that if you add the elements in the list, their sum is equal to the Sum given. Here is what I am trying to do thus far, but I am pretty sure it is wrong... I'm not really sure how to think about it. sumList([],0). sumList([X|Xrest], Sum) :- sumList[Xrest, Sum1), Sum is X + Sum1. Could you give me a point in the right direction or at least let me know how to try to think about the problem?

    Read the article

  • Number guessing game (3+- guessed result)

    - by Nick Waring
    I've been assigned a task to create a game that generates 4 digits and the user has to guess the digits one at a time to get the correct result. If the number is correct a Y is displayed and if not, a N. This was easy, now the next step was to implement another two responses. If the answer is too high, a H is displayed and too low, an N. Again, was easy - now the third is to use the same design as game 2 but if the number is 3 higher than a H is displayed and same if it's 3 lower than a L is displayed - otherwise an X is displayed. I can't figure out how to do this. Here's my test code for game 2 for just one of the digits - any help is appreciated. (5 was used just for a test.) def guess(): x = 5 g= int(input("Guess the number: ")) if g == x: print("Y") elif g < x: print("L") else: print("H")

    Read the article

  • Array Flatten does not work (Instance variable nil)

    - by Nick
    I was trying to write a simple array flatten method, but it does not work using instance variable. It works only using class variables. Can anyone tell me why? and how to make it work using instance variables. class Array @y = [] def flatten_array self.each do |x| if x.class.to_s != 'Array' @y << x else x.flatten_array end end return @y end end a = [1,2,3,4,5] b = [6,7,8] c = [9,10] a1 = [12,13,a,b,c] puts a1.inspect b1 = a1.flatten_array puts b1.inspect

    Read the article

  • Are function arguments stored in a closure?

    - by Nick Lowman
    I was reading this great article about closures here and the example below outputs 'item3 undefined' three times. I understand why it outputs 'item3' three times as the functions inside buildList() all use the same single closure but why can't it access the 'list' argument? Why is it undefined? Is it because the argument is passed in after the closure has been created? function buildList(list) { var result = []; for (var i = 0; i < list.length; i++) { var item = 'item' + list[i]; result.push( function() {console.log(item + ' ' + list[i])} ); } return result; } function testList() { var fnlist = buildList([1,2,3]); // using j only to help prevent confusion - could use i for (var j = 0; j < fnlist.length; j++) { fnlist[j](); } }

    Read the article

  • How can I create an array of random numbers in C++

    - by Nick
    Instead of The ELEMENTS being 25 is there a way to randomly generate a large array of elements....10000, 100000, or even 1000000 elements and then use my insertion sort algorithms. I am trying to have a large array of elements and use insertion sort to put them in order and then also in reverse order. Next I used clock() in the time.h file to figure out the run time of each algorithm. I am trying to test with a large amount of numbers. #define ELEMENTS 25 void insertion_sort(int x[],int length); void insertion_sort_reverse(int x[],int length); int main() { clock_t tStart = clock(); int B[ELEMENTS]={4,2,5,6,1,3,17,14,67,45,32,66,88, 78,69,92,93,21,25,23,71,61,59,60,30}; int x; cout<<"Not Sorted: "<<endl; for(x=0;x<ELEMENTS;x++) cout<<B[x]<<endl; insertion_sort(B,ELEMENTS); cout <<"Sorted Normal: "<<endl; for(x=0;x<ELEMENTS;x++) cout<< B[x] <<endl; insertion_sort_reverse(B,ELEMENTS); cout <<"Sorted Reverse: "<<endl; for(x=0;x<ELEMENTS;x++) cout<< B[x] <<endl; double seconds = clock() / double(CLK_TCK); cout << "This program has been running for " << seconds << " seconds." << endl; system("pause"); return 0; }

    Read the article

  • Changing a Widget's name based on a string read in from an XML form in Qt.

    - by Nick
    I'm writing a code for a voting machine that will allow user to read in custom XML ballots and then vote on them, however in the current build I have in QtCreator, I don't see an easy way to edit buttons in my GUI directly. In the code snippet below, I assign an element to pull out the names and type of ballot being read in, but I need to append a label on the GUI as well as change buttons to the names of candidates read in. Any ideas on how to do this? while(!n.isNull()){ QDomNode x = n.firstChildElement(); QDomElement e = n.toElement(); QMessageBox::information(0, tr( "Loading Element" ), tr( "Our element is %1" ).arg(e.tagName()) ); QDomElement p = x.firstChildElement();//p finds Races QMessageBox::information(0,tr("Foo"),tr("p = %1").arg(p.text()));//finds Race and Ballot types n = n.nextSibling(); } }

    Read the article

  • Does anybody know of a USB Postage Scale that's Linux compatible?

    - by Nick
    I'm looking for a postage scale that already has linux support (drivers, etc) for a shipping system that I'm working on. I'm planning to use Ubuntu 9.04, but I am willing to switch distro's for compatibility. Does anybody know of any scales that currently work? Is there an open source project that's working on scale drivers or similar? Thanks!

    Read the article

  • Recomendations for Creating a Picture Slide Show with Super-Smooth Transitions (For Live Presentaito

    - by Nick
    Hi everyone, I'm doing a theatrical performance, and I need a program that can read images from a folder and display them full screen on one of the computer's VGA outputs, in a predetermined order. All it needs to do is start with the first image, and when a key is pressed (space bar, right arrow), smoothly cross-fade to the next image. Sounds just like power-point right? The only reason why I can use power-point/open-office is because the "fade smoothly" transition isn't smooth enough, or configurable enough. It tends to be fast and choppy, where I would like to see a perfectly smooth fade over, say, 30 seconds. So the question is what is the best (cheap and fast) way to accomplish this? Is there a program that already does this well (for cheap or free)? OR should I try to hack at open-office's transition code? Or would it be easier to create this from scratch? Are there frameworks that might make it easier? I have web programming experience (php), but not desktop or real-time rendering. Any suggestions are appreciated!

    Read the article

  • How do I escape a new line character in a .ini file so that Zend_Config_Ini reads it literally?

    - by Nick
    I am trying to store a multiple line e-mail in an ini file using PHP/Zend Framework. My string has new lines characters in it, and when I use Zend_Config_Ini to parse the ini file, the new line characters come back escaped, so they are printed out on screen, instead of a line feed. Example: // ini file message = Hi {0},\n\nThis is a test message.\nGoodbye! is parsed by Zend_Config_Ini as: Hi {0},\\n\\nThis is a test message.\\nGoodbye! which then is printed out in the email as: Hi John,\n\nThis is a test message.\nGoodbye! Instead I want the e-mail to look like this: Hi John, This is a test message. Goodbye! Does anybody know how to achieve this? Thanks!

    Read the article

  • Why doesn't AJAX History work in IE7 as it does in IE8 and every other browser?

    - by Nick
    I have two ASP.NET pages, say page1 and page2. Page1 contains an update panel and I use AJAX History to allow browser back/forward button support. Users can navigate to page2 via page1 - I do a response.redirect server-side so that I can store in a session what options were on page1 when they left. On page2, a user can click the back button and return to page1 with it displaying what was there prior to navigating to page2. You can click the back button again on page1 to go back to other selectively chosen history states. This all works great in IE8, Firefox, Safari, and Chrome. However, in IE7 it doesn't. The user can get back to page1 from page2, but when they click the back button again it doesn't show the previous states of page1 - it displays the original page load content. The history data looks to still be encoded in the url when using ie7 but is not working for some reason. Does anyone know why this is happening in IE7 and how I can get around this? It really needs to work in IE7 as most of our users are on IE7. Please help.

    Read the article

  • Problem in the Android documentation

    - by Nick
    Hi all, This is my first post ever -- I love the Android SDK (been at it for a week), but I did notice a small typo in the official documentation that needs correcting. Not sure if this is where I post it, but on this page: http://developer.android.com/reference/android/os/CountDownTimer.html within the example source code, the source says "CountdownTimer" on line one when it should say "CountDownTimer" (notice the capitalization of the letter "D"). An easy fix for one with programming experience, but the code as written will not compile, which could be confusing for someone using this code for the first time. Is this where documentation bugs are submitted, and if not, where should I go to request the fix? Thanks all!

    Read the article

  • Calculations coming out to 0.0?

    - by Nick Gibson
    A simple percentage calculation. It wont return a value except 0.0 and I think once or twice it returned 100.0%. Other than that it won't do a thing. I have tried playing with the code in several different ways and it just wont work. for (int loop = 1; loop < loopCount; loop++) { aa = r.nextInt(10+1); abc = (int) aa; String[] userAnswer = new String[x]; int totalQues = (correctAnswer + wrongAnswer), actualQues = (totalQues - 1); if(abc < x) { userAnswer[abc] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]+"\nCorrect Answers: "+correctAnswer+"\nWrong Answers: "+wrongAnswer+"\nTotal Questions: "+totalQues); if(userAnswer[abc].equals(answers[abc])) { correctAnswer++; } else { wrongAnswer++; }//else if(actualQues == x); { score = (correctAnswer / actualQues) * 100; JOptionPane.showMessageDialog(null,"The test is finished."); JOptionPane.showMessageDialog(null,"You scored "+score+"%"); }//if }//if }//for

    Read the article

  • AJAX Closures and targeting 'this'

    - by Nick Lowman
    In the code example below the success callback function logs 'input#04.update' four times rather than each individual input, which makes sense seeing how closures work but how would I go about targeting each individual input using this. <input type="text" name="" id="01" class="update"> <input type="text" name="" id="02" class="update"> <input type="text" name="" id="03" class="update"> <input type="text" name="" id="04" class="update"> function updateFields(){ $('input.update').each(function(){ $this = $(this); $.ajax({ data: 'id=' + this.id, success: function(resp){ console.log($this); $this.val(resp) } }); }); }

    Read the article

  • How do I find everything between two characters after a word using grep, without outputting the entire line?

    - by Nick Sweeting
    I am downlading the info.0.json file from xkcd and trying to parse just the alt text. I don't care if there are quotes around it or not. The problem it that the info.0.json file is all one line, and the alt text is in quotes after the word "alt=". Trying cat info.0.json | grep alt just returns the whole file (because it's all one line). What is the grep or sed code that will get me the alt text?

    Read the article

  • nested has_many

    - by Nick Vanderbilt
    I am using Rails 2.3.5. Class User < ActiveRecord::Base has_many :phones end class Phone < ActiveRecord::Base has_many :frequency_bands end I want to get all the frequency_bands for a user. I know I can write a method def freq_bands for User but I would like to know if it is possible to have has_many freq_bands for a User. In this way I can chain the call. What I would like to have is class User < ActiveRecor::Base has_many :frequence_bands, :through => phones end I think it is possible to have nested has_many using this plugin http://github.com/ianwhite/nested_has_many_through However if possible I would like to avoid using another plugin and rely solely on rails.

    Read the article

  • Where is the best place to store globals in Rails app?

    - by Nick Gorbikoff
    Hello. I was wondering if there is the best practice on where to store global settings in a rails app. What I mean by that is i.e: I have a few globals defined that may change, but not likely and it seems inappropriate to store them in DB since they are used so much. For instance I have SYSTEM_EMAIL & SYSTEM_EMAIL_SIGNATURE & SYSTEM_STORAGE_ROOT. Right now I keep them in environment.rb, but I'm not sure if this is the right palce to store them. Thank you

    Read the article

  • Help with getting data from resized image.

    - by nick
    I'm using an ASP.NET file upload control and then resizing an image and storing the new image in a new Bitmap. Here is the code I have so far: protected void ResizeImage() { Bitmap originalBMP = new Bitmap(FileUpload1.FileContent); //Calculate new image dimensions int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; int sngRatio = origWidth / origHeight; int newWidth = 100; int newHeight = newWidth / sngRatio; Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); } I'm uploading directly to Amazon S3 and I need to pass some data to its upload method. How do I get the following information from my new bitmap that I have been using with the fileupload?: FileUpload1.FileBytes FileUpload1.FileBytes.Length Do I need to save my new bitmap to a stream so I can get an array of bytes?

    Read the article

  • CSS: background:#252 or background-color:#252? will the first cause the browser to assume the same a

    - by nick
    if for a class i include "background:#252", the browser will assume the rest of the background properties that i didn't specify. If instead I used "background-color:#252", would it cause the browser to assume the exact same about the rest of the background properties that i leave unspecified? background:#252 is shorter, but i wonder if it would be better to use background-color:#252? thanks.

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >