w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Write a function to dynamically create a new copy of string and return a pointer to the new copy (C)
I should start by pointing out that in my opinion, given the number and (especially) nature of the mistakes in this code, you probably need to get a good book on C. Your newString = s; overwrites the pointer instead of copying the string into the space you just allocated. Thus, you lose the pointer to what you just allocating (leaking the memory) without making a copy. You probably want to use strcpy instead of direct assignment. Your computation of the size you allocate isn't what you really want either. Typically, for a string of length N, you want to allocate N+1 bytes. You're currently attempting to allocat sizeof(int * strlen(s)) bytes, which shouldn't even compile.

Categories : C

Execute function on height change using jQuery
$('.mydiv').resize(function() { if($(this).height() > 400){ $('body').removeClass('normal height bigheight').addClass('bigheight'); } else if ($(this).height() > 200){ $('body').removeClass('normal height bigheight').addClass('height'); } else if ($(this).height() > 0){ $('body').removeClass('normal height bigheight').addClass('normal'); } else { $('body').removeClass('normal height bigheight'); } });

Categories : Jquery

jQuery ajax can't animate div height resize in success function
Are you sure your content block is float:left; ? Maybe height of #content doesnt change really ... if you have multiple block with float:left; in a parent block with float:none; , parent block havent "the real height", child blocks were showed because overflow is visible ... <div class="container"> <div id="content" style="float:left"> &nbsp; </div> </div>

Categories : Javascript

How to write a jquery function for same-type controls in html?
how about? $("#send").click(function() { $("input[type=text]").each(function(){ if ($(this).val().length == 0) { $(this).css({ background: "url(image/error.png) no-repeat right" }); } }); }); example: http://jsfiddle.net/ddDSB/

Categories : Javascript

How to write copy-on-write list in .NET
Implementation is correct because reference assignment is atomic in accordance to Atomicity of variable references. I would add volatile to list.

Categories : C#

jQuery - get tallest image's height, apply other images' height difference to top margin
Try this: function createGrid() { var imgs = $('.hlist figure > img'); var maxImgHeight = 0; imgs.each(function () { var imgHeight = $(this).outerHeight(); maxImgHeight = maxImgHeight > imgHeight ? maxImgHeight : imgHeight; }); imgs.each(function () { var margin = maxImgHeight > $(this).outerHeight() ? (maxImgHeight - $(this).outerHeight()) : 0; $(this).css("margin-top", (margin + "px")); }); } The first each loop looks for the tallest height and stores it in maxImgHeight, as you originally had planned. The second each loop calculates and applies the margin for each image. The conditional assignment will cause the margin-top for the tallest image to be 0.

Categories : Javascript

Warning: copy() [function.copy]: Filename cannot be empty
http://www.php.net/manual/en/ini.core.php#ini.post-max-size Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.

Categories : PHP

jQuery Error: Object has no method 'height', this.height()
this is a DOM element. You want a jQuery object. Try $(this).height() : function Test(){ $("#list li").each(function(){ var h = $(this).height() + 50; $(this).height(h); }); }

Categories : Jquery

jQuery Set height of 2 independent lists first list li the same height as second li
http://jsfiddle.net/EvspT/ $(document).ready(function() { $('.extraQuestionName li').each(function(i) { $('.extraQuestionValue li').eq(i).height($(this).height()); }); }); The each() function has an index parameter. This loops through the li elements in the first list, and uses eq() to find the item with the same index in the second list, then set the height.

Categories : Jquery

Javascript / jQuery - Is there a performance difference between height() and .css({'height'})
Read the Source, Luke. jQuery.prototype.height: //snipped to end: return value === undefined ? // Get width or height on the element, requesting but not forcing parseFloat jQuery.css( elem, type, extra ) : // Set width or height on the element jQuery.style( elem, type, value, extra ); jQuery.prototype.css: return value !== undefined ? jQuery.style( elem, name, value ) : jQuery.css( elem, name ); The difference between the two is what's done before going over the matched elements, and that extra parameter that's passed in .height. What could rationally cause a big slowdown? I've no real idea. Maybe it has to do with optimizations a js engine can do in one, but not the other. More likely than not, the perf test is bad (testing these things correctly is very ha

Categories : Javascript

jQuery Scroll function : Scroll Top and Window Height 1px discrepancy in value
It is because the browser sometimes adds its own stylesheet as well. That may be the cause of your issue. Try using reset.css. It resets all the browser default css. And its always a good practice to trigger infinite scroll from around 50px of the bottom. You dont wanna have the user to scroll to "the very end" to show next content.

Categories : Jquery

