w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I create an Rx sequence by running tasks over original sequence's values?
This seems to work for me so far: public static IObservable<U> Select<T, U> ( this IObservable<T> source, Func<T, CancellationToken, Task<U>> selector) { return source .Select (item => Observable.Defer (() => Observable.StartAsync (ct => selector (item, ct)) .Catch (Observable.Empty<U> ()) )) .Concat (); } We map a deferred task-based exception-swallowing observable to each item, and then concat them. My thought process went like this. I noticed that one of the SelectMany overloads does almost exactly what I wanted and even has exactly the same signature. It didn't satisfy my needs though: it creates tasks as original items come up, whereas I neede

Categories : C#

Microsoft SQL Server 2012 Sequence Not Working - keeps incrementing sequence by 2
The JDBC string I was using was: jdbc:sqlserver://[host]:[port];DatabaseName=[name];selectMethod=cursor;sendStrin‌gParametersAsUnicode=false When I changed the string to: jdbc:sqlserver://[host]:[port];DatabaseName=[name] The sequences returned were as expected: 1, 2, 3, etc

Categories : Sql Server

How to generate sequence id and move table rows up or down and dynamically adjusting each row's sequence ID?
you can do this: $('#add').on("click", function(){ var clone=$('#one tbody input:checked').parent().parent().clone(); clone.each(function(){ $(this).appendTo("#two tbody").attr("id",$(this).index()); }); return false; }); $('#remove').on("click", function(){ $('#two tbody input:checked').parent().parent().remove(); $('#two tbody tr').each(function(){ $(this).attr("id",$(this).index()); }); return false; }); $(".up,.down").click(function(){ var row = $('#two tbody input:checked').parent().parent(); if ($(this).is(".up")) { row.each(function(){ var previndex=$(this).prev().index(); if(previndex>=0){ v

Categories : Javascript

How to fill gaps in a sequence of integers, by choosing the best complementary sequence
Following steps will do it 1) Store the gaps of A, in an array. 2) Then Map each element of A With different B(B1,B2,..) 3) And then display the result, based on the result in the above step This is a brute force approach to solve this problem.

Categories : Algorithm

find the first longest ascending or descending sub-sequence in a given unsorted sequence by C++
Well, for starters, your function will always return true. if (v.size() <1) return false; if (v.size() == 1) cout << v[0] << endl; return true; should probably be if (v.size() <1) { return false; } else if (v.size() == 1) { cout << v[0] << endl; return true; }

Categories : C++

Clojure lazy-sequence where sequence grows from both ends
If all you want is to get n members of an equivalence class, then you could define your function like this instead: (defn range-right-left [x step] (interleave (iterate #(- % step) x) (iterate #(+ % step) (+ x step)))) (take 5 (range-right-left 7 3)) ; => (7 10 4 13 1) (sort (take 5 (range-right-left 7 3))) ; => (1 4 7 10 13) The results aren't in the same order that you had before, but as the example shows you can just use sort once you have your slice of the infinite stream if you really need it in sorted order.

Categories : Clojure

What is the proper sequence of options for gcc & the importance of that sequence?
List libraries last. After compiling, GCC passes files to the linker for linking (unless linking is not to be performed, as happens when you request compilation-only with the -c switch). It passes the files to the linker in the order you list them (or their corresponding inputs) on the command line. You listed -lpthread (which means the pthread library, named libpthread.a or something similar) followed by multi_thread_server.c (which gets compiled to an object file named multi_thread_server.o. So the linker receives the library first, then the object file. When the linker processes a library file, it extracts from it only the modules that supply a definition of a symbol that is needed to satisfy earlier references to the symbol. Since the library is the first file, there are no earlier

Categories : C

Why is Hibernate not using the next sequence value in the sequence table?
I found that my script needs to update the sequence table CREDENTIALS_SEQUENCE. In HSQL that is done as follows: alter sequence credentials_sequence restart with 13; HIBERNATE_SEQUENCES is not used.

Categories : Hibernate

Sequence of group and Sequence of elements
I just tried and it seems to be working as you expect <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="test" xmlns:test="test"> <xs:group name="a_group"> <xs:sequence> <xs:element name="a" type="xs:string" /> </xs:sequence> </xs:group> <xs:group name="b_group"> <xs:sequence> <xs:element name="b" type="xs:string" /> </xs:sequence> </xs:group> <xs:element name="body"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:group ref="test:a_group

Categories : HTML

xpath 2.0: filter sequence using another sequence
Probably context is changing there. So I tried use a variable and it seems to be working. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" indent="yes" /> <xsl:variable name="refs" select="//reference" /> <xsl:variable name="files" select="doc('files.xml')/files/file[path = $refs]" /> <xsl:template match="/"> <files> <xsl:copy-of select="$files" /> </files> </xsl:template> </xsl:stylesheet> This xslt gives a result <?xml version="1.0

Categories : Misc

JPA with Hibernate - Sequence not working with XML
EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); AmmEdGroupTypes newGroup = new AmmEdGroupTypes(); newGroup.setName("test"); entityManager.persist(newGroup); entityManager.getTransaction().commit(); System.out.println(newGroup.getId());

Categories : Java

Hibernate/Oracle Sequence not working
Why are you using xml AND @Annotation at the same time? Maybe xml definition wins against annotation and Hibernate is retriving default sequence instead of your property_seq. Try remove xml mapping and check if it works.

Categories : Java

Regular expression not working when sequence changed
. is not a word character, so  after it would only match if it's followed by a word character. Instead of the last  you could use (?!w), (?!S), B, or even remove it if you aren't picky.

Categories : Regex

Replace char sequence in a string not working
You probably mean: a = a.replace(tmp, tmpWithHttp); instead of: a = a.replace(a, tmpWithHttp); And you don't need to do a contains() check before replacing. String#replace method will replace only if the substring to replace is present. So, you can remove the surrounding if.

Categories : Java

How to map a sequence of discriminated unions (where all items are of the same case) onto a sequence of items of the type of the case?
You are assuming your sequence contains not a single case1, so if this is not true you need to throw an exception. let matchCase item = match item with | Case1 x -> failwith "Unexpected Case1" | Case2 x -> x let case2s = Seq.map matchCase union1s An alternative approach, if you are not sure the sequence contains always the same case is to use an Option let matchCase item = match item with | Case1 x -> None | Case2 x -> Some x Then it depends on how you will handle these cases, you can just filter out the None values using Seq.choose instead of Seq.map as shown on the other answer. Which approach to follow depends if you consider having an argument with Case1s an exceptional case or part of the logic of your program. There was a question regardin

Categories : F#

Get/set current @keyframes percentage/change keyframes
I achieved roughly what I wanted using pure javascript with my CSS3. For my experiment to come up with a way to do these objectives, I created a basic CSS3 animation rotating a circle around a small circular path. My goal was to, when a button was clicked, change the origin of the animation to the new location To achieve the first goal of getting the percentage value of the animation I simply approximated the current percentage using the following setInterval, which displays the approximated current percent. This runs every 40 milliseconds to correspond with the duration of the animation (milliseconds / 100) var result = document.getElementById('result'), currentPercent = 0; var showPercent = window.setInterval(function() { if(currentPercent < 100) { currentPercent += 1; }

Categories : Javascript

What does "" mean?
It means nothing as far as I can tell. The cursor element can take the 4 attributes ( numRows, id, position and maxRows ) and nothing else. Taking out the <xsd:sequence/> would have no effect whatsoever. In general <xsd:sequence> appears around a number of other elements that must appear in the specified order

Categories : Xml

Using SQL Sequence in Asp.net c#
At the basic level, take the nextval part out of quotes. However, PLEASE PLEASE PLEASE parameterize this: cmd.CommandText = @" INSERT INTO TBL_IS (ID,chapter_name,work_priority,description) VALUES (tbl_is_sequence.nextval,:name,:pri,:desc)"; cmd.Parameters.AddWithValue("name", DropDownList3.SelectedValue); cmd.Parameters.AddWithValue("pri", Convert.ToInt32(DropDownList4.SelectedValue)); cmd.Parameters.AddWithValue("desc", TextBox5.Text); cmd.ExecuteNonQuery(); (note, I'm not an Oracle person, and the above is from memory only - but along those lines)

Categories : C#

Sequence of if-else if in C
You shouldn't use else in this case. Code: if (condition) code else if (condition2) code2 Checks if condition is true. If so it executes code. Only if condition is false, condition2 is checked and code2 could be executed.

Categories : C

JS i/o sequence
This explains it pretty well: http://javascript.info/tutorial/events-and-timing-depth#javascript-execution-and-rendering The most important thing being: In most browsers, rendering and JavaScript use single event queue. It means that while JavaScript is running, no rendering occurs. The while loop completely blocks the thread for three seconds. The document.write calls are added to the event queue, maybe even executed, but the paint-event happens after JS is not blocking anymore. If you open Chrome's Developer Tools Timeline, you can see exactly what the browser is doing (https://developers.google.com/chrome-developer-tools/docs/timeline). Off topic: I assume this is test code. In no way should anything like this be used in production. Stacking multiple functions inline within t

Categories : Javascript

@keyframes not working in Firefox
It's not working because you have declared the wrong property. The declaration you need for firefox is just animation. Only Chrome and Safari need the -webkit- prefix for this CSS3 effect. So your code would be: -webkit-animation:slideshow 21s infinite; animation:slideshow 21s infinite; http://www.w3schools.com/css3/css3_animations.asp

Categories : HTML

conditional "next value for sequence"
I think you're thinking about this in the wrong way. You have 3 values and these values are determined by another column. Switch it around, create 3 columns and remove the Counter column. If you have a table with value1, value2 and value3 then the Counter value is implied by the column in which the value resides. Create a unique index on these three columns and add an identity column for a primary key and you're sorted; you can do it all in a stored procedure easily.

Categories : Sql Server

F# sequence comparison
Whilst you may expect that a=b would compare elements for sequences it infact a=b computes reference equality. You can see this with something like seq {1..3} = seq {1..3} which returns false. However, in some cases when you use constants you get confusing results, in particular seq [1;2;3] = seq [1;2;3] returns true, which is confusing. To avoid this issue, you need to do something like let test a b = Seq.fold (&&) true (Seq.zip a b |> Seq.map (fun (aa,bb) -> aa=bb)) to compare element wise. Alternatively, you can use Seq.compareWith as outlined in Gene's answer. However, this requires that the elements also implement a comparison operator as well as equality, which may not be the case for some things like discriminated unions which implement = but not compari

Categories : F#

Is it possible to see the sequence of test run?
If you want to know the sequence in which your test ran you can do the following: A bit of work to do: Add a breakpoint at the start of your method decorated with attribute 'TestMethod'. Right click your breakpoint and select 'When Hit...'. Make sure the checkbox next to 'Print a message' is ticked. Do this for all your test methods. Let Visual Studio do the rest: Debug all your tests by pressing ALT + S, D, A. Wow! It worked: Find the sequence in your debug output window (ALT + V, O).

Categories : Visual Studio

Multithread - even odd sequence
notify chooses any available thread. The choice is arbitrary and occurs at the discretion of the implementation If there are more than two threads waiting you could be signalling the "wrong" thread. Also, note that both of your threads could be just finished in get(Even|Odd) with neither waiting, leading to the notify going nowhere depending upon the scheduling. You need to be more strict to ensure the ordering. Perhaps two locks, even and odd, would be helpful.

Categories : Java

How to use a sequence table
Use a table to contain your counter. Each time you need a new value, start another, very short transaction, which will get the value of the counter from the table, increment it, save it back in the table, and return it. Then generate your job number from this counter and save it into your entity. If you often generate such job numbers, then you could use a better technique, like a hilo algorithm, or a technique which increments the counter by 100 and keeps the 100 next counter values in a thread-safe cache in memory.

Categories : Java

How to get name and in a sequence in Powershell
Its a lot easier to make all of the WMI calls into a single object. It is much easier to handle formatting. I think I got everything that you were wanting: function GetCompInfoWork { param ( [string]$computername,[string]$logfile ) $pc = Get-WmiObject Win32_ComputerSystem -ComputerName $computername $bios = Get-WmiObject win32_bios -ComputerName $computername $disk = Get-WmiObject win32_logicalDisk -Filter "DeviceID= 'C:'" ` -computername $computername $obj = New-Object -TypeName PSObject $obj | Add-Member -MemberType NoteProperty ` -Name PSCompName -Value ($bios.PSComputerName) $obj | Add-Member -MemberType NoteProperty ` -Name Version -Value ($bios.version) $obj | Add-Member -MemberType NoteProperty ` -Name Manufa

Categories : Powershell

ASN.1 Sequence Confusion
Suppose you write the following: R DEFINITIONS AUTOMATIC TAGS ::= BEGIN USPostalAddress ::= SEQUENCE { street IA5String, city IA5String, state IA5String (SIZE (2)) (FROM("A".."Z")), zipcode IA5String (SIZE (5)) (FROM("0".."9")) } END The part between BEGIN and END above is called a "type assignment". "USPostalAddress" is the name of a (user-defined) "type". By writing the above, you have specified a user-defined type and you have given a name to it. Each SEQUENCE construct (the above SEQUENCE construct, for example) is a "type". It's a complex type, in that it contains one or more "fields" each having its own type. A possible "value" of the above type is denoted as follows: { street "1234 Main St.", city "New York", state "NY", zipcode "12345" } We

Categories : Misc

my sequence is too long,so please go through this
In the filter mediator, then condition you are trying to send request back to the client as response. So, you need to remove the "To" header. The "else" condition looks fine. What is the issue now you are facing and at which configuration segment you are facing the issue?

Categories : Wso2

How to stop this sequence?
i have made a global integer: int i=1; -(void)conveyComplete:(UIView*)v{ [self convey:v delay:0]; } -(void)convey:(UIView*)v delay:(int)nDelay{ [UIView animateWithDuration:.5 delay:nDelay options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction) animations: ^ { CGRect rPos = v.frame; i+=1;// then increase +1 every time it runs NSLog(@"x:%f y:%f vFrame:%f vFrame:%f" , rPos.origin.x,rPos.origin.y,v.frame.origin.x,v.frame.origin.y); rPos.origin.x -= 5; rPos.origin.y -=100; v.frame = rPos; } completion: ^(BOOL finished) { if(i<20){ [self conveyComplete:v]; } NSLog(@"I:%i, F:%i",i,f); }]; }

Categories : IOS

animation with keyframes not working on firefox
I'd say you've got a few problems besides the one you mentioned. In the html in your fiddle, you had <a class="arrUp"></a> right inside the <ul>. The only child element type that can be inside the <ul> is<li>. Changing this screwed up the arrow look, but I'm sure you can figure that out. I would just make the image the background of the <ul> like you did with the parent <li>. Transition is a much better use for your drop down than animation. This way you can have the animation work for both the close and open. In your current code, even if the animation did work, when you closed the drop down you either had to create another animation or just have it disappear. The root of the problem was that Firefox wasn't running the animation before th

Categories : HTML

how should I change the sequence of a list
You have not provided enough information on if the data is static or dynamic, what kind of element is it wrapped inside. I will answer you based on my understanding of your question. You can use List to format the data in a way you want. Put all the items in an unordered list (i.e. UL) like this: HTML <div id="somelist"> <ul> <li>August, 2013</li> <li>July, 2013</li> <li>June, 2013</li> <li>May, 2013</li> <li>April, 2013</li> <li>March, 2013</li> <li>February, 2013</li> <li>January, 2013</li> <li>December, 2012</li> <li>November, 2012</li> <li>October, 2012</li> <li>September, 2012</li> <li>August, 2012</li> </ul>

Categories : CSS

Local sequence cannot be used in LINQ to SQL
The query provider doesn't know how to translate w.ops.Intersect(selecteditems) into a SQL query. If selecteditems was another query from the same query provider then it may be able to translate them, or if the entire operation were being done in Linq-to-Objects, rather than Linq-to-SQL, then it would be fine. As per the error message, the only operation it knows how to perform on such an object is Contains. You can re-work your query to use that instead: .Where(w => selecteditems.Count == 0 || w.ops.Any(op => selecteditems.Contains(op))) That [should] work.

Categories : C#

Sorting a hashmap according to my sequence
Your problem seems to be, that you're iterating over the sequence and for every element in that sequence you're iterating over the map and add each non-matching element. I guess you want something like this instead: create a copy of the map for each element in the sequence for each entry in the map copy (use an iterator here, since you'll have to call remove()on it) if the entry matches the sequenc element add to the list remove the current entry from the map copy (that's why you need the copy) after doing this, the list contains all matching elements in order and the map copy contains all non-matching elements The problem in your case is that map keys and sequence elements don't match entirely, otherwise you could optimize that for better lookups. EDIT: Another option might b

Categories : Java

Converting a string to a sequence in R
Here is a solution using the dreaded eval(parse(...)) structure: Dependencies$DEP <- sapply(paste("c(", Dependencies$DEP, ")"), function(x) eval(parse(text = x))) Dependencies # SUB DEP # 1 1 NULL # 2 2 1 # 3 3 1, 2 # 4 4 1, 2, 3 # 5 5 1, 2, 3, 5 str(Dependencies) # 'data.frame': 5 obs. of 2 variables: # $ SUB: int 1 2 3 4 5 # $ DEP:List of 5 # ..$ c( ) : NULL # ..$ c( 1 ) : num 1 # ..$ c( 1, 2 ) : num 1 2 # ..$ c( 1, 2, 3 ): num 1 2 3 # ..$ c( 1:3, 5 ) : num 1 2 3 5

Categories : R

Deleting a sequence of objects
Use this: rm(list=paste0("yob.",14:60)) EDIT: Using @baptiste's suggestion: rm(list=Filter(exists, paste0("yob.", 14:60))) In case some of the names generated do not reference existing dataframes. Another option, using regexps (thanks @mnel): rm(list=ls(pattern="^yob\."))

Categories : R

Right way to iterate a sequence of XML nodes in PHP
if(count($clients->Client) > 1){ foreach ($clients->Client as $client ) { print_r($client); //Print the client node and its properties if more than one client, and prints each property of client node if only one client. print_r($client->Id); //Give me error if only one client, because Id will not exist. } }else { echo $clients->Client['id']; //and other child attributes }

Categories : PHP

when is the ID (GenerationType.SEQUENCE) set in the object?
When having a sequence, JPA sets the id exactly after you call the persist method of your EntityManager instance. There is no need to commit of flush. The id is available exactly after that call. That's the main difference between GenerationType.SEQUENCE and .IDENTITY. The later one offers the id after contacting the db, while SEQUENCE sets it directly, because a group of ids is preloaded in the application at runtime, therefore there's no need to interact with the db for getting an id. Explanation of JPA protocol by a different implementation: "Unlike AUTO and IDENTITY, the SEQUENCE strategy generates an automatic value as soon as a new entity object is persisted (i.e. before commit). This may be useful when the primary key value is needed earlier. To minimize round trips to the database

Categories : Database

XSD validation in a sequence and choice
What I'd like is an unsorted list of El1 or El2 with optionnaly one (and only one) El3. I read that as (e1 | e2)* (e3, (e1 | e2)*)? that is sequence choice max=unbounded E1 E2 /choice sequence min=0 E3 choice max=unbounded E1 E2 /choice /sequence /sequence

Categories : Xml

Create a second sequence, same object
what you have done to create new sequence for purchase is ok. to restrict particular sequence for particular partner is not any existing functionality in openerp, for this you have to done some customization in your module, like in purchase order sequence generated when you create new purchase order, then overwrite the create method and add code here , check the partner if partner is belong to old sequence then generated sequence from old or belong to new then generate sequence from new one sequence hope this help

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.