w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to add elements from sublists with 2 elements (the first element is a string and the second one a number)?
You just need to break out the string versus the number: sum_fire( [[_,N]|Tail], Sum ) :- sum_fire( Tail, S1 ), Sum is N + S1. sum_fire( [], 0 ). So I'm using [_,N] instead of H for the head item because I want what's inside (the number N). I don't care about the string for the sum, so it's _.

Categories : Prolog

C# Support for RSA SHA 256 signing for individual XML elements
I am also looking at the Oasis ebms stuff. I cannot find the article I took this from but I used that class that is in 4.5: public class RsaPkCs1Sha256SignatureDescription : SignatureDescription { public RsaPkCs1Sha256SignatureDescription() { KeyAlgorithm = "System.Security.Cryptography.RSACryptoServiceProvider"; DigestAlgorithm = "System.Security.Cryptography.SHA256Managed"; FormatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureFormatter"; DeformatterAlgorithm = "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"; } public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key) { var asymmetricSignatureDeformatter = (AsymmetricSignatureDeformatter) CryptoConfig.CreateFromName(D

Categories : C#

Add callback to the class or individual elements
Performance wise, use event delegation. It will have loads better performance compared to either of those options because a single handler is only attached once, on a known and existing parent element. Similar to the example provided in the .on() documentation: $("#wrapper").on("click", ".btnClass:visible", function(event){ alert($(this).text()); });

Categories : Javascript

r matrix individual shift operations of elements
This is a bit cleaner and about 40% faster using your example on my machine. Maybe the speed improvement will be greater using your larger data? You should use a matrix of integers. It uses less memory and some operations are faster: A <- matrix(as.integer(c(0,0,4,-3,0,2,0,-3,0,-4,0,-2,2, -2,0,-3,0,0,0,0,-1,0,0,0)), nrow = 8, ncol = 3) Each column is a vector, so should be your output. I replaced matrices with vectors. Also made your code more robust without the hardcoded number of rows: shift <- function(x) { n <- length(x) y <- rep(0L, n) for(i in seq_len(n)) { if (x[i] == 0L) next j <- i + abs(x[i]) if (j > n) next y[j] <- if (y[j] != 0L) 0L else x[i] } return(y) } You can run it using apply: shift_mat <-

Categories : R

How to disable autolayout for individual UI elements (UIlabel)
If you're using Autolayout then your UIViews are positioned based on their NSLayoutConstraints. To move them, rather than set their frames you need to alter the constraints.

Categories : IOS

With one XML file, how do I populate different pages with individual XML elements?
If you are using some server-side scripting, you could parse only the COOKING-category when requesting cooking.html etc. Though, if you are getting the XML-data directly from the HTML-code, then I would recommend splitting the XML-file by category. Alternately you could have a XML-file which includes separate XML-files sorted by category. Described here. Sorry I couldn't give you a better solution.

Categories : Xml

Validating individual elements using jQuery Validation
Quote OP: "... I also needed input validation for elements which are not inside a form ... so my question is, is it possible to validate such individual elements which are not inside form elements using jQuery Validation" No. It is not possible to validate any input elements not contained within <form></form> tags using the jQuery Validate plugin. All input elements must be contained within form tags and .validate() attached to the form element to initialize the plugin. There is no other way. This is by design. See: documentation... "Validate forms like you've never been validating before!" Quote OP: "if no, then how can I validate them without writing my whole new validating functions?" Why would you need to re-write anything? Simply wrap your input e

Categories : Javascript

memmove vs. copying individual array elements
The implementation behind memmove() might be more optimized in your C library. Some architectures have instructions for moving whole blocks of memory at once very efficiently. The theoretical running-time complexity won't be improved, but it may still run faster in real life.

Categories : C

specific column [Remove elements up to last zero element, then remove elements from first zero element to the end]
Let's call your matrix A: firstCol = A(:, 1); indices = find(firstCol); check = find(diff(indices) ~= 1); if (isempty(check) ) Afinal = A(indices, :); else indices2 = indices(check(1)+1:1:check(2)); Afinal = A(indices2, :); end Afinal should be the output you're looking for.

Categories : Matlab

Accessing individual elements' characters using an array parameter in c++
Be careful to be aware of the types of your variables. c++ is a strongly typed language that will distinguish the difference between one char and an array of chars. Dont be confused by the const char * yet... think of it as your array. char fullValue[] = hand[i]; //gets the element at position i char oneLetter = fullValue[1]; //gets char 1 from our fullValue array

Categories : C++

jquery fade effects on individual elements on load
What part of your question comes down to is checking for each img to load and then fadeIn the corresponding element instead of doing them all at once. For example: $("img").load(function() { $(this).fadeIn(1000); }).each(function() { if(this.complete) $(this).load(); }); You can find a working example of that implementation HERE.

Categories : Jquery

Raphael js - animate opacity on group while retaining individual elements opacities
A general solution that works for any number of elements, any number of changes and any number of sets is to use .customAttributes which calculate and store the correct opacity level for each element in the set based on a value attached to that individual element and a value for the set. For example (in the demo, click multiple times to see the opacity of the set of three circles change one way and the individual circle clicked on change the other way): http://jsbin.com/oxeyih/9/edit Using something like this, which essentially adds this feature to all existing and future sets and elements in this Raphael paper instance: // apply this using .attr or .animate to sets or each in a set // to set the opacity of the set as a whole, maintaining relative opacity paper.customAttributes.setOpac

Categories : Javascript

Select elements OptGroups from options with JQUERY
I setup a jsFiddle for this to test http://jsfiddle.net/murCv/ 1) I assume your select box looks something like <select id="residualModelSelector"> <option value="some-node1">Out side opt groups 1</option> <option value="GROUP-first">FirstGroup</option> <option value="first-node1">Inside First group 1</option> <option value="first-node2">Inside First group 2</option> <option value="GROUPEND-first">End FirstGroup</option> <option value="some-node2">Between Groups</option> <option value="GROUP-second">SecondGroup</option> <option value="second-node1">Inside Second group 1</option> <option value="second-node2">Inside Second group 2</option>

Categories : Javascript

How can I control which options are displayed in each of my two
The options you want on the left should go in the first <select> element (name="select3"). The options you want on the right should go in the second <select> element (name="select4"). Basically, exactly how it is now. Edit: ah - the following line in your jQuery file is emptying the second <select> element on document ready for some reason. sel2.empty(); For reference, the <label> element is being used incorrectly. Each <label> is meant to have one form element (referenced by id in the <label>'s for attribute) that it labels, otherwise it's a bit useless (see http://www.w3.org/html/wg/drafts/html/master/forms.html#the-label-element). To label multiple form elements (like your two <select>s), you wrap them in a <fieldset> element, and

Categories : Jquery

Take all elements of .Split (' ') and take last OR exclude last item
Splitting the string is a bit too much here. You just need to find the last occurence of " " and split at this position: var address = "At the gates 42"; var idx = address.LastIndexOf(' '); var street = address.Substring(0, idx); var number = address.Substring(idx + 1); Also consider using regular expressions if you need more flexibility.

Categories : C#

Split UL elements to responsible columns
If I were trying to achieve the effect that I believe you are after I would look at using the masonry library http://masonry.desandro.com. if this does not give you exactly what you are after There are many other clone projects available

Categories : CSS

How to split elements of list with regex
not sure if this is the most efficient way, but: output = [] for x in input: if re.search('(?<=d)s(?=[-+]ddd)', x): output += x.split(" ") should work.

Categories : Python

How to split the elements to in separate div using jQuery
How about something like: $('.modal-body input[type="checkbox"]').each(function () { newWrapped = $("<div>"); newWrapped.append( $(this).clone() ); newWrapped.append( $(this).next().clone() ); $(this).next().remove(); $(this).remove(); $('.modal-body').append(newWrapped); }); $('.modal-body br').remove(); JSFiddle: http://jsfiddle.net/uUCZF/

Categories : Javascript

can't get css3 drop down menu to appear on top of other elements
yes Sir it s the z-index just add it like this : #nav li:hover ul { left: 0; z-index: 22222; } demo: http://jsfiddle.net/n3Zwm/10/

Categories : HTML

One way drag and drop elements between lists
Use jquery's sortable, $(document).ready(function(){ $("#divA").sortable({ connectWith: '#divB', delay: 250 }); }); This would let you drag between A to B only, not from B to A. To make it draggable between both, $(document).ready(function(){ $("#divA").sortable({ connectWith: '#divB', delay: 250 }); $("#divB").sortable({ connectWith: '#divA', delay: 250 }); });

Categories : Javascript

Splitting a string in R, different split argument elements
You can use paste with the collapse argument to combine every element starting with the fifth element. A <- strsplit( x = "2012-10-19T16:59:01-07:00 192.101.136.140 <190>Oct 19 2012 23:59:01: %FWSM-6-305011: Built dynamic tcp translation from Inside:10.2.45.62/56455 to outside:192.101.136.224/9874", split = c(" ", " ", "%", " ")) c(A[[1]][1:4], paste(A[[1]][5:length(A[[1]])], collapse=" ")) As @DWin points out, split = c(" ", " ", "%", " ") is not used in order - in other words it's identical to split = c(" ", "%")

Categories : R

How to drag and drop
  • elements into input fields
  • I did something similar. Well, for the input boxes, I did not use <input></input> but with some div elements making use of contenteditable attribute. I believe in jQuery-UI, there is an event registered for the droppable element. In that event listener, put a code to clone the dragged element and make it as a child of the container. Position it with relative positioning. The layout more or less is like this <div id="1"> <span id="2"> <div id="3" contenteditable="true"> <!-- where user can type something like > 18 etc --> </div> </span> </div> If user drags a tag, then drop event on droppable will be fired. Make a code that clone the tag (or make a new one) and place it under id="2" by insertBefore($("#3")) method in

    Categories : Jquery

    drag and drop html elements or editor
    I would recommend jQuery UI, which affords drop and drag with the 'Droppable' and 'Draggable' interactions, respectively. If you're a real beginner - http://html5demos.com/drag - should get you started with HTML5 drag and drop, so you can get a basic understanding of how it works.

    Categories : Javascript

    options.data has multiple index elements in handlebars helper
    I figured it out. Deleting index: delete options.data.index; Will delete only the first one, so now options.data.index will return the index of the outer #each

    Categories : Javascript

    Split a cell's formulaic elements into seperate cells
    Your formula is already accessing those values in order to sum them in the open workbook. You do NOT need to re-open the workbook in order to evaluate the reference values, nor to parse the formula in the active workbook. Assuming your formula references a closed workbook, with a simple sum function like: ='C:Usersdavid_zemensDesktop[test.xlsx]Sheet1'!$A$1 + ='C:Usersdavid_zemensDesktop[test.xlsx]Sheet1'!$B$1 You can parse the formula either in VBA or using string functions on the worksheet. As you note, for this example, parsing by the + operator will suffice. Since I think you understand how to do this, my example does not demonstrate how to parse the formula. As long as you know or can obtain the references from the formula, you should be able to access those cells' values via form

    Categories : Excel

    Split using regex creates 2 empty elements in array
    You can try with checking if last element is empty or not: var last = list.pop(); last.length || list.push(last); or: list[list.length-1].length || list.pop(); or even shorter: list.slice(-1)[0].length || list.pop(); To handle first empty element (test was there as @Kobi suggested) use: list[0].length || list.shift();

    Categories : Javascript

    Remove duplicate elements from a drop down list using javascript
    In ES3 POJS you could do this. Javascript function removeDuplicateOptions(selectNode) { if (typeof selectNode === "string") { selectNode = document.getElementById(selectNode); } var seen = {}, options = [].slice.call(selectNode.options), length = options.length, previous, option, value, text, i; for (i = 0; i < length; i += 1) { option = options[i]; value = option.value, text = option.firstChild.nodeValue; previous = seen[value]; if (typeof previous === "string" && text === previous) { selectNode.removeChild(option); } else { seen[value] = text; } } } removeDuplicateOptions("Fruits"); On jsfiddle

    Categories : Javascript

    dynamically creating select elements and populating options from sharepoint list
    The obvious first step is to refactor out the shared code. So: $(function () { // Temp test stuff to populate option list var selectObj = document.getElementById("combobox2") if (selectObj) { for (var i=0; i < csKeyword.length;++i){ addOption(selectObj, csKeyword[i], csKeyword[i]); } } }); ( ... etc ... ) becomes: function populate(id, collection) { var selectObj = document.getElementById(id) if (selectObj) { for (var i=0; i < collection.length;++i){ addOption(selectObj, collection[i], collection[i]); } } } $(function () { populate ("combobox1", csCategory); populate ("combobox2", csKeyword); populate ("combobox3", csEntity); }); I can't see any significant advantage at this stage of putting combobox1 and its sibli

    Categories : C#

    Unexpected element (uri:"", local: "element"). Expected elements are <{}link> <{}size>
    There appears to be a bug in EclipseLink JAXB (MOXy) for this use case related to the abstract getCollecion property. We have opened up the following bug that you can use to track our progress on this issue: http://bugs.eclipse.org/411408 WORK AROUND Wrapper We can use @XmlAccessorType(XmlAccessType.NONE) so that only annotated fields/properties will be processed (see: http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html). import java.util.*; import javax.xml.bind.annotation.*; @XmlAccessorType(XmlAccessType.NONE) public abstract class Wrapper<T> extends ElementRoot { protected int totalSize; protected List<T> collection = new ArrayList<>(); @XmlElement public int getTotalSize() { return totalSize; } public void

    Categories : Java

    The element 'entityFramework' has invalid child element 'providers'. List of possible elements expected: 'contexts'
    This happened to me running vs-2013 preview. The App.config/Web.config IntelliSense files that get installed by EFTools.msi should be updated to include valid EF6 elements. The xsd for "validating" EF config section in web/app.config file does not recognize newly added EF6 elements. It should be updated so that it does not show squiggles for valid EF6 config file. Update the config xsd to recognize the elements added in EF6 (i.e. ). These files are located in the Visual Studio install area like ~ "C:Program Files (x86)Microsoft Visual Studio 12.0XmlSchemas". This is not a 100% complete - sorry I am in time-box mode.

    Categories : Wcf

    jquery location.pathname.split("/") returning empty first and last elements
    Well, consider the following url http://stackoverflow.com/questions/18762585/jquery-location-pathname-split-returning-empty-first-and-last-elements/. Path name is /questions/18762585/jquery-location-pathname-split-returning-empty-first-and-last-elements/ and there is nothing before the first "/" and after the last "/". ["", "questions", "18762585", "jquery-location-pathname-split-returning-empty-first-and-last-elements", "18762683", ""]

    Categories : Jquery

    Place element inside other element using absolute. Elements are siblings
    Just do a quick reset on the top: * { margin:0; padding:0; } Fiddle Note: This is a quick reset. You might want to use other reset stylesheets out there.

    Categories : Javascript

    Center a non floating element inside an element having floated elements
    You must float also the #logo; #logo { float:left; width: 200px; height: 30px; margin: 15px auto 0 auto; background: #ccc; } example

    Categories : HTML

    jquery performance issues by enable drag & drop for new elements
    I think the problem is that the elements that are already on the page become draggable over and over again. I think a solution would be to assign a class to those that already have it: $('.order').each(function() { var element = $(this); if ( !element.hasClass('event-already-attached')) { element.addClass('event-already-attached').draggable({ }) } });

    Categories : Javascript

    HTML5 draggable elements within contenteditable div - stops working after first drop - why?
    Apparently Chrome has a bug (not a surprise - contenteditable is the most buggy feature in all browsers). Your code works perfectly fine on Firefox, but for some reason element inserted into editable with insertHTML command cannot be dragged any more. I tried few hacks, but only one worked - inserting other element and then replacing it. So instead: document.execCommand('insertHTML', false, content); Use something like this: var spanId = 'temp-' + (new Date()).getTime(); // Insert span with zero-width space (so it isn't visible and it isn't empty). document.execCommand('insertHTML', false, '<span id="' + spanId + '">u200b</span>'); // Replace that span with our dragged content. $('#' + spanId).replaceWith(content); You can try this here: http://jsfiddle.net/gXScu/5/. I

    Categories : Javascript

    raphael js : text elements drag & drop in the wrong direction
    The raphael issue seems a lot more challenging than your second issue which is the one I'll take a crack at. You can make these non-selectable with a little css and an attribute (for IE10 and Opera). text { /* Use a more applicable selector here - text is potentially too generic */ -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; -moz-user-select: -moz-none; user-select: none; /*cursor:pointer;*/ } Fiddle This is solves most of the problem, but with Opera and IE10 you need to be able to set other attributes on the elements, namely unselectable="on". You can set this through javascript if you can't find a way to do it in the declaration for the element. I did get the directional stuff working by playing with the m: value of the odd one

    Categories : Javascript

    How to get individual text elements from a XML request in jQuery Ajax request
    giv a try to this $(returned).find('data').each(function(){ var $data = $(this); var first_name = $data.find("first_name").text(); alert("it worked: " + first_name); });

    Categories : Jquery

    How do I take a JS array that has some elements that are also arrays and make ALL array elements top level elements
    You don't need the second step to have an array of arrays, just join then split it by the comma: var array = ["item1", "item2", "item3, item4", "item5", "item6"] console.log(array.join(',').split(',')); Example fiddle

    Categories : Javascript

    Append element after last element in a row of floating elements
    on Click , do this - $('.floatLeft').on('click',function(){ $(this).closest('.wrapper').append("<div class='addElement'></div>"); }); Demo -----> http://jsfiddle.net/xQ7hh/2/

    Categories : Jquery

    In Firefox SPAN elements cannot be dynamically added to elements with -column-width values
    Solved it. As I suspected, its a matter of forcing Firefox to redraw elements. The problem is fixed after adding the following line to the addSpan( ) function. document.getElementById("content").innerHTML = document.getElementById("content").innerHTML;

    Categories : HTML



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