jQuery, min-height based on browser height
Use css(). var height = $(window).height(); $(".single-block").css("min-height", height); or simply: $(".single-block").css("min-height", $(window).height());

Categories : Jquery

Copy-on-write support in STL
The string class provided by the C++ standard library, for example, was specifically designed to allow copy-on-write implementations That is half-truth. Yes, it started design with COW in mind. But in the rush the public interface of std::string was messed up. Resulting it getting COW-hostile. The problems were discovered after the standard published, and we're stuck with that ever since. As stands currently std::string can not be thread-safely COW-ed and implementations in the wild don't do it. If you want a COW-using string, get it from another library, like CString in MFC/ATL.

Categories : C++

How do I tell if Ruby 2.0 is copy on write friendly?
Apparently Ruby 2.0 is copy on write friendly, but the method ":copy_on_write_friendly" is only available in Ruby Enterprise Edition. The COW friendliness is a function of the garbage collector, and only one gc is available for ruby 2.0 (correct me if I'm wrong!), there is no need for a configuration option. If you want to query COW friendliness, you would want to query the version of ruby.

Categories : Ruby

How to write $("#content").height() in pure JavaScript?
Equalent to $('#content').height() would be : document.getElementById('content').clientHeight; or equalent to $('#content').css('height') document.getElementById('content').style.height;

Categories : Javascript

File.Copy versus read and write in C#
Go with 1st option. Because its a inbuilt function and will use CPU rather then Memory StreamReader will use Memory which is should be avoided when you have large files. However buffering can also be implemented in this.

Categories : C#

jquery .height() not pulling the height
If you want a one-liner, try this: $(".zebra-helper").fadeToggle("slow", "linear").height($("#main-content-pane").height()); If you want to use again the same height in that block, store it into a variable, then use it when needed: var h = $("#main-content-pane").height(); $(...).height(h);

Categories : Jquery

Javascript / jQuery : get height when max-height is set to 0
My first question would to be why are you using max-height: 0; is there something else you can use? Like hide() show() which use display: none the only thing I can thing of would be to remove the max-height css get the height and then reapply the max-height: $('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0') This should happen fast enough that you wont see the element but it could be wise to hide it before removing the max-height with: $('.div').hide() $('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0') $('.div').show()

Categories : Javascript

Click to increase height and decrease back to original height when click again with jQuery?
$("button").toggle(function(){ $("#section").height($("#section").height()+300); },function(){ $("#section").height($("#section").height()-300); }); reference toggle

Categories : Jquery

How do I write a code to copy data from one sheet to another when "x" is found and not duplicate
The code below will do exactly what you ask for, but not more than that. It sets the value in the L column to xx (instead of just x) to not copy the data twice, and it assumes that the x-es in the L column are in order, which of course could be a false assumption. Sub CopyData() Dim run As Boolean Dim i As Integer i = 1 run = True While run If Worksheets("Used Car Log").Range("L" + CStr(i)).Value = "x" Then Worksheets("Used Pending").Range("B" + CStr(i) + ":K" + CStr(i)).Value = Worksheets("Used Car Log").Range("B" + CStr(i) + ":K" + CStr(i)).Value 'Mark the value as copied by setting the value in column L as xx Worksheets("Used Car Log").Range("L" + CStr(i)).Value = "xx" ElseIf Worksheets("Used Car Log").Range("L" + CStr(i)).Value = "" Then run =

Categories : Excel

C# - Marshal.Copy : Attempted to read or write protected memory
You seem to be considering 3 times the stride for every row; your code will only work for the first third of the image; after that you have indeed gone outside of your allowed range. Basically: bmpData.Scan0 + y * bmpData.Stride * 3 looks really dodgy. The "stride" is the number of bytes (including padding) used by every line. Typically, that would be just: bmpData.Scan0 + y * bmpData.Stride

Categories : C#

Is it possible to write copy constructors for classes with interface member variables in Java?
To my knowledge there is no direct equivalent to this in Java. The "proper" way is to make the Interface it self implement Cloanable. And the easiest way might be to use reflection. I know there is a library which handles deep copies of arbitrary objects, but I cannot recall the name at the moment. Related: Java: recommended solution for deep cloning/copying an instance

Categories : Java

how to write a windows batch script to copy some files and folders from location A to B based on a variable like server name
Use a text editor (for example the Windows built-in Notepad) to store the commands you would type on the commandline in a file. Save that file with the extension ".bat" or ".cmd". The command you'll probably want to use is "copy" or "xcopy". You can learn more about how to call them by calling them with "/?". Example: copy /? To learn more about environment variables, try: set /?

Categories : Windows

jQuery possible to copy existing jQuery method or non DOM object for purpose of extension
It's quite difficult to figure out what you are trying to do in your code. You do realise that your variable "instance" is actually being set to the dom element id="div_2" in your example. Are you trying to get 2 instances of the same plugin or are you just trying to get the same functionality with 2 plugin names? Are you sure you are not just trying to do this? $.fn.a_copy_of_my_plugin = $.fn.myplugin; If you take your code, when you do a console.log() & are able to "see your plugin" - it is not actually a copy of anything it is just a pointer to the function you are assigning to $.fn.copy_of_my_plugin in your code above. Only when you do $('#div_2').copy_of_myplugin(); is it then running that function which tries to "create the second instance" so to speak. If you wanted to run t

Categories : Jquery

calculate and set the height for some div (initial settings). When the height of the browser window is changed --> change the height for div
is that what you are looking for? api.jquery.com jQuery(document).ready(function () { $(window).resize(function() { var height = document.documentElement.clientHeight - 500; if (height < 135) { height = 135; } document.getElementById('left_space').style.height = height + 'px'; jQuery(window).resize(function () { var height = document.documentElement.clientHeight - 500; if (height < 135) { height = 135; } document.getElementById('left_space').style.height = height + 'px'; }); }); });

Categories : Javascript

How to write a template function that can handle object or pointer function calls ?
Overloaded function template is the savior: template<typename T> void invoke(T * obj) //when object is pointer { obj->Process(); } template<typename T> void invoke(T & obj) //when object is non-pointer { obj.Process(); } then use it as: auto value = it->second; invoke(value); //correct invoke() will be selected by the compiler! But that is not good enough, as you might want to do something else also with value in the rest of the function written by you. So if you follow the above approach, there will be code duplication, as both invoke() will have almost similar code. So here is one improvement: instead of using invoke(), turn the pointer into reference so that you could use it uniformly in your function. template<typename T> T& ensure

Categories : C++

How to write a wrapper function which can honour default values, when the target function has ones?
I'll reply myself with even more elaborate setup (I replaced targetf with lib* names). The bar functions are nested inside foo ones, so their default values are not easily visible to the user. libfoo<-function(par1=1,...) { if (missing(par1)) { warning("par1 is missing!!") } print(paste0('par1: ',par1)) libbar(...) } libbar<-function(par2=1) { if (missing(par2)) { warning("par2 is missing!!") } print(paste0('par2: ',par2)) } libfoo2<-function(par3=1,...) { if (missing(par3)) { warning("par3 is missing!!") } print(paste0('par3: ',par3)) libbar2(...) } libbar2<-function(par4=1) { if (missing(par4)) { warning("par4 is missing!!") } print(paste0('par4: ',par4)) } The wrap

Categories : R

Solved: Scala: How to write a generic check function that evaluates any function that returns boolean?
If your input functions only have 2 arguments, like your two examples, you can write a semi generic function take takes all functions with two arguments of any type: def eval[A,B](func: (A,B) => Boolean, arg1: A, arg2: B) = { func(arg1, arg2) } def checkLength(str: String, length: Int) : Boolean = { str.length == length } eval(checkLength, "ham", 4) res0: Boolean = false But if you want to support functions with more arguments, you would have to write one eval function for three arguments, four arguments, etc Maybe there is a better way that can handle all cases?

Categories : Function

Changing height of jQuery Mobile "select" with jQuery?
You are missing the obvious. Your original select is not longer visible. Also as you can see new one is just custom combination of <div>'s and <span>'s. New custom select box will not inherit css from the old one. New select box CSS structure needs to be changed in order for this to work. Working example: http://jsfiddle.net/Gajotres/PMrDn/107/ HTML: <div class="ui-grid-a"> <div class="ui-block-a" style="width: 80%;"> <div data-role="content" class="accountTransferLabels" style="padding-left: 0;"> Amount: </div> <input type="text" autocomplete="off" class="translate" placeholder="0.0" data-clear-btn="true" autofocus required autocorrect="off" autocapitalize="off" data-theme="d"/> </div> &l

Categories : Javascript

Vim function to copy a code function to clipboard
Try this function function! CopyCodeBlockToClipboard() let cursor_pos = getpos('.') let i = 1 let done = 0 while !done call setpos('.', cursor_pos) execute "normal" 'v' . i . 'aBVok"*y' if mode() =~ "^[vV]" let done = 1 else let i = i + 1 endif endwhile execute "normal <ESC>" call setpos('.', cursor_pos) endfunction This preforms a execute command to select blocks until it fails to select a block larger block. ([count]aB selects [count] blocks) It seems when the selection fails we end up in visual mode. So we can use mode() to check this. When this function exits you should be in normal mode and the cursor should be restored to where you started. And the function will be in the * registe

Categories : Function

To create a copy of object in java w/o clone,copy constructor and copy factory
You can just create a new object for NewDog using OldDog Have you considered something like this? NewDog dog = new NewDog(someOldDogObject); While constructor of NewDog can be. public NewDog(OldDog oldDog){ this.dogWeight = oldDog.dogWeight; // keeping the same weight this.dogName = "newDog" + oldDog.dogName; // changing your dog name as per rquirement. }

Categories : Java

jQuery errors "x.ready.promise is not a function" and "Modernizr.prefixed is not a function" / jQuery.noConflict
replace $ with jQuery if you have small amout of scripts.. or wrap them in: (function ($, window, document) { //code }(jQuery, window, document)); or jQuery(document).ready(function() { //code }); or (function(window, undefined) { 'use strict'; //code })(this);

Categories : Jquery

function to write function after argument
>>= has the type m a -> (a -> m b) -> m b. In the case where m is a [] (a list), it does behave like concatMap because then the types line up nicely. What you've written is a completely different type so you can't expect them to work the same. Incidentally, what you've written is already defined exactly that way in Control.Category (>>>) :: a b c -> a c d -> a b d So if you want to have just good old function combination, use it. It can do other things as well but you don't have to worry about them. The second code snippet doesn't make much sense. $ is the opposite of >>> so you've just written (foldr (+) >>> ( filter (>5) >>> ([1..10] >>> map (*2)))) >>> print or without so many parens (foldr (+) >&g

Categories : Haskell

jquery css cannot set the height
Something on your page is conflicting with jQuery. Using $ is the problem in this case. Try this instead... (function($) { $(function(){ $('#nimble_portfolio_grid_1').addClass('importantRule'); }); })(jQuery); That will run whatever code is inside the enclosure with jQuery passed in as the $ parameter and solved your problem. Alternatively, if you're not adding any more code, just change the $ to jQuery like this... jQuery(function(){ jQuery('#nimble_portfolio_grid_1').addClass('importantRule'); }); Finally, the best thing to do would be to use CSS correctly and just specify the element by ID... <style> #nimble_portfolio_grid_1 { height: 5320px !important; } </style>

Categories : Jquery

vba function to copy certain value from one workbook to another
Find returns a Range object if something is found, but Nothing otherwise. You are attempting to Activate the result of using Find, even if it is Nothing - which will generate an error. You need to store the result of your Find attempt in a Range variable, and check for Nothing. Dim rngFound As Range Set rngFound = Range("A1").Find(...) If Not rngFound Is Nothing Then ' we found something! Else ' Nothing End If But, as advised, you should be supplying more details for your question.

Categories : Vba

Perl - need to copy only function name
perl -p -e 's/(.*//' input.file Look for an open parenthesis and anything after it, and delete it all. The -p means read the input file arguments or standard input line-by-line, and after each line, print what's left of $_ after the script in the argument to the -e option has executed.

Categories : Regex

VBA copy appearance function
I think this might be the problem if your Pie chart is not a perfectly square shape. I can replicate your issue, and even when I check the Fill options, the offsets are all 0%. I can adjust them, but that is not a reliable way to do it. So, the best option I think will be to ensure that your pie chart .Parent is a square shape. To do this, before you CopyPicture, set its Height equal to its Width, like this: chtMarker.Parent.Height = chtMarker.Parent.Width '## Ensure the chartObject is a square, so it will not be distorted when pasted. chtMarker.Parent.CopyPicture xlScreen, xlPicture

Categories : Excel

height not changing in scroll function
Would you consider using CSS to style the small state of the header? Whenever the scrollTop is greater than 20px, add the small state class and whenever it's less than 20px, remove it. Demo: http://jsfiddle.net/NphFw/23/ In relation to your problem, I'm not sure jQuery can animate to dynamic values such as auto or inherit even.

Categories : Jquery

height % not working and images in a function
Use display:block instead of table-cell positioning. Set 100% height to #logo. jQuery has a toggle() function to show/hide divs easily. toggle

Categories : Jquery

how can I add a copy of a div with jquery?
Name mismatches: <div id="subjectselectiondiv" style="width:inherit;"> ^^^^^^ $('#choices').clone().appendTo('#subjectselectdiv'); ^^^ What you're attempting to append to doesn't exist. Most likely if you'd bothered checking your javascript console, you'd have seen the warnings/errors about the non-existing element.

Categories : Javascript



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