Search Results

Search found 2761 results on 111 pages for 'sequence generators'.

Page 37/111 | < Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >

  • Is there a way to undo Mocha stubbing of any_instance?

    - by Steve Weet
    Within my controller specs I am stubbing out valid? for some routing tests, (based on Ryan Bates nifty_scaffold) as follows :- it "create action should render new template when model is invalid" do Company.any_instance.stubs(:valid?).returns(false) post :create response.should render_template(:new) end This is fine when I test the controllers in isolation. I also have the following in my model spec it "is valid with valid attributes" do @company.should be_valid end Again this works fine when tested in isolation. The problem comes if I run spec for both models and controllers. The model test always fails as the valid? method has been stubbed out. Is there a way for me to remove the stubbing of any_instance when the controller test is torn down. I have got around the problem by running the tests in reverse alphabetic sequence to ensure the model tests run before the controllers but I really don't like my tests being sequence dependant.

    Read the article

  • Maximum number of bytes that can be sent on a TCP connection

    - by iamrohitbanga
    I initially assumed that since tcp has a sequence number field of 32 bits and each byte sent on a tcp connection is labeled with a unique number, maximum number of bytes that can be sent on a tcp connection is about 2^32-1 or 2^32-2 (which?). but now I feel that since TCP is a sliding window protocol, the wraparound of sequence numbers during the connection should not have an affect on the maximum number of bytes that can be sent over a tcp connection as long as the when wraparound occurs the old packet is no longer in the network (it is sent after 2*MSL). What is the correct answer?

    Read the article

  • How to convert list into a string?

    - by PARIJAT
    I have extracted some data from the file and want to write it in the file 2 but the program says 'sequence item 1: expected string, list found', I want to know how I can convert buffer[] i.e. string into sequence, so that it could be saved in file 2. file = open('/ddfs/user/data/k/ktrip_01/hmm.txt','r') file2 = open('/ddfs/user/data/k/ktrip_01/hmm_write.txt','w') buffer = [] rec = file.readlines() for line in rec : field = line.split() print '>',field[0] term = field[0] buffer.append(term) print field[1], field[2], field[6], field[12] term1 = field [1] buffer.append(term1) term2 = field[2] buffer.append[term2] term3 = field[6] buffer.append[term3] term4 = field[12] buffer.append[term4] file2.write(buffer) file.close() file2.close()

    Read the article

  • UML and Documenting Simple Diagrams

    - by Jason
    As part of a rewrite of an old Java application into C#, I'm writing an actual Software Design Specification. A problem I run into is when a method is too simple to bother with a Sequence Diagram (it doesn't interact with other objects). As an example, I have a simple POJO called Item, containing the following method: public String getCategoryKey() { StringBuffer value = new StringBuffer("s-"); value.append(this.getModelID()); value.append("-c"); return value; } The purpose and the algorithm for the method needs to be documented. However, a sequence diagram is overkill. How would others document it? (I take no credit/blame for the given method, it's very old code and the author "forgot" to put their name in the Javadoc).

    Read the article

  • Need help with a Linq XML conditional grouping query

    - by FiveTools
    I have the following xml fragment: <BANNER ID="Banner 2" ROW_WIDTH="200"> <BANNER_TEXTS ID="BANNER_TEXTS"> <BANNER_TEXT UNDERLINE="false" SPAN_COL="1" WIDTHT="78px"></BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT="234px">Years In Practice</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT="234px">Internet Usage</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="4" WIDTHT="312px">Sales Reps Seen / Week</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT="234px">Prescription Volume</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT="222px">Patient Load</BANNER_TEXT> </BANNER_TEXTS> <BANNER_TEXTS ID="COLUMN_TEXTS"> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">Total</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">&#60; 11 years</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">11-20 years</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">21-30 years</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">Light 1-5 hrs</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">Medium 6-10 hrs</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">Heavy &#62;10 hrs</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">0</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">1-2</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">3-5</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">&#62;5</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">1-100</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">101-150</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="78px">&#62;150</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="74px">1-100</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="74px">101-200</BANNER_TEXT> <BANNER_TEXT UNDERLINE="true" SPAN_COL="1" WIDTHT="74px">&#62;200</BANNER_TEXT> </BANNER_TEXTS> <BANNER_TEXTS ID="COLUMN_TEXTS"> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(A)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(B)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(C)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(D)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(E)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(F)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(G)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(H)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(I)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(J)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(K)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(L)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(M)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(N)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(O)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(P)</COLUMN_TEXT> <COLUMN_TEXT UNDERLINE="false" SPAN_COL="1">(Q)</COLUMN_TEXT> </BANNER_TEXTS> </BANNER> I would like to group all the 'BANNER_TEXT' in the second sequence using the first sequence 'BANNER_TEXT' as the key (only include elements where string is not null or empty). The span_col attribute in the first 'BANNER_TEXT' sequence indicates which elements by position in the 2nd sequence are related. An example: 'Years in Practice' would be the first key and the attribute SPAN_COL=3 for that element indicates it would contain '< 11 years', '11-20 years', '21-30 years' (the first grouping of string.empty = Total would be skipped).

    Read the article

  • What did I do wrong with this function?

    - by Felipe Galdino Campos
    I don't know what I did - it's wrong . Can someone help me? def insert_sequence(dna1, dna2, number): '''(str, str, int) -> str Return the DNA sequence obtained by inserting the second DNA sequence at the given index. (You can assume that the index is valid.) >>> insert_sequence('CCGG', 'AT', 2) 'CCATGG' >>> insert_sequence('TTGC', 'GG', 2) 'TTGGGC' ''' index = 0 result = ''; for string in dna1: if index == number: result = result + dna2 result = result + string index += 1 print(result)

    Read the article

  • Creating a bouncing button in flex

    - by Yasmine
    I am trying to make an effect on a button that when I mouse over it, it keeps jumping up and down smoothly and when mouse out it stops. I tried this but the result was really bad: <mx:Sequence id="bounceEffect" repeatCount="0"> <mx:Move duration="2000" yBy="10" easingFunction="{Bounce.easeOut}"/> <mx:Move duration="2000" yBy="-10" easingFunction="{Bounce.easeOut}"/> </mx:Sequence> <mx:Button id="btn" label="Request Information" rollOver="bounceEffect.play([btn])" rollOut="bounceEffect.end()" fillColors="[#ff0000, #ff0000, #ff0000, #ff0000]" color="#ffffff" textRollOverColor="#ffffff" /> Can someone help me on this? There's something else I noticed when I mouse over the button and during the effect the text on the button becomes very hazy. Thanks

    Read the article

  • Byte order (endian) of int in NSLog?

    - by Eonil
    NSLog function accepts printf format specifiers. My question is about %x specifier. Does this print hex codes as sequence on memory? Or does it have it's own printing sequence style? unsigned int a = 0x000000FF; NSLog(@"%x", a); Results of above code on little or big endian processors are equal or different? And how about NSString's -initWithFormat method? Does it follows this rule equally?

    Read the article

  • Removing Duplicates in an array in C

    - by LuckySlevin
    The question is a little complex. The problem here is to get rid of duplicates and save the unique elements of array into another array with their original sequence. For example : If the input is entered b a c a d t The result should be : b a c d t in the exact state that the input entered. So, for sorting the array then checking couldn't work since I lost the original sequence. I was advised to use array of indices but I don't know how to do. So what is your advise to do that?

    Read the article

  • .NET Neural Network or AI for Future Predictions

    - by Ian
    Hi All. I am looking for some kind of intelligent (I was thinking AI or Neural network) library that I can feed a list of historical data and this will predict the next sequence of outputs. As an example I would like to feed the library the following figures 1,2,3,4,5 and based on this, it should predict the next sequence is 6,7,8,9,10 etc. The inputs will be a lot more complex and contain much more information. This will be used in a C# application. If you have any recommendations or warning that will be great. Thanks

    Read the article

  • Does AsEnumerable() cache all result (LINQ)

    - by Akshay
    When we call a query operator on a sequence, a sequence-specific operator gets called. I mean if i call Where<>() operator on IEnumerable<>, the operator that will be called will be defined in Enumerable class and if it's called on IQueryable<>, the one defined in Queryable class will be called. Consider the operator Reverse, defined in the Enumerable class. If i want to call it on Iqueryable<> then I must use the AsEnumerable<>() operator to first convert it into IEnumerable<>. db.Countries.OrderBy(cntry=>cntry.CountryName).AsEnumerable().Reverse() But the Reverse operator got to have all records at the same time so that it can reverse them. In the above code do all the records get loaded in memory first and then the Reverse() operator is reversing it ?

    Read the article

  • can i write a schema that all XML are valid to it ?

    - by Gady
    Hi, i need to write a schema that all xml instances are valid to it. i tried: <xs:element name="Arguments"> <xs:complexType> <xs:sequence> <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> </xs:sequence> </xs:complexType> but it enforces a root element named Arguments. is there a way for the root to be Any ?

    Read the article

  • What happens to an instance of ServerSocket blocked inside accept(), when I drop all references to i

    - by Hanno Fietz
    In a multithreaded Java application, I just tracked down a strange-looking bug, realizing that what seemed to be happening was this: one of my objects was storing a reference to an instance of ServerSocket on startup, one thread would, in its main loop in run(), call accept() on the socket while the socket was still waiting for a connection, another thread would try to restart the component under some conditions, the restart process missed the cleanup sequence before it reached the initialization sequence as a result, the reference to the socket was overwritten with a new instance, which then wasn't able to bind() anymore the socket which was blocking inside the accept() wasn't accessible anymore, leaving a complete shutdown and restart of the application as the only way to get rid of it. Which leaves me wondering: with no references left to the ServerSocket instance, what would free the socket for a new connection? At what point would the ServerSocket become garbage collected? In general, what are good practices I can follow to avoid this type of bug?

    Read the article

  • jquery background image fade

    - by Nick
    I am using jQuery to load ina background image that fills the page width / height. I have the following in the Head: $(document).ready(function() { $('body').css({ 'background-image' : 'url({HTML_BASE}images/backgrounds/randoms/{BACK_IMG})', 'background-repeat' : 'no-repeat', 'background-position' : 'center top', 'background-attachment': 'fixed', 'background-size': '100% 100%', }); $('#home-promo').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: 'auto' }); $('.model-search').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '393' }); }); This works fine and can be seen at http://projects.snowshtechnologies.com/golden_dragon/home/ I want the BG image to fade in from the black background colour. I have looked at a few other threads on Stack that suggest its not possible as a body element defined in css, but in this scenario the BG image is being loaded in by jQuery. How would I go about adding a fade in to this code to bring the image in with a nice fadein?

    Read the article

  • sql server bulk copy out/postgres copy from infile

    - by Chris Curvey
    I'm starting a conversion of a system from MS SQL Server to Postgres. I have the table structures converted, and I use "bcp" to get the data out of SQL Server. ERROR: invalid byte sequence for encoding "UTF8": 0x80 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". CONTEXT: COPY cm_outgoing, line 200: "200 c:\temp\200.xml 2009-10-10 01:50:44.000 1900-01-01 00:00:00.000" I've already used "sed" to get rid of the NUL (0x00) entries in the file, and I can't find any instances of 0x80 in the file that I'm trying to import. Any thoughts? Is there an easier way?

    Read the article

  • How to get the next prefix in C++?

    - by Vicente Botet Escriba
    Given a sequence (for example a string "Xa"), I want to get the next prefix in order lexicographic (i.e "Xb"). As I don't want to reinvent the wheel, I'm wondering if there is any function in C++ STL or boost that can help to define this generic function easily? If not, do you think that this function can be useful? Notes The next of "aZ" should be "b". Even if the examples are strings, the function should work for any Sequence. The lexicographic order should be a template parameter of the function.

    Read the article

  • Controlling rsync with Python?

    - by Cheesemold
    I've been wanting to write a python script that would run several instances of rsync in sequence for backing up data to a different computer. At the moment I just have this text file with the commands I use and I've just been copy-pasting them into the terminal, and it seems kinda silly. I want to be able to use python to do this for me. I know very vaguely how to use subprocess.popen, but I have no clue how to get python to interact with rsync directly, like for entering my password for me. Can python do that? Something like: if theProccess.proccessResponse == "Password:" : theProccess.respond(string) Or is the best that I can do is just have it, or even a bash script, just run the rsyncs in sequence and have to type my password in over and over again? Thanks in advance.

    Read the article

  • C# Console Application Output to .csv file

    - by Zinn
    I am trying to make a program that will show the numbers: 1, 10 +30 2, 40 (the scale goes up in this pattern by adding 20 to the last number added) 3, 90 +50 4, 160 5, 250 +70 So far I have this code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;// namespace Myloop { class Program { static void Main(string[] args) /// </summary> { StreamWriter myOutputStream = new StreamWriter("loopdata.csv"); int forloop; for (forloop = 1; forloop < 21; forloop++) Console.WriteLine(forloop); Console.ReadLine(); myOutputStream.Close(); } } } This is showing the first sequence of numbers 1 - 20, but could anyone give me any guidance how to do the other sequence next to it in the console application and how I can output these to a .csv file, as the information I have so far doesn't appear in the .csv file

    Read the article

  • AtomicInteger for limited sequnce generation

    - by satish
    How can we use AtomicInteger for limited sequence generation say the sequence number has to be between 1 to 60. Once the sequece reaches 60 it has to start again from 1. I wrote this code though not quite sure wether this is thread safe or not? public int getNextValue() { int v; do { v = val.get(); if ( v == 60) { val.set(1); } } while (!val.compareAndSet(v , v + 1)); return v + 1; }

    Read the article

  • can list be converted into string

    - by PARIJAT
    Actually i have extracted some data from the file and want to write it in the file 2 but the program says 'sequence item 1: expected string, list found', I want to know how i can convert buffer[] ie string into sequence, so that it could be saved in file 2...I am new to the python please help* file = open('/ddfs/user/data/k/ktrip_01/hmm.txt','r') file2 = open('/ddfs/user/data/k/ktrip_01/hmm_write.txt','w') buffer = [] rec = file.readlines() for line in rec : field = line.split() print '>',field[0] term = field[0] buffer.append(term) print field[1], field[2], field[6], field[12] term1 = field [1] buffer.append(term1) term2 = field[2] buffer.append[term2] term3 = field[6] buffer.append[term3] term4 = field[12] buffer.append[term4] file2.write(buffer) file.close() file2.close()

    Read the article

  • Choosing randomly all the elements in the the list just once

    - by Dalek
    How is it possible to randomly choose a number from a list with n elements, n time without picking the same element of the list twice. I wrote a code to choose the sequence number of the elements in the list but it is slow: >>>redshift=np.array([0.92,0.17,0.51,1.33,....,0.41,0.82]) >>>redshift.shape (1225,) exclude=[] k=0 ng=1225 while (k < ng): flag1=0 sq=random.randint(0, ng) while (flag1<1): if sq in exclude: flag1=1 sq=random.randint(0, ng) else: print sq exclude.append(sq) flag1=0 z=redshift[sq] k+=1 It doesn't choose all the sequence number of elements in the list.

    Read the article

  • Are Triggers Based On Queries Atomic?

    - by David
    I have a table that has a Sequence number. This sequence number will change and referencing the auto number will not work. I fear that the values of the trigger will collide. If two transactions read at the same time. I have ran simulated tests on 3 connections @ ~1 million records each and no collisions. CREATE TABLE `aut` ( `au_id` int(10) NOT NULL AUTO_INCREMENT, `au_control` int(10) DEFAULT NULL, `au_name` varchar(50) DEFAULT NULL, `did` int(10) DEFAULT NULL, PRIMARY KEY (`au_id`), KEY `Did` (`did`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 TRIGGER `binc_control` BEFORE INSERT ON `aut` FOR EACH ROW BEGIN SET NEW.AU_CONTROL = (SELECT COUNT(*)+1 FROM aut WHERE did = NEW.did); END;

    Read the article

  • Getting deadlocks in MySQL

    - by at
    We're very frustratingly getting deadlocks in MySQL. It isn't because of exceeding a lock timeout as the deadlocks happen instantly when they do happen. Here's the SQL code that is executing on 2 separate threads (with 2 separate connections from the connection pool) that produces a deadlock: UPDATE Sequences SET Counter = LAST_INSERT_ID(Counter + 1) WHERE Sequence IS NULL Sequences table has 2 columns: Sequence and Counter The LAST_INSERT_ID allows us to retrieve this updated counter value as per MySQL's recommendation. That works perfect for us, but we get these deadlocks! Why are we getting them and how can we avoid them?? Thanks so much for any help with this.

    Read the article

  • Generate HTML pages from some template

    - by Appu
    I have an open-source project for which I have to generate HTML pages to put on the web. I wanted to keep everything as simple HTML pages. The problem with this approach is if I need to change the design, I have to goto all the pages and change it. This will be tough as I have lot of pages. Is there some kind of HTML generators which can process simple annotated text files? This way, I can maintain the documentation and website contents as plain text files and run it through this program to generate static HTML pages. This also helps in keeping the design consistent. Any help would be great!

    Read the article

< Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >