coding-style

javascript pass variable to style

一曲冷凌霜 提交于 2019-12-11 20:01:34
问题 screen_w = window.innerWidth; screen_h = window.innerHeight; to get the window deminsions and then set it to a variable. Is there a way to take that variable and then use it in my style? Such as: img { width:screen_w; height:screen_h; } I have tried <script type="text/javascript"> <style> img.. </style> </script> but that doesn't seem to work.. is this even possible or is there some other way to pass a variable? Thanks in advance. ///Added Ok so the Link down there ---v Is discussing making a

MSVC C++11: non-standard constructor inheritance

元气小坏坏 提交于 2019-12-11 18:37:24
问题 In my Windows Native C++ library I've sometimes overdone it in terms of constructors without providing actual methods with same functionality (5-10 extra constructors). This makes basic extending a C++ class really hard as there's no proper constructor inheritance (without redeclaring them and forwarding calls) . I use MSVC. (Yes, smile all you want!) Question is: Is there a way to inherit constructors except the default constructor/copy-constructor using using ? Because, if someone decided

What is the preferred coding style for checking if something is false? [closed]

狂风中的少年 提交于 2019-12-11 16:46:36
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Given the following: bool isCorrect = theAnswer == 42; Which is the preferred way of testing false boolean logic in C# (programming in

Abbreviate argument to member function expecting introduced type (enum class)

大城市里の小女人 提交于 2019-12-11 15:28:37
问题 TL;DR Is there a Shorter syntax for the enum class type argument to a member function ( field_inst.write(decltype(field_inst)::Type::cpr1_4096); ) in the following code? namespace Hal { // complex template definition `Bit_Field` template< class Tregister, typename Tregister::Data Toffset, typename Tregister::Data Tmask, class Tfield_type, class Tmutability_policy = typename Tregister::Mutability_Policy > struct Bit_Field : Tregister { using Type = Tfield_type; static Field read() { // ...

Different from Jquery, Remove class when width screen is 1050px

强颜欢笑 提交于 2019-12-11 14:44:59
问题 OK i know now how to remove abd add class with the width of the window. But now i'm struggling with this issue: I want this: var num = 90; //number of pixels before modifying styles $(window).bind('scroll', function () { if ($(window).scrollTop() > num) { $('#menu2').addClass('f-nav'); } else { $('#menu2').removeClass('f-nav'); } }); to work with this: function checkWidth() { if ($(window).width() > 1049) { $('#menu2').addClass('f-nav'); } else { $('#menu2').removeClass('f-nav'); } } $(window

Background-color style in FF/chrome

旧街凉风 提交于 2019-12-11 14:14:46
问题 Does anyone know why my 'container' div isn't showing the white bg-color from it's parent div s? I'm getting the black (Lime in my example for better description) bg-color from the CSS body setting. Please excuse the sloppy styling. I did my best to reduce the code and show relative stuff. BTW, I've tried making the 'container' div and it's child divs' style bg-color white; and it still doesn't work. When I give the highest div a large height attribute (say 1000px), it shows white to that

is it bad form to use instance vars directly in ruby?

最后都变了- 提交于 2019-12-11 13:19:33
问题 Should you always create accesssors (for reading and/or writing) in ruby? If you have a class that's not meant to be reused outside, can't I just use instance variables directly? One of the problems I ran into is that it's problematic to stub out @instance_vars in tests. 回答1: Instance variables don't matter when it comes to testing. You should be testing your methods , in order to verify that they produce the correct results. When you define a reader method for an attribute, you expose that

way to handle to write CUDA+MEX code in linux?

混江龙づ霸主 提交于 2019-12-11 13:09:09
问题 I try to write matlab mex code with Cuda integrated but it is just hard enough to compile and debug all around. Is there any better approach to code and test? I am on Matlab 2012b. Currently I am writing code in sublime then compile it on matlab but I am also newbie at CUDA as well thus it is just hard to code it without seeing the result instantly. 回答1: The comment by Robert Crovella is interesting. I just wanted to mention the way I was used to compile mex file with CUDA instructions (and

PSR-2 coding standard: why no closing PHP tag in files containing only PHP? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-11 12:41:45
问题 This question already has answers here : Why would one omit the close tag? (14 answers) Closed 5 years ago . I just heard of the PSR-2 coding standard in a comment on this question: Is there any reason to use the "public" keyword before method and member variable names? I have a question on one of the rules in the PSR-2 standard: The closing ?> tag MUST be omitted from files containing only PHP. What is the point of that? 回答1: It is a good universal rule not using closing tag in php scripts.

Ruby style for displaying long arrays

谁都会走 提交于 2019-12-11 12:26:36
问题 I am using rubocop to check the styling conventions of my code conform to best practices. I have an array of colors and want to know the best way to display them. I've read that lines should be less than 80 characters long, so I did this. colors = [:light_red, :red, :pink, :orange, :light_yellow, :yellow, :light_green, :green, :light_blue, :blue, :white, :black] I get the following exception message from rubocop C: Align the elements of an array literal if they span more than one line Does