qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
44,587,800
I use javascript to read an large image and append to the document, the image is vertical, with the size of 3024 \* 4032: [![Here is the original image](https://i.stack.imgur.com/a2q7B.png)](https://i.stack.imgur.com/a2q7B.png) here was my code: ``` var image = new Image() image.onload = function () { var width = ...
2017/06/16
[ "https://Stackoverflow.com/questions/44587800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4715721/" ]
You can rotate your image: ```js let image = new Image() image.onload = function (e) { let width = image.width; let height = image.height; document.body.appendChild(image); let el = e ? e.target : window.event.srcElement; el.style.transform = 'rotate(+90deg)'; console.log('width: ' + wid...
Thanks for the answer from @jonLuci , this library fixed my issue: <https://github.com/blueimp/JavaScript-Load-Image> and I update my code as bellow: ``` var imageUrl = 'images/01vertical.jpg' loadImage( imageUrl, function (img) { if (img.type === 'error') { console.log('Error loading image ' + imageUrl...
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
You can do this without Javascript. Using HTML5 is easier: ``` <input type="text" placeholder="default text" /> ```
``` $('#textbox').blur(function() { if( $('#textbox').val() == "" ) { //show the date } } ```
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
Here's how I usually do it. ``` <form id="myform"> <input name="box" type="text" value="Type here"> </form> ``` \_ ``` $("input[name='box']", "#myform").bind("blur focus", function() { if ($(this).val() == "" ) { $(this).val("Type here"); }else if ($(this).val() == "Type here" ) { $(this...
``` $('#textbox').blur(function() { if( $('#textbox').val() == "" ) { //show the date } } ```
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
You can do this without Javascript. Using HTML5 is easier: ``` <input type="text" placeholder="default text" /> ```
Actually your question is not very clear but ,, ``` var yourVaribale; $('yourTextSelector').val(yourVariable) ``` u can set a value of an input text like above
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
Here's how I usually do it. ``` <form id="myform"> <input name="box" type="text" value="Type here"> </form> ``` \_ ``` $("input[name='box']", "#myform").bind("blur focus", function() { if ($(this).val() == "" ) { $(this).val("Type here"); }else if ($(this).val() == "Type here" ) { $(this...
Actually your question is not very clear but ,, ``` var yourVaribale; $('yourTextSelector').val(yourVariable) ``` u can set a value of an input text like above
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
You can do this without Javascript. Using HTML5 is easier: ``` <input type="text" placeholder="default text" /> ```
you can do something like ``` $(document).ready(function(){ if ($("input[id$='your textbox id']").val().length == 0 || $("input[id$='your textbox id']").val().trim() == " ") { $("input[id$='your textbox id']").val("something"); }); ```
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
You can do this without Javascript. Using HTML5 is easier: ``` <input type="text" placeholder="default text" /> ```
Here's how I usually do it. ``` <form id="myform"> <input name="box" type="text" value="Type here"> </form> ``` \_ ``` $("input[name='box']", "#myform").bind("blur focus", function() { if ($(this).val() == "" ) { $(this).val("Type here"); }else if ($(this).val() == "Type here" ) { $(this...
7,872,047
how can i do it with JQuery? I use the **change** event but if i submit or reset the form the text is not set again. I need to show a text(it is a datapicker, so i need to show a date) inside the input. How to do it? Thanks!
2011/10/24
[ "https://Stackoverflow.com/questions/7872047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887651/" ]
Here's how I usually do it. ``` <form id="myform"> <input name="box" type="text" value="Type here"> </form> ``` \_ ``` $("input[name='box']", "#myform").bind("blur focus", function() { if ($(this).val() == "" ) { $(this).val("Type here"); }else if ($(this).val() == "Type here" ) { $(this...
you can do something like ``` $(document).ready(function(){ if ($("input[id$='your textbox id']").val().length == 0 || $("input[id$='your textbox id']").val().trim() == " ") { $("input[id$='your textbox id']").val("something"); }); ```
11,165,673
I am working on asp.net using c#. I have one master page with 3 anchor tag links and one html label. When a user clicks on a particular link it should redirect to specific page and the link text should be displayed on the label. I have used following code, ``` $(document).ready(function () { $('#div1 a').c...
2012/06/23
[ "https://Stackoverflow.com/questions/11165673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999689/" ]
If you have a label server control, changing the text with javascript before a postback occurs will have no effect since the whole page is redrawn. **Edit**: I think I know what you are trying to do. Why not create a `contentplaceholder` in your master page, and set its value in each of the pages? In your Master page...
If I am getting your problem right , the labels are on the Master page and $('#lblHeader') is not accessing the labels properly, possibly because asp.net changes the id's of labels that are of master page - try this: ``` $(document).ready(function () { $('#div1 a').click(function () { if (fo...
11,165,673
I am working on asp.net using c#. I have one master page with 3 anchor tag links and one html label. When a user clicks on a particular link it should redirect to specific page and the link text should be displayed on the label. I have used following code, ``` $(document).ready(function () { $('#div1 a').c...
2012/06/23
[ "https://Stackoverflow.com/questions/11165673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999689/" ]
If I am getting your problem right , the labels are on the Master page and $('#lblHeader') is not accessing the labels properly, possibly because asp.net changes the id's of labels that are of master page - try this: ``` $(document).ready(function () { $('#div1 a').click(function () { if (fo...
If you want user to see something after clicking a link you need to prevent browser default and set a timer for duration you want. This won't provide a very good user experience! ``` $('#div1 a, #blog, #about').click(function() { if (focus == true) { $('[id$=lblHeader]').text("Home"); var href = t...
11,165,673
I am working on asp.net using c#. I have one master page with 3 anchor tag links and one html label. When a user clicks on a particular link it should redirect to specific page and the link text should be displayed on the label. I have used following code, ``` $(document).ready(function () { $('#div1 a').c...
2012/06/23
[ "https://Stackoverflow.com/questions/11165673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999689/" ]
If you have a label server control, changing the text with javascript before a postback occurs will have no effect since the whole page is redrawn. **Edit**: I think I know what you are trying to do. Why not create a `contentplaceholder` in your master page, and set its value in each of the pages? In your Master page...
If you want user to see something after clicking a link you need to prevent browser default and set a timer for duration you want. This won't provide a very good user experience! ``` $('#div1 a, #blog, #about').click(function() { if (focus == true) { $('[id$=lblHeader]').text("Home"); var href = t...
8,315,467
how do I source a .sql file, like the one below, through php? ``` CREATE DATABASE IF NOT EXISTS data_base; USE data_base; CREATE TABLE IF NOT EXISTS the_table( package_name varchar(50) NOT NULL, PRIMARY KEY (`package_name`) ) ``` I tried the following, but it doesn't work. I've tried to do some research and...
2011/11/29
[ "https://Stackoverflow.com/questions/8315467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/954912/" ]
You cannot just run an SQL script, even with mysqli::multi\_query(). An SQL script can contain some commands that are recognized as [builtin commands](http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html) only by the mysql client, not by the MySQL server's SQL parser. `SOURCE` is definitely a command that is pr...
You're mixing `mysql` command line statements with PHP functional calls. Do one or the other. Utilize the `mysql` CLI (if available): ``` // executing mysql cli exec("mysql < test.sql"); ``` Or run the SQL with [`mysqli_multi_query()`](http://php.net/manual/en/mysqli.multi-query.php): ``` // running the files con...
8,315,467
how do I source a .sql file, like the one below, through php? ``` CREATE DATABASE IF NOT EXISTS data_base; USE data_base; CREATE TABLE IF NOT EXISTS the_table( package_name varchar(50) NOT NULL, PRIMARY KEY (`package_name`) ) ``` I tried the following, but it doesn't work. I've tried to do some research and...
2011/11/29
[ "https://Stackoverflow.com/questions/8315467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/954912/" ]
You're mixing `mysql` command line statements with PHP functional calls. Do one or the other. Utilize the `mysql` CLI (if available): ``` // executing mysql cli exec("mysql < test.sql"); ``` Or run the SQL with [`mysqli_multi_query()`](http://php.net/manual/en/mysqli.multi-query.php): ``` // running the files con...
Okay, this is a really old one I just stumbled across but I don't see anybody mention what I've always had work for me --NOTE I didn't look this up, just thought about it and it worked so I've used it for years, may not be the most secure way. If the queries are already in a .sql file, I have always just read that in a...
8,315,467
how do I source a .sql file, like the one below, through php? ``` CREATE DATABASE IF NOT EXISTS data_base; USE data_base; CREATE TABLE IF NOT EXISTS the_table( package_name varchar(50) NOT NULL, PRIMARY KEY (`package_name`) ) ``` I tried the following, but it doesn't work. I've tried to do some research and...
2011/11/29
[ "https://Stackoverflow.com/questions/8315467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/954912/" ]
You cannot just run an SQL script, even with mysqli::multi\_query(). An SQL script can contain some commands that are recognized as [builtin commands](http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html) only by the mysql client, not by the MySQL server's SQL parser. `SOURCE` is definitely a command that is pr...
Okay, this is a really old one I just stumbled across but I don't see anybody mention what I've always had work for me --NOTE I didn't look this up, just thought about it and it worked so I've used it for years, may not be the most secure way. If the queries are already in a .sql file, I have always just read that in a...
20,918,112
With reference to [Why does HTML think “chucknorris” is a color?](https://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color) Is the following analysis correct? 1. First, all non-hex characters are replaced with '`0`'. testing -> `0e00000` 2. Then if it is not divisible by 3, append '0's ...
2014/01/04
[ "https://Stackoverflow.com/questions/20918112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/810770/" ]
What it's actually doing is splitting it into the RGB values, not the hex color value. So you're not creating `#0e0000`, you're creating `RGB(0e0, 000, 000)`. Since we know that `000` is simply `0`, we only have to look at the `0e0` part of it. From here, you need to remove the leading `0`s down to two digits if there ...
Yes you are right it is using following parsing algoritham with following steps First, remove any hash-marks, then replace any non-hexadecimal characters (0-9a-f) with 0's. Eg: #DIXIT becomes D0000. For lengths 1-2, right pad to 3 characters with 0's. Eg: "0F" becomes "0F0", "F" becomes "F00". For length 3, take ea...
55,398,373
I have some data in csv like ``` string[][] items = new string[][] { new string[] { "dog", "3" }, new string[] { "cat", "2" }, new string[] { "bird", "1" } }; ``` now I want to convert the input into properly formatted CSV lines and return them - expected output: ``` string[] csvLines = {"\"dog\";\"3\"", "\"c...
2019/03/28
[ "https://Stackoverflow.com/questions/55398373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6887468/" ]
If you want to wrap items in quotations (with escapement: `"ab\"c"` should be `"\"ab\"\"c\""`) and `Join` them with `;` you don't need `CsvHelper` but a simple *Linq* ``` string[][] items = new string[][] { new string[] { "dog", "3" }, new string[] { "cat", "2" }, new string[] { "bird", "1" }, new st...
I would say that @Dmitry Bychenko's answer is more straight forward, but if you did want to use CsvHelper it is possible. ```cs public static IEnumerable<string> GetCSVLines(string[][] list) { using (MemoryStream stream = new MemoryStream()) using (StreamWriter writer = new StreamWriter(stream)) using (Csv...
32,224,509
I'm using visual studio 2013 professional edition. When I create new VC++ console application, I'm getting the following error **'Null' is null or not an object** After selecting OK, I'm getting the below exception **System.Runtime.InteropServices.COMException** If we add any files in the existing project below er...
2015/08/26
[ "https://Stackoverflow.com/questions/32224509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2663777/" ]
I've been struggling with the same issue for quite a while and the internet seems to be dry on addressing this issue, it turns out that the problem is with Environment Variable VCTargetsPath. The default value is somehow missing a backslash in the end '\'. ``` VCTargetsPath = C:\Program Files (x86)\MSBuild\Microsoft.C...
<https://social.msdn.microsoft.com/Forums/en-US/bb74eebd-a88b-4b02-8e99-126a90e8ebdf/how-to-resolve-null-is-null-or-not-an-object-error-in-vs-2013?referrer=http%3a%2f%2fsocial.msdn.microsoft.com%2fForums%2fen-US%2fbb74eebd-a88b-4b02-8e99-126a90e8ebdf%2fhow-to-resolve-null-is-null-or-not-an-object-error-in-vs-2013%3fref...
70,474,798
I am trying to change the background color of `select` element based on which option user selects. I have created this example <https://codepen.io/lordKappa/pen/YzrEWXd> and here the color changes but it also changes for all `select` elements not just for the one we changed. ``` const [selectState, setSelectState] =...
2021/12/24
[ "https://Stackoverflow.com/questions/70474798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15575033/" ]
There is the experimental NativeAOT-LLVM (<https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM>). It is not an official Microsoft WebAssembly compiler, its supported by the community, but .Net 6 is available. First, and this only works on Windows, you need to install and activate emscripten. I wont cover i...
I recently came across : <https://github.com/Elringus/DotNetJS> Looks very interesting and closer to how I would want to use c# in the web browser. I will be looking at this in the next few months
535,727
Assume we have n observations $x\_i$ (i from 1 to n), each from the a normal distribution with mean 0 and some variance component: $X\_i \sim N(0, \sigma^2)$. The random variables $X\_i$s have some (let's assume known) correlation structure. I.e.: $Corr(X\_i, X\_j) = \rho\_{ij}$. How should we estimate $\sigma^2$? Ho...
2021/07/23
[ "https://stats.stackexchange.com/questions/535727", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/253/" ]
Let $R = (\rho\_{ij})$ be the correlation matrix so that the covariance matrix is $\Sigma = \sigma^2 R.$ Consider $\mathbf x = (x\_1,\ldots, x\_n)^\prime$ to be a *single* observation of the [$n$-variate Normal distribution](https://en.wikipedia.org/wiki/Multivariate_normal_distribution) with zero mean and $\Sigma$ cov...
You can apply GLS equations, e.g. top of p.5 in these lectures: <http://halweb.uc3m.es/esp/Personal/personas/durban/esp/web/notes/gls.pdf> The equation for MSE is $\sigma^2=1/n \sum\_{ij} x\_i r^{-1}\_{ij} x\_j$ if you set X to zero and correspond your r to their V This equation doesn’t work for extreme cases such as...
59,835,221
So I have login page that the admin or users can use to login. It went well until such time we have some changes and added the admin side. I only uses 1 table for all user types and I have `role_id` column that defines the users role. So if the `role_id` is `0`, I have to redirect them to the dashboard page whereas if ...
2020/01/21
[ "https://Stackoverflow.com/questions/59835221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6643271/" ]
You can try it ``` public function login(UserLoginRequest $request) { // Attempt to log the user in if (!Auth::guard('user')->attempt(['email' => $request->email, 'password' => $request->password])) { return redirect()->back() ->withInput($request->only('email')) ...
Check below i have edited the method of login: ``` public function login(UserLoginRequest $request) { // Attempt to log the user in if (Auth::guard('user')->attempt(['email' => $request->email, 'password' => $request->password])) { // Over here this condition will be true when user is succe...
3,685,328
Just wondering if anybody had the same problem with rubygems.org I appluad the decision to consolidated everything on rubygems.org, but when the default was rubyforge - I never had any problems. Now it seems I have a problem updating gems everytime I do a new installation. I mean I can work around it, but downloading ...
2010/09/10
[ "https://Stackoverflow.com/questions/3685328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198424/" ]
The error has disappeared - can't recreate it anymore - so I assume it was a problem with the rubygems server, since nothing changed on my end.
> > Which leads me to believe it has nothing to do with my ruby setup, but is actually a problem on rubygems.org > > > Not necessarily. `502` only means that *some* gateway, somewhere, *anywhere*, between you and rubygems.org didn't respond properly. This could be pretty much any server that sits in between you a...
18,580,267
I have 3 Class firs for get data from database second for common works other for show table. ``` public class TableContent { private final Vector<String> headers; private final Vector<Vector<String>> content; public TableContent(final Vector<String> headers, final Vector<Vector<String>> content) { this.header...
2013/09/02
[ "https://Stackoverflow.com/questions/18580267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900445/" ]
According to the link below, my thoughts are confirmed. A 301 is fine as it forwards everything including page rank to the "new" site. In your case this-is-mine.com. A 302 could/would be a problem for SEO. <http://seo-hacker.com/301-302-redirect-affect-seo/>
If your current website is ranking well then don't disturb it. There is no benefits in pointing multiple domains on one website. You can also make a single page website on the new domain and optimize it for Google and link with your old one. If you still want to do this then do a 301 redirect but make sure that the do...
7,808,991
I can't get changeuserjudge.php to open. I've put it in several other places without any success whatsoever. Can anyone tell me why this is? JQuery: ``` $('#userCreateSave').click(function(){ var success = false; var createUserName = $('#createUserName').val(); ...
2011/10/18
[ "https://Stackoverflow.com/questions/7808991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902929/" ]
Instead of setting a boolean called `success`, create a function called `success()`, and execute it once the request has finished. Your code doesn't work as intended, because `success` is false immediately after the `$.ajax()` call. Execution model: > > `.ajax()` > > `success == false` > > AJAX finished: set ...
you should include ``` window.open("changeuserjudge.php"); ``` within the sucess callback function , also make sure to log to see wether the sucess function is executed or not ``` console.log("success") ``` the local variable success you created has nothing to do with the option sucess , it's always gonna be f...
7,808,991
I can't get changeuserjudge.php to open. I've put it in several other places without any success whatsoever. Can anyone tell me why this is? JQuery: ``` $('#userCreateSave').click(function(){ var success = false; var createUserName = $('#createUserName').val(); ...
2011/10/18
[ "https://Stackoverflow.com/questions/7808991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902929/" ]
why don't you put the open within your success function. thereby making sure to call it when the ajax call is completed. it won't be setting it to true because ajax is asynchronous
you should include ``` window.open("changeuserjudge.php"); ``` within the sucess callback function , also make sure to log to see wether the sucess function is executed or not ``` console.log("success") ``` the local variable success you created has nothing to do with the option sucess , it's always gonna be f...
7,808,991
I can't get changeuserjudge.php to open. I've put it in several other places without any success whatsoever. Can anyone tell me why this is? JQuery: ``` $('#userCreateSave').click(function(){ var success = false; var createUserName = $('#createUserName').val(); ...
2011/10/18
[ "https://Stackoverflow.com/questions/7808991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902929/" ]
the first a in ajax means asynchronous, meaning the success callback gets called out of the normal flow and thus after the `if(success)` statement. you should put the `window.open("changeuserjudge.php");` inside the success callback.
you should include ``` window.open("changeuserjudge.php"); ``` within the sucess callback function , also make sure to log to see wether the sucess function is executed or not ``` console.log("success") ``` the local variable success you created has nothing to do with the option sucess , it's always gonna be f...
14,612,143
I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below: * Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML) * Session fixation and hijacking * Cross-Site Vulnerabilities (Scripting, Request Forgery) * Mass Assignment * *insert relevant concern ...
2013/01/30
[ "https://Stackoverflow.com/questions/14612143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438550/" ]
I wrote a blog post that gives a great starting point on [Writing Secure Express.js Apps](https://blog.liftsecurity.io/2012/12/07/writing-secure-express-js-apps). It covers a few other things beyond csrf and helmet as was mentioned by zeMirco. The other thing is you can't compare express.js to rails. They are apples a...
Two modules I can immediately think of: 1. [csrf](http://www.senchalabs.org/connect/csrf.html): CRSF protection middleware. 2. [helmet](https://github.com/evilpacket/helmet): Middleware that implement various security headers
14,612,143
I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below: * Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML) * Session fixation and hijacking * Cross-Site Vulnerabilities (Scripting, Request Forgery) * Mass Assignment * *insert relevant concern ...
2013/01/30
[ "https://Stackoverflow.com/questions/14612143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438550/" ]
Two modules I can immediately think of: 1. [csrf](http://www.senchalabs.org/connect/csrf.html): CRSF protection middleware. 2. [helmet](https://github.com/evilpacket/helmet): Middleware that implement various security headers
You should be aware that if you specify a catch-all error handler, you should NOT restart the server or do anything blocking in that handler in response to USER errors (the `4xx` range) because it could lead to a DOS vulnerability. This vulnerability is addressed automatically in `express-error-handler`, and the servic...
14,612,143
I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below: * Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML) * Session fixation and hijacking * Cross-Site Vulnerabilities (Scripting, Request Forgery) * Mass Assignment * *insert relevant concern ...
2013/01/30
[ "https://Stackoverflow.com/questions/14612143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438550/" ]
I wrote a blog post that gives a great starting point on [Writing Secure Express.js Apps](https://blog.liftsecurity.io/2012/12/07/writing-secure-express-js-apps). It covers a few other things beyond csrf and helmet as was mentioned by zeMirco. The other thing is you can't compare express.js to rails. They are apples a...
One thing to be wary of is bodyParser. See <http://andrewkelley.me/post/do-not-use-bodyparser-with-express-js.html>
14,612,143
I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below: * Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML) * Session fixation and hijacking * Cross-Site Vulnerabilities (Scripting, Request Forgery) * Mass Assignment * *insert relevant concern ...
2013/01/30
[ "https://Stackoverflow.com/questions/14612143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438550/" ]
I wrote a blog post that gives a great starting point on [Writing Secure Express.js Apps](https://blog.liftsecurity.io/2012/12/07/writing-secure-express-js-apps). It covers a few other things beyond csrf and helmet as was mentioned by zeMirco. The other thing is you can't compare express.js to rails. They are apples a...
You should be aware that if you specify a catch-all error handler, you should NOT restart the server or do anything blocking in that handler in response to USER errors (the `4xx` range) because it could lead to a DOS vulnerability. This vulnerability is addressed automatically in `express-error-handler`, and the servic...
14,612,143
I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below: * Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML) * Session fixation and hijacking * Cross-Site Vulnerabilities (Scripting, Request Forgery) * Mass Assignment * *insert relevant concern ...
2013/01/30
[ "https://Stackoverflow.com/questions/14612143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438550/" ]
One thing to be wary of is bodyParser. See <http://andrewkelley.me/post/do-not-use-bodyparser-with-express-js.html>
You should be aware that if you specify a catch-all error handler, you should NOT restart the server or do anything blocking in that handler in response to USER errors (the `4xx` range) because it could lead to a DOS vulnerability. This vulnerability is addressed automatically in `express-error-handler`, and the servic...
13,040,793
I have a Visual Studio 2012 TypeScript project. When I first made the project I added 2 new .ts files these were Framework.ts & Graphics.ts. I recently added two more TypeScript files to be declaration files and named them .d.ts such as Framework.d.ts and Graphics.d.ts. The interesting part is that all 4 of these files...
2012/10/23
[ "https://Stackoverflow.com/questions/13040793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769741/" ]
If they are as you say, declaration files, then they will have no javascript output. I think you do not need to 'add' these to the project or at the very least, do not bother applying the TypeScriptCompile build action on them. You can just include them in the other source files using ``` ///<reference path="Framewor...
I'm not sure this is your case or not, but there are some issues regarding with .ts file encoding. Unfortunately TypeScript cannot compile UTF-8 **with** signature. You might choose another save option by "FILE"-->"Advanced Save Options"--> Select "UTF-8 without signature". Check current issue. <http://typescript.cod...
31,446,341
I am trying to execute the below query from Ecllips i am getting the following error. ``` rs = stmt.executeQuery("select" +"sum(pr.amount)" +"from trans_log tl," +"payment_detail pp," +"pft_trans_reltn pr," +"pft_encntr pe," +"encounter e," +"account a" +"where" +"pr.beg_effective_dt_tm >= TO_DATE('01/JUN/2015 00:00:...
2015/07/16
[ "https://Stackoverflow.com/questions/31446341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4969096/" ]
Add whitespaces on every line. Try to use like this: ``` rs = stmt.executeQuery("select" +" sum(pr.amount)" +" from trans_log tl," +" payment_detail pp," +" pft_trans_reltn pr," +" pft_encntr pe," +" encounter e," +" account a" +" where" +" pr.beg_effective_dt_tm >= TO_DATE('01/JUN/2015 00:00:00', 'dd/mm/yy hh24:mi:ss...
if you have ``` rs = stmt.executeQuery("select" +"sum(pr.amount)" ``` then the string of the sql that it is trying to execute is ``` selectsum(pr.amount) ``` as you can see you need some white space. Also the date mask ``` TO_DATE('01/JUN/2015 00:00:00', 'dd/mm/yy hh24:mi:ss') ``` is incorrect, try using `MO...
24,917,214
I am learning spring 3 from a book and I get an exception in the first example itself. It is given below. My project can be downloaded as a zip file from the link - <https://github.com/double-whammy/prospring3.git> My environment - Eclipse STS (Eclipse for Spring) Exception: ``` INFO t.support.ClassPathXmlApplicati...
2014/07/23
[ "https://Stackoverflow.com/questions/24917214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3838094/" ]
It is because your xml is a invalid: the header has a mistake: there the `xsi` attribute value needs its double quotes! ``` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ``` --- `<bean id="renderer" class="com.apress.prospring3.ch2.StandardOutMessageRenderer" p:messageProvider-ref="provider"/>` I do not ...
The error is because there are no quotes around the value of xmlns:xsi. Correction - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Pro spring 3 book sucks. full xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSc...
24,917,214
I am learning spring 3 from a book and I get an exception in the first example itself. It is given below. My project can be downloaded as a zip file from the link - <https://github.com/double-whammy/prospring3.git> My environment - Eclipse STS (Eclipse for Spring) Exception: ``` INFO t.support.ClassPathXmlApplicati...
2014/07/23
[ "https://Stackoverflow.com/questions/24917214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3838094/" ]
It is because your xml is a invalid: the header has a mistake: there the `xsi` attribute value needs its double quotes! ``` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ``` --- `<bean id="renderer" class="com.apress.prospring3.ch2.StandardOutMessageRenderer" p:messageProvider-ref="provider"/>` I do not ...
The problem you have is related to the fact that maven only picks one of the spring.handlers files from all the different spring jars. To solve this use the following link: <http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#Merging_Content_of_Specific_Files_with_AppendingTransforme...
24,917,214
I am learning spring 3 from a book and I get an exception in the first example itself. It is given below. My project can be downloaded as a zip file from the link - <https://github.com/double-whammy/prospring3.git> My environment - Eclipse STS (Eclipse for Spring) Exception: ``` INFO t.support.ClassPathXmlApplicati...
2014/07/23
[ "https://Stackoverflow.com/questions/24917214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3838094/" ]
You can not use: `p:messageProvider-ref="provider"`, it was in spring 2.5 use this: ``` <bean id="renderer" class="com.appress.prospring3.ch2.StandardOutMessageRenderer"> <property name="messageProvider" ref="provider"></property> </bean> ```
The error is because there are no quotes around the value of xmlns:xsi. Correction - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Pro spring 3 book sucks. full xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSc...
24,917,214
I am learning spring 3 from a book and I get an exception in the first example itself. It is given below. My project can be downloaded as a zip file from the link - <https://github.com/double-whammy/prospring3.git> My environment - Eclipse STS (Eclipse for Spring) Exception: ``` INFO t.support.ClassPathXmlApplicati...
2014/07/23
[ "https://Stackoverflow.com/questions/24917214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3838094/" ]
You can not use: `p:messageProvider-ref="provider"`, it was in spring 2.5 use this: ``` <bean id="renderer" class="com.appress.prospring3.ch2.StandardOutMessageRenderer"> <property name="messageProvider" ref="provider"></property> </bean> ```
The problem you have is related to the fact that maven only picks one of the spring.handlers files from all the different spring jars. To solve this use the following link: <http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#Merging_Content_of_Specific_Files_with_AppendingTransforme...
52,424,524
I want to call a function inside that same function and outside also. How does it in javascript? **Js:** ``` someFunction(function repeat(result) { document.body.innerHTML += '<br>' + result.winner; if (result.winner) { someFunction(repeat); } }); someFunction.repeat(); ```
2018/09/20
[ "https://Stackoverflow.com/questions/52424524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10161204/" ]
```js var someFunction = function( callback ) { // Do some things that belong to someFunction, like creating the result object. var result = { winner: true }; // Call the repeat function, using the result as the parameter. callback( result ); }; var endless_loop_protection = 0; var repeat = funct...
I guess you want to implement it using recursion, this might help you.Change you condition and output in code as you expect. ```js function someFunction(result) { document.body.innerHTML += '<br>' + result; result--; if (result===0) { return; } return someFunction(result); } s...
84,532
I'll be in Prague at the end of this month (24th, 29-31 Dec) and I would like to buy some bakeware products such as Silpat silicon mat and stand mixer and cookie sheet. Is there an area popular for its baking or cake supply stores that are open over the Christmas period?
2016/12/17
[ "https://travel.stackexchange.com/questions/84532", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/20691/" ]
No, there is no area in Prague famous for cooking supplies, as most of that stuff is made abroad anyway. If you need to buy some around Christmas, visit any large hypermarket (e.g. the [Tesco near Andel](http://itesco.cz/prodejny/obchody-tesco/hypermarket-praha-novy-smichov) metro station) - they will be open until **1...
Been there, done that... I didn't find any professional baking supplies in Albert, Tesco or other similar hypermarkets. What I found was a bakeware store in Palladium center and Tescoma store in Černý Most Prague Metro station.
56,748,459
I wanna ask your opinion about this one… when creating a statefull widget, we need to create a state for it. and this is tiresome when I need to have multiple widgets that changes…. I wanna create it more simpler way bu creating only one Statefullwidget, but with multiple State…. basically like this: ``` class MyWidg...
2019/06/25
[ "https://Stackoverflow.com/questions/56748459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2145360/" ]
That won't work. Using such code, you may find yourself losing the state of `MyState.state` after something updated in the widget tree (hot-reload, keyboard opens, ...) Not only that, but the property `context` of your custom `State` will never be set and you'll be missing out on some health checks from Flutter. It ...
If the main purpose is to abbreviate the syntax I don't think it is the right approach. You can take a look at the snippets to autogenerate stateful widgets with VSCode or with Android Studio (`stful` in VSCode). Other thing you can take a look at is Flutter Hooks (based on React Hooks), which can abbreviate a lot the ...
56,748,459
I wanna ask your opinion about this one… when creating a statefull widget, we need to create a state for it. and this is tiresome when I need to have multiple widgets that changes…. I wanna create it more simpler way bu creating only one Statefullwidget, but with multiple State…. basically like this: ``` class MyWidg...
2019/06/25
[ "https://Stackoverflow.com/questions/56748459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2145360/" ]
That won't work. Using such code, you may find yourself losing the state of `MyState.state` after something updated in the widget tree (hot-reload, keyboard opens, ...) Not only that, but the property `context` of your custom `State` will never be set and you'll be missing out on some health checks from Flutter. It ...
Theoretically it might be fine, but it might be worth checking how to use a mixin rather than inheritance.
36,574,152
I want to ask the user to input only integer, later which will be stored in a variable. If user enters a string input, then prompt user to enter a valid integer,string is not allowed. Thanks
2016/04/12
[ "https://Stackoverflow.com/questions/36574152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6193509/" ]
``` a=input() try: int(a) print("Valid") except: print("Invalid") ``` > > Try and except are used in error handling. I am taking an input and I am trying to convert it into an integer. If an alphabet or special character is given then an error arises in converting the string to an integer and the program follo...
try this ``` response = '' while not isinstance(response, int): try: response = int(raw_input('MSG :')) except: print 'Not int' continue ```
2,673,926
> > $$\\A\mathbf v - \lambda \mathbf v=0$$ > $$\\(A - \lambda) \mathbf v=0$$ > > > since the equation looks like to be correct. how to explain that it is not? (without examples) I know that$\ I$ makes no change for $\lambda \mathbf v$ and i only found unpersuasive explains like this one "We needed to do this be...
2018/03/02
[ "https://math.stackexchange.com/questions/2673926", "https://math.stackexchange.com", "https://math.stackexchange.com/users/304721/" ]
What you put in quotes *is* the explanation. Why try to do this without an example? $2 \times 2$ should be convincing, particularly if you note the ambiguity: perhaps "subtracting $\lambda$" should mean subtracting it from all four matrix entries, not just from the two on the diagonal. How would you distinguish?
The size of $A$ and $\lambda$ are not the same, hence the subtraction is not well defined. While you can define $A- \lambda = A - \lambda I$, until you do so, the subtraction is not compatible and it might not be clear to other readers of what you are doing. We do call a diagonal matrix with identical diagonal entrie...
2,673,926
> > $$\\A\mathbf v - \lambda \mathbf v=0$$ > $$\\(A - \lambda) \mathbf v=0$$ > > > since the equation looks like to be correct. how to explain that it is not? (without examples) I know that$\ I$ makes no change for $\lambda \mathbf v$ and i only found unpersuasive explains like this one "We needed to do this be...
2018/03/02
[ "https://math.stackexchange.com/questions/2673926", "https://math.stackexchange.com", "https://math.stackexchange.com/users/304721/" ]
The size of $A$ and $\lambda$ are not the same, hence the subtraction is not well defined. While you can define $A- \lambda = A - \lambda I$, until you do so, the subtraction is not compatible and it might not be clear to other readers of what you are doing. We do call a diagonal matrix with identical diagonal entrie...
I guess you're thinking of "substracting a scalar from a matrix" as "substracting a scalar from each element of a matrix". Let's call $\star$ this operation. Notice that $A-\lambda I \neq A\star \lambda$. For instance, with $A = I$ and $\lambda = 1$ : $$ A - \lambda I = I - 1\times I = 0$$ while $$A \star \lambda = I\...
2,673,926
> > $$\\A\mathbf v - \lambda \mathbf v=0$$ > $$\\(A - \lambda) \mathbf v=0$$ > > > since the equation looks like to be correct. how to explain that it is not? (without examples) I know that$\ I$ makes no change for $\lambda \mathbf v$ and i only found unpersuasive explains like this one "We needed to do this be...
2018/03/02
[ "https://math.stackexchange.com/questions/2673926", "https://math.stackexchange.com", "https://math.stackexchange.com/users/304721/" ]
The size of $A$ and $\lambda$ are not the same, hence the subtraction is not well defined. While you can define $A- \lambda = A - \lambda I$, until you do so, the subtraction is not compatible and it might not be clear to other readers of what you are doing. We do call a diagonal matrix with identical diagonal entrie...
The field of scalars embeds into the matrix ring via $\lambda \mapsto \lambda I$, therefore you can identify $\lambda \in \Bbb{k}$ the field with $\lambda I$. Thus the notation is well-defined.
2,673,926
> > $$\\A\mathbf v - \lambda \mathbf v=0$$ > $$\\(A - \lambda) \mathbf v=0$$ > > > since the equation looks like to be correct. how to explain that it is not? (without examples) I know that$\ I$ makes no change for $\lambda \mathbf v$ and i only found unpersuasive explains like this one "We needed to do this be...
2018/03/02
[ "https://math.stackexchange.com/questions/2673926", "https://math.stackexchange.com", "https://math.stackexchange.com/users/304721/" ]
What you put in quotes *is* the explanation. Why try to do this without an example? $2 \times 2$ should be convincing, particularly if you note the ambiguity: perhaps "subtracting $\lambda$" should mean subtracting it from all four matrix entries, not just from the two on the diagonal. How would you distinguish?
I guess you're thinking of "substracting a scalar from a matrix" as "substracting a scalar from each element of a matrix". Let's call $\star$ this operation. Notice that $A-\lambda I \neq A\star \lambda$. For instance, with $A = I$ and $\lambda = 1$ : $$ A - \lambda I = I - 1\times I = 0$$ while $$A \star \lambda = I\...
2,673,926
> > $$\\A\mathbf v - \lambda \mathbf v=0$$ > $$\\(A - \lambda) \mathbf v=0$$ > > > since the equation looks like to be correct. how to explain that it is not? (without examples) I know that$\ I$ makes no change for $\lambda \mathbf v$ and i only found unpersuasive explains like this one "We needed to do this be...
2018/03/02
[ "https://math.stackexchange.com/questions/2673926", "https://math.stackexchange.com", "https://math.stackexchange.com/users/304721/" ]
What you put in quotes *is* the explanation. Why try to do this without an example? $2 \times 2$ should be convincing, particularly if you note the ambiguity: perhaps "subtracting $\lambda$" should mean subtracting it from all four matrix entries, not just from the two on the diagonal. How would you distinguish?
The field of scalars embeds into the matrix ring via $\lambda \mapsto \lambda I$, therefore you can identify $\lambda \in \Bbb{k}$ the field with $\lambda I$. Thus the notation is well-defined.
116,979
I installes electrum on admin usage. For security reasons I do not want to use admin account to use the wallet (the computer has no other use). I want to use normal account. So I created another account. It turns out that electrum not available on other accounts. So I reinstall electrum on that other account. I st...
2023/01/31
[ "https://bitcoin.stackexchange.com/questions/116979", "https://bitcoin.stackexchange.com", "https://bitcoin.stackexchange.com/users/1498/" ]
Per Electrum's github, this issue appears to be Windows-specific and is caused by `pyinstaller` (an upstream dependency) running under the admin context. This means that the installer will only create icons and shortcuts for the admin account, even when run from a user account. Take a look at <https://github.com/spesm...
It looks like electrum is not designed to be installed on non admin account. So I changed the account into admin. I install electrum and I got things working
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Others have already stated why they believe that 100 is an acceptable constant here. This answer shows how you can get Sonar to accept that. Under `your-sonar-domain/profiles/`, you can edit quality profiles, and the rules in them. The "Magic Number" rule is customisable, you can specify certain numbers for the rule t...
Any number that remains unnamed remains a magic number. It's not related common usage as common usage is relative. The problem with it is "when" or "where" to draw a line... when does a number changes its state to non-magic... 2,71828... may not be magic for mathematicians (Euler) 1760 may not be a magic number for a...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Some numbers are called 'magic' because it is unclear where they come from. I think in this particular case, it is clear that 100 originates from the definition of percent. However, if you wish you can define a constant `PERCENTS_IN_UNIT_RATE=100` instead of using it directly. Violations reported by code analysis tool...
If forced to use a symbol, I might call it N100. That way you can tell what its value is. A long time ago I saw this done for common constants. And negative numbers were prefixed with "M". Why did they do this? Because the computer instruction set couldn't load numbers in line ("immediate"); they had to be fetched from...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Some numbers are called 'magic' because it is unclear where they come from. I think in this particular case, it is clear that 100 originates from the definition of percent. However, if you wish you can define a constant `PERCENTS_IN_UNIT_RATE=100` instead of using it directly. Violations reported by code analysis tool...
It technically is since both those 100's have the same context. Similar to me using 32 as a width in several different places. It depends how nitpicky you want to be. In this case I might use something like `MAX_PERCENT`. It does help with readability as well since when I see that I know the calculations have to do wit...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Speaking as a human programmer (i.e. I am not Lint software), your use of "100" there looks fine to me. Wikipedia has an article (without citations) titled [Accepted limited use of magic numbers](http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Accepted_limited_use_of_magic_numbers): IMO your "100" is in th...
I think 100 IS a magic number here. Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percent mille (1/100.000) are used enough to have their own name. I would change your function to `getPerPart(value, part)` and `getFromPart(value, part)`, maybe with a default `get...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Speaking as a human programmer (i.e. I am not Lint software), your use of "100" there looks fine to me. Wikipedia has an article (without citations) titled [Accepted limited use of magic numbers](http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Accepted_limited_use_of_magic_numbers): IMO your "100" is in th...
Although `100` should be fine in source-code, I'm surprised nobody has offered the most *readable* alternative yet. This should be acceptable for both humans and lint-code: Define your constant `PERCENT=0.01`. Then, when you need to do a conversion: ``` rate = discount*PERCENT ``` or ``` discount = rate/PERCENT ...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Speaking as a human programmer (i.e. I am not Lint software), your use of "100" there looks fine to me. Wikipedia has an article (without citations) titled [Accepted limited use of magic numbers](http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Accepted_limited_use_of_magic_numbers): IMO your "100" is in th...
Any number that remains unnamed remains a magic number. It's not related common usage as common usage is relative. The problem with it is "when" or "where" to draw a line... when does a number changes its state to non-magic... 2,71828... may not be magic for mathematicians (Euler) 1760 may not be a magic number for a...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Speaking as a human programmer (i.e. I am not Lint software), your use of "100" there looks fine to me. Wikipedia has an article (without citations) titled [Accepted limited use of magic numbers](http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Accepted_limited_use_of_magic_numbers): IMO your "100" is in th...
Others have already stated why they believe that 100 is an acceptable constant here. This answer shows how you can get Sonar to accept that. Under `your-sonar-domain/profiles/`, you can edit quality profiles, and the rules in them. The "Magic Number" rule is customisable, you can specify certain numbers for the rule t...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Although `100` should be fine in source-code, I'm surprised nobody has offered the most *readable* alternative yet. This should be acceptable for both humans and lint-code: Define your constant `PERCENT=0.01`. Then, when you need to do a conversion: ``` rate = discount*PERCENT ``` or ``` discount = rate/PERCENT ...
It technically is since both those 100's have the same context. Similar to me using 32 as a width in several different places. It depends how nitpicky you want to be. In this case I might use something like `MAX_PERCENT`. It does help with readability as well since when I see that I know the calculations have to do wit...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Others have already stated why they believe that 100 is an acceptable constant here. This answer shows how you can get Sonar to accept that. Under `your-sonar-domain/profiles/`, you can edit quality profiles, and the rules in them. The "Magic Number" rule is customisable, you can specify certain numbers for the rule t...
I think 100 IS a magic number here. Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percent mille (1/100.000) are used enough to have their own name. I would change your function to `getPerPart(value, part)` and `getFromPart(value, part)`, maybe with a default `get...
44,047
Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: > > **'100' is a magic number.** > > > Consider this code: ``` public double getPercent(double rate) { return rate * 100; } public double getRate(double percent) { return percent / 100; } ``` SonarQube will rais...
2014/03/11
[ "https://codereview.stackexchange.com/questions/44047", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/12390/" ]
Some numbers are called 'magic' because it is unclear where they come from. I think in this particular case, it is clear that 100 originates from the definition of percent. However, if you wish you can define a constant `PERCENTS_IN_UNIT_RATE=100` instead of using it directly. Violations reported by code analysis tool...
Others have already stated why they believe that 100 is an acceptable constant here. This answer shows how you can get Sonar to accept that. Under `your-sonar-domain/profiles/`, you can edit quality profiles, and the rules in them. The "Magic Number" rule is customisable, you can specify certain numbers for the rule t...
7,686,193
We are developing an open source project, and we are using Mercurial for source management control. The Mercurial repository for this project is public (we are using Bitbucket). Now we have a client for whom we need to customize our open source software. These customizations must be kept private, so we probably need t...
2011/10/07
[ "https://Stackoverflow.com/questions/7686193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983775/" ]
What you describe is a standard thing with a distributed version control system: developing in two repositories and keeping one a subset of the other. Start by making a clone for the private development: ``` hg clone open private ``` Then go into `private` and make the new features there. Commit as normal. The `priv...
Well in principle the basic model is relatively simple; have a separate private repository which is a clone (branch) of the public one, make all private changes on there, and then regularly merge the public one into the private one. There are no problems in regard to history preservation, I don’t know why you read that...
7,686,193
We are developing an open source project, and we are using Mercurial for source management control. The Mercurial repository for this project is public (we are using Bitbucket). Now we have a client for whom we need to customize our open source software. These customizations must be kept private, so we probably need t...
2011/10/07
[ "https://Stackoverflow.com/questions/7686193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983775/" ]
Well in principle the basic model is relatively simple; have a separate private repository which is a clone (branch) of the public one, make all private changes on there, and then regularly merge the public one into the private one. There are no problems in regard to history preservation, I don’t know why you read that...
Well, some extensions and variations. * For Martin's workflow you can use "Branch Per Task" paradigm (branches have to be created in base project, "Open") and "push -b --new-branch" (publish only branch, not the whole set of changes also in mainline) to "Private", in which branch also must be merged to default. Incre...
7,686,193
We are developing an open source project, and we are using Mercurial for source management control. The Mercurial repository for this project is public (we are using Bitbucket). Now we have a client for whom we need to customize our open source software. These customizations must be kept private, so we probably need t...
2011/10/07
[ "https://Stackoverflow.com/questions/7686193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983775/" ]
Well in principle the basic model is relatively simple; have a separate private repository which is a clone (branch) of the public one, make all private changes on there, and then regularly merge the public one into the private one. There are no problems in regard to history preservation, I don’t know why you read that...
Project as usual consists of a set of modules. In my experience sometime even better to have some modules in separate source-controls repositories. For example, some utility-module or core-module like web-framework or DAO (ORM) module. In this case you able to use branches in source-controls as they **should** be used...
7,686,193
We are developing an open source project, and we are using Mercurial for source management control. The Mercurial repository for this project is public (we are using Bitbucket). Now we have a client for whom we need to customize our open source software. These customizations must be kept private, so we probably need t...
2011/10/07
[ "https://Stackoverflow.com/questions/7686193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983775/" ]
What you describe is a standard thing with a distributed version control system: developing in two repositories and keeping one a subset of the other. Start by making a clone for the private development: ``` hg clone open private ``` Then go into `private` and make the new features there. Commit as normal. The `priv...
Well, some extensions and variations. * For Martin's workflow you can use "Branch Per Task" paradigm (branches have to be created in base project, "Open") and "push -b --new-branch" (publish only branch, not the whole set of changes also in mainline) to "Private", in which branch also must be merged to default. Incre...
7,686,193
We are developing an open source project, and we are using Mercurial for source management control. The Mercurial repository for this project is public (we are using Bitbucket). Now we have a client for whom we need to customize our open source software. These customizations must be kept private, so we probably need t...
2011/10/07
[ "https://Stackoverflow.com/questions/7686193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983775/" ]
What you describe is a standard thing with a distributed version control system: developing in two repositories and keeping one a subset of the other. Start by making a clone for the private development: ``` hg clone open private ``` Then go into `private` and make the new features there. Commit as normal. The `priv...
Project as usual consists of a set of modules. In my experience sometime even better to have some modules in separate source-controls repositories. For example, some utility-module or core-module like web-framework or DAO (ORM) module. In this case you able to use branches in source-controls as they **should** be used...
26,564,728
``` string line, operation, sec, third; int first; getline(cin, line); istringstream(line) >> operation >> first >> sec >> third; ``` the program reads a command from the user then acts according to the operation specified some operation takes only one parameter ``` >>operation_name first_argument ``` if the use...
2014/10/25
[ "https://Stackoverflow.com/questions/26564728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4067598/" ]
You can replace newlines with an empty string. Move the cursor to the beginning of your file and execute this sequence ``` M-x replace-string C-q C-j RET RET ```
You can replace with query replace, *pasting* the newline. 1. mark/copy a newline 2. start at beginning of buffer 3. Alt-% 4. paste the newline and do enter. (for me the buffer says `Query replace ^J with:` ) 5. type space + enter 6. type ! for accept all or y/n for accept/reject per match
57,615
Take metal cans, for instance, and imagine them in any number of uses, functional or purely as an art form. Can your eyes and mind see the potential metal case, bird feeder, or other object in **the simple cast off items**? What about boxes or clothing? What might be done with these? Boxes can usually serve as new stor...
2015/05/25
[ "https://ell.stackexchange.com/questions/57615", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/3751/" ]
A: The event has led to the creating of the new plan. B: The event has led to the creation of the new plan. First, the difference between *creating* and *creation*: *Creating* refers to the activity of creating - not what is created or who is doing the creating. These questions can be answered with objects to narrow...
The first sentence is incorrect. *The* is an article, which you can combine with a noun (*creation*). Because *creating* is a verb, you cannot combine it with *the*. So, your second sentence is correct, but your first is not. Correct would be: > > The event has led to creating the new plan. > > > Note that you ...
57,615
Take metal cans, for instance, and imagine them in any number of uses, functional or purely as an art form. Can your eyes and mind see the potential metal case, bird feeder, or other object in **the simple cast off items**? What about boxes or clothing? What might be done with these? Boxes can usually serve as new stor...
2015/05/25
[ "https://ell.stackexchange.com/questions/57615", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/3751/" ]
A: The event has led to the creating of the new plan. B: The event has led to the creation of the new plan. First, the difference between *creating* and *creation*: *Creating* refers to the activity of creating - not what is created or who is doing the creating. These questions can be answered with objects to narrow...
> > A: This event led to **the** creating of the new plan. > > > B: This event led to **the** creation of the new plan. > > > ***The*** When we use this type of *of* phrase in this way to modify a noun, the larger noun phrase will normally take a definite article. Notice that the purpose of the phrase *of the n...
8,514,602
okay... I know this is a repeat but, nothing is wrong with my xml. r isn't imported and I have tried cleaning my project. It started when I added a .png in my drawble folder and I removed it and the error still protists. I don't know what else to try but it is really frustrating. I have also tried to create new proj...
2011/12/15
[ "https://Stackoverflow.com/questions/8514602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/759645/" ]
Try to delete the R file, it will be automatically recreated & this may resolve the issue. You can find the R file here: ``` Your Project >> gen >> your package Name >> R.java ```
I'm not sure if this can help, but some build problems in eclipse can be solved by deleting errors. Just go to problems view of eclipse, select error and press delete on your keyboard. Then clean project again and build it.
8,514,602
okay... I know this is a repeat but, nothing is wrong with my xml. r isn't imported and I have tried cleaning my project. It started when I added a .png in my drawble folder and I removed it and the error still protists. I don't know what else to try but it is really frustrating. I have also tried to create new proj...
2011/12/15
[ "https://Stackoverflow.com/questions/8514602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/759645/" ]
Try to delete the R file, it will be automatically recreated & this may resolve the issue. You can find the R file here: ``` Your Project >> gen >> your package Name >> R.java ```
Double check your java source file to see if there are any that have "import com.company.R;" statement explicitly defined. If yes, delete them then do a clean on your project. "import com.company.R;" should be never explicitly defined in java source. In some situation, Eclipse attempt to do some auto fix for us by sil...
8,514,602
okay... I know this is a repeat but, nothing is wrong with my xml. r isn't imported and I have tried cleaning my project. It started when I added a .png in my drawble folder and I removed it and the error still protists. I don't know what else to try but it is really frustrating. I have also tried to create new proj...
2011/12/15
[ "https://Stackoverflow.com/questions/8514602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/759645/" ]
Double check your java source file to see if there are any that have "import com.company.R;" statement explicitly defined. If yes, delete them then do a clean on your project. "import com.company.R;" should be never explicitly defined in java source. In some situation, Eclipse attempt to do some auto fix for us by sil...
I'm not sure if this can help, but some build problems in eclipse can be solved by deleting errors. Just go to problems view of eclipse, select error and press delete on your keyboard. Then clean project again and build it.
61,781,345
In my React app, I can see the following code; ``` const pages = [ { pageLink: '/state/:stateCode', view: State, displayName: t('State'), animationDelayForNavbar: 0.7, showInNavbar: false, }, ]; <Route render={({location}) => ( <div className="Almighty-Router"> ...
2020/05/13
[ "https://Stackoverflow.com/questions/61781345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/485743/" ]
Use: ``` with open("list.txt") as f1, open("num.txt", "w") as f2: for line in f1: line = line.strip('\n[]') f2.write(str(len(line.split(','))) + '\n') ```
``` with open("list.txt") as fin, open("num.txt", "w") as fout: input_data = fin.readline() # check if there was any info read from input file if input_data: # split string into list on comma character strs = input_data.replace('[','').split('],') lists = [map(int, s.replace(']','')....
61,781,345
In my React app, I can see the following code; ``` const pages = [ { pageLink: '/state/:stateCode', view: State, displayName: t('State'), animationDelayForNavbar: 0.7, showInNavbar: false, }, ]; <Route render={({location}) => ( <div className="Almighty-Router"> ...
2020/05/13
[ "https://Stackoverflow.com/questions/61781345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/485743/" ]
Use: ``` with open("list.txt") as f1, open("num.txt", "w") as f2: for line in f1: line = line.strip('\n[]') f2.write(str(len(line.split(','))) + '\n') ```
When python try to read a file using default method it generally treats content of that file as a string. So first responsibility is to type cast string content into appropriate content type for that you can not use default type casting method. You can use special package by the name **ast** to type cast the data. ``...
61,781,345
In my React app, I can see the following code; ``` const pages = [ { pageLink: '/state/:stateCode', view: State, displayName: t('State'), animationDelayForNavbar: 0.7, showInNavbar: false, }, ]; <Route render={({location}) => ( <div className="Almighty-Router"> ...
2020/05/13
[ "https://Stackoverflow.com/questions/61781345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/485743/" ]
``` with open("list.txt") as fin, open("num.txt", "w") as fout: input_data = fin.readline() # check if there was any info read from input file if input_data: # split string into list on comma character strs = input_data.replace('[','').split('],') lists = [map(int, s.replace(']','')....
When python try to read a file using default method it generally treats content of that file as a string. So first responsibility is to type cast string content into appropriate content type for that you can not use default type casting method. You can use special package by the name **ast** to type cast the data. ``...
36,138,036
Is there any way in JavaScript to detect when individual `img`s (including gifs) on a page are loaded, so that I could construct a progress bar for the page assets being fully loaded? e.g. something like ``` var $imgs = $('img'); var k = 0, n = $imgs.length; $imgs.onloaded(function(){ $('#progress-bar inner').w...
2016/03/21
[ "https://Stackoverflow.com/questions/36138036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5587809/" ]
As Rayon pointed about maybe you're looking for something like this? ``` var $imgs = $('img'); var k = 0, n = $imgs.length; $imgs.each(function(index){ $(this).onload(function(){ console.log("loaded image number:"+index) $('#progress-bar inner').width((k++ * 100 / n) + '%'); }); }); ```
``` $("<img/>") .on('load', function() { //script }) .on('error', function() { //script }) ```
53,553,287
All of the sources I could find, explain how to check if the PC is in sleep-mode use .NET Framework but I have to use .NET Core as my application has to be cross-platform. I want to replicate something like the below which requires .NET Framework and can check to see if the PC left sleep mode ``` SystemEvents.PowerMo...
2018/11/30
[ "https://Stackoverflow.com/questions/53553287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10696971/" ]
The fact, that the file is in the same directory as the program doesn't matter. If you don't provide a path the program will look for the file in the working directory which might be a total different one. If you want to use a specific directory add your path to the filename. A flexible approach would be to determine ...
I would suggest an easy solution, I got stuck at the same stage. I was coding in VS Code and later realized that the terminal is currently executing code from parent directory. So to import image I just need to get the terminal into my current working directory and then run the program again. Images were load fine wit...
53,553,287
All of the sources I could find, explain how to check if the PC is in sleep-mode use .NET Framework but I have to use .NET Core as my application has to be cross-platform. I want to replicate something like the below which requires .NET Framework and can check to see if the PC left sleep mode ``` SystemEvents.PowerMo...
2018/11/30
[ "https://Stackoverflow.com/questions/53553287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10696971/" ]
The fact, that the file is in the same directory as the program doesn't matter. If you don't provide a path the program will look for the file in the working directory which might be a total different one. If you want to use a specific directory add your path to the filename. A flexible approach would be to determine ...
I've same problem. but for me, it's wrong about file name. ``` *sub_img = os.path.join(img_folder, 'submarine.png.png') self.image = pygame.image.load(sub_img).convert()* ``` I was edit my file name " submarine.png " after downloaded. So, This file is name submarine.png type png. You can fix it by change fil...
58,027,735
I like to know, how to align text vertical in Text Widget. There is an attribute called textAlign. It will align the text center of both vertical and horizontal. So I need to algin text only in vertical. When I set TextAlign.center, [![enter image description here](https://i.stack.imgur.com/SI557.png)](https://i.stac...
2019/09/20
[ "https://Stackoverflow.com/questions/58027735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3782085/" ]
This shoud produce the expected result: ``` def win_los_percent(sdf): sdf['winner wins'] = sdf.groupby('winner').cumcount() sdf['winner losses'] = [(sdf.loc[0:i, 'loser'] == sdf.loc[i, 'winner']).sum() for i in sdf.index] sdf['loser losses'] = sdf.groupby('loser').cumcount() sdf['loser wins'] = [(sdf.l...
The first solution that comes to mind to me is to **use object-oriented programming**. I am proposing some guidelines of an implementation below. You can create a `player` class with attributes `firstName`, `lastName`, `numberWins`, and `numberLosses`. In the constructor, you can set `numberWins` and `numberLosses` t...
58,027,735
I like to know, how to align text vertical in Text Widget. There is an attribute called textAlign. It will align the text center of both vertical and horizontal. So I need to algin text only in vertical. When I set TextAlign.center, [![enter image description here](https://i.stack.imgur.com/SI557.png)](https://i.stac...
2019/09/20
[ "https://Stackoverflow.com/questions/58027735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3782085/" ]
This shoud produce the expected result: ``` def win_los_percent(sdf): sdf['winner wins'] = sdf.groupby('winner').cumcount() sdf['winner losses'] = [(sdf.loc[0:i, 'loser'] == sdf.loc[i, 'winner']).sum() for i in sdf.index] sdf['loser losses'] = sdf.groupby('loser').cumcount() sdf['loser wins'] = [(sdf.l...
Here is my attempt **Explanation** 1. Create new dataframe by combining "winner" and "loser" columns to "player" column and indicate win/loose by "won" column 2. Group new dataframe by "player" and "tournament" and calculate win % using "calc\_winning\_percent" function for each row 3. now split win % of new\_df int...
471,080
The following commands work ``` $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt ``` But this does not ``` $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim: Error reading input, exiting... Vim: preserving files... Vim: Finished. ``` How can I accomplish this (...
2018/09/24
[ "https://unix.stackexchange.com/questions/471080", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/285600/" ]
``` vi -- "$(ls -t | head -n 1)" ``` (that assumes file names don't contain newline characters). Or if using `zsh`: ``` vi ./*(om[1]) ``` Or: ``` vi ./*(.om[1]) ``` To only consider *regular* files. ``` vi ./*(.Dom[1]) ``` To also consider *hidden* files (as if using `ls -At`). Those work regardless of wha...
With your pipeline structure, you could use `xargs` like so: ``` ls -1t | head -1 | xargs vi ```
471,080
The following commands work ``` $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt ``` But this does not ``` $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim: Error reading input, exiting... Vim: preserving files... Vim: Finished. ``` How can I accomplish this (...
2018/09/24
[ "https://unix.stackexchange.com/questions/471080", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/285600/" ]
``` vi -- "$(ls -t | head -n 1)" ``` (that assumes file names don't contain newline characters). Or if using `zsh`: ``` vi ./*(om[1]) ``` Or: ``` vi ./*(.om[1]) ``` To only consider *regular* files. ``` vi ./*(.Dom[1]) ``` To also consider *hidden* files (as if using `ls -At`). Those work regardless of wha...
If you need a more solid solution that doesn’t rely on the flaky output of `ls` you can resort to `stat(1)`. Most implementations have some way to specify a custom output format which can include timestamps to feed to `sort(1)` or an Awk script. Some examples: * with GNU coreutils: ``` stat -L -c '%Y %n' -- * ``` * ...
471,080
The following commands work ``` $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt ``` But this does not ``` $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim: Error reading input, exiting... Vim: preserving files... Vim: Finished. ``` How can I accomplish this (...
2018/09/24
[ "https://unix.stackexchange.com/questions/471080", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/285600/" ]
With your pipeline structure, you could use `xargs` like so: ``` ls -1t | head -1 | xargs vi ```
If you need a more solid solution that doesn’t rely on the flaky output of `ls` you can resort to `stat(1)`. Most implementations have some way to specify a custom output format which can include timestamps to feed to `sort(1)` or an Awk script. Some examples: * with GNU coreutils: ``` stat -L -c '%Y %n' -- * ``` * ...
62,625,605
I'm trying to learn Django and searched for a way to install it and it says that it's better to create a virtual environment instead of installing it globally, so I installed pipenv fine but when I tried to install Django in pipenv it gave me this error and I can't find any answers in any other existing posts. Instala...
2020/06/28
[ "https://Stackoverflow.com/questions/62625605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12481070/" ]
`pipenv` isn't being actively developed anymore, maybe `poetry` will suit your needs better. However, if you just want to use `virtualenv` to manage `dependencies`, we can use `virtualenv` directly. ``` $ pip install virtualenv $ virtualenv django $ source django/bin/activate $ pip install django ``` After using `so...
If you have Python version 3.5 or above. To create a virtual environment is as easy as running the following command in you command line. If you are on windows which is the one I use. ``` python -m venv name #replace name with your custom name, or if you want to use name of current directory just use a dot (.) #activ...
62,625,605
I'm trying to learn Django and searched for a way to install it and it says that it's better to create a virtual environment instead of installing it globally, so I installed pipenv fine but when I tried to install Django in pipenv it gave me this error and I can't find any answers in any other existing posts. Instala...
2020/06/28
[ "https://Stackoverflow.com/questions/62625605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12481070/" ]
`pipenv` isn't being actively developed anymore, maybe `poetry` will suit your needs better. However, if you just want to use `virtualenv` to manage `dependencies`, we can use `virtualenv` directly. ``` $ pip install virtualenv $ virtualenv django $ source django/bin/activate $ pip install django ``` After using `so...
I discovered I didn't add Python to path when I first installed it so I had to reinstall Python (so yes it was indeed a path error).
22,017,316
I have a page layout like this. ``` <body> <section id="s1">...</div> <section id="s2">...</div> <section id="s3">...</div> </body> ``` I need to add class to body tag whenever the `<section>` meet the top by scrolling. like `<body class="s1">` for `#s1` section and `<body class="s2">` for `#s2`. How this can ...
2014/02/25
[ "https://Stackoverflow.com/questions/22017316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2625764/" ]
This is probably what you want: <http://jsbin.com/tabolida/1/edit?html,js,output> ``` var bodyEl = $("body"); $(window).on("scroll", function() { var scrollTop = $(this).scrollTop(); $("section").each(function() { var el = $(this), className = el.attr("id"); if (el.offset().top < s...
You should look up ``` $(window).scrollTop() and $(element).offset() ``` and compare those two in ``` $(window).scroll( function() { } ); ``` There you can see which element is closest to the top border of the window, and act according to that. Is that what you need?
50,874,391
I have multiple `path.data`s configured for my Elasticsearch cluster. The official documentation states that only a single path is used for a single shard, so it's never splitted across multiple paths. I'd like to find a way to finding out which path on which node is used for some specific shard (primary or replica), l...
2018/06/15
[ "https://Stackoverflow.com/questions/50874391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1350552/" ]
You can find that info using the [indices stats API](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/indices-stats.html) by specifying the `level=shards` parameter ``` GET index/_stats?level=shards ``` will return a structure like this ``` "indices": { "listings-master": { "primaries": { ...
Not easily but but by doing a small python script I've the info I want, here the script ```html import json with open('shard.json') as json_file: data = json.load(json_file) print(data.keys()) data=data['indices'] for indice in data: #print(indice) d1=data[indice] shards=d1['shards'] #print(shards,type(...
43,490,043
I have an interface in angularJS with 3 table (on for adding lines) other for displaying and another for displaying and inserting data.I also have inputs and attachments.The interface contains so much data.I work with concept of states.I am new to angular so i don't have a clear idea on how to split this interface.Shou...
2017/04/19
[ "https://Stackoverflow.com/questions/43490043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7844220/" ]
While is a loop that won't end until the condition equates to `false`. So let's say the value for `currentDataLength` changes with every cpu cycle, but is always greater than `0`( or never goes below `0`), it will keep going on. Seeing that you change the value of `currentDataLength` once outside the `while` loop, an...
The while loop never returns because the param `stream` is waiting for the new response from my server. So the `Read(...)` method can never get to the end because it's waiting for the response close. So when it gets to the end (current) of the stream, the main thread will suspend for new response and seems like the a ...
43,490,043
I have an interface in angularJS with 3 table (on for adding lines) other for displaying and another for displaying and inserting data.I also have inputs and attachments.The interface contains so much data.I work with concept of states.I am new to angular so i don't have a clear idea on how to split this interface.Shou...
2017/04/19
[ "https://Stackoverflow.com/questions/43490043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7844220/" ]
I don't think you even need to call `fs.Flush()`because you are inside a `using` block - which implements `IDisposable` and should automatically take care of writing the stream to the file when the object is disposed. I think it might have something to do with the fact that you use a large buffer size than the default...
The while loop never returns because the param `stream` is waiting for the new response from my server. So the `Read(...)` method can never get to the end because it's waiting for the response close. So when it gets to the end (current) of the stream, the main thread will suspend for new response and seems like the a ...
43,430,649
I'm from Turkiye and my level is intermediate. I reply mails in 8 hours at work. My question is about time calculation. **Conditions** ``` 1. Our work starts at 09:00 and finishes at 18:00. 2. Mails must be replied in 8 hours. 3. Mails must be replied only between 09:00 and 18:00. 4. We don't work between 18:00 and t...
2017/04/15
[ "https://Stackoverflow.com/questions/43430649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1748919/" ]
So we can break down your all condition to basically two categories. One, where (Mail Received Time + 8 Hours) is less than or equal to 18:00 Hrs, other is where it falls beyond 18:00 Hrs. Use the formula in the Reply Deadline with formula column and drag it down to get the desired answer `=IF((A7+"8:00"<=TIME(18,0,0)...
Please try the below formula, `=IF(OR(A2<TIME(9,0,0),A2>TIME(18,0,0)),TIME(17,0,0),IF(A2+TIME(8,0,0)<=TIME(18,0,0),A2+TIME(8,0,0),A2+TIME(23,0,0)))` [![enter image description here](https://i.stack.imgur.com/tXQsA.png)](https://i.stack.imgur.com/tXQsA.png) This formula consists of 2 `IF` conditions. The first `IF` ...
43,430,649
I'm from Turkiye and my level is intermediate. I reply mails in 8 hours at work. My question is about time calculation. **Conditions** ``` 1. Our work starts at 09:00 and finishes at 18:00. 2. Mails must be replied in 8 hours. 3. Mails must be replied only between 09:00 and 18:00. 4. We don't work between 18:00 and t...
2017/04/15
[ "https://Stackoverflow.com/questions/43430649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1748919/" ]
So we can break down your all condition to basically two categories. One, where (Mail Received Time + 8 Hours) is less than or equal to 18:00 Hrs, other is where it falls beyond 18:00 Hrs. Use the formula in the Reply Deadline with formula column and drag it down to get the desired answer `=IF((A7+"8:00"<=TIME(18,0,0)...
excelevator solved the problem on reddit also. <https://www.reddit.com/r/excel/comments/65l25n/reply_time_calculation_issue/>
43,430,649
I'm from Turkiye and my level is intermediate. I reply mails in 8 hours at work. My question is about time calculation. **Conditions** ``` 1. Our work starts at 09:00 and finishes at 18:00. 2. Mails must be replied in 8 hours. 3. Mails must be replied only between 09:00 and 18:00. 4. We don't work between 18:00 and t...
2017/04/15
[ "https://Stackoverflow.com/questions/43430649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1748919/" ]
Please try the below formula, `=IF(OR(A2<TIME(9,0,0),A2>TIME(18,0,0)),TIME(17,0,0),IF(A2+TIME(8,0,0)<=TIME(18,0,0),A2+TIME(8,0,0),A2+TIME(23,0,0)))` [![enter image description here](https://i.stack.imgur.com/tXQsA.png)](https://i.stack.imgur.com/tXQsA.png) This formula consists of 2 `IF` conditions. The first `IF` ...
excelevator solved the problem on reddit also. <https://www.reddit.com/r/excel/comments/65l25n/reply_time_calculation_issue/>
188,623
Just wondering whether this is possible? i.e. once a modal is open, close it by clicking anywhere on the grey backdrop? I've tried invoking my custom close-modal function via: - Adding onclick to the slds-backdrop div - Adding onblur to the slds-modal\_\_container div - Adding onclick to the slds-modal (just ...
2017/08/16
[ "https://salesforce.stackexchange.com/questions/188623", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/12016/" ]
It is possible, my approach is/was to create a static resource with an eventlistener on clicks outside of the scope of my modal. i then referenced the static resource in my lightning component and on click I simply change the classes (add/remove) For my actual modal, I have 1 eventlistener which on click I trigger an...
In addition to the previous answer. You can implement such logic within Aura-component without any imports: ``` <div role="dialog" aura:id="modal" class="slds-modal" onclick="{!c.closeModal}"> <div class="slds-modal__container"> <header class="slds-modal__header slds-modal__header_empty"> <lightning:button...
188,623
Just wondering whether this is possible? i.e. once a modal is open, close it by clicking anywhere on the grey backdrop? I've tried invoking my custom close-modal function via: - Adding onclick to the slds-backdrop div - Adding onblur to the slds-modal\_\_container div - Adding onclick to the slds-modal (just ...
2017/08/16
[ "https://salesforce.stackexchange.com/questions/188623", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/12016/" ]
It is possible, my approach is/was to create a static resource with an eventlistener on clicks outside of the scope of my modal. i then referenced the static resource in my lightning component and on click I simply change the classes (add/remove) For my actual modal, I have 1 eventlistener which on click I trigger an...
I tried this, and WORKING! CloseModel.cmp ``` <aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName"> <aura:attribute name="isOpen" type="boolean" default="false"/> <div onclick="{!c.stopPropagation}"> <lightning:button varian...
188,623
Just wondering whether this is possible? i.e. once a modal is open, close it by clicking anywhere on the grey backdrop? I've tried invoking my custom close-modal function via: - Adding onclick to the slds-backdrop div - Adding onblur to the slds-modal\_\_container div - Adding onclick to the slds-modal (just ...
2017/08/16
[ "https://salesforce.stackexchange.com/questions/188623", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/12016/" ]
In addition to the previous answer. You can implement such logic within Aura-component without any imports: ``` <div role="dialog" aura:id="modal" class="slds-modal" onclick="{!c.closeModal}"> <div class="slds-modal__container"> <header class="slds-modal__header slds-modal__header_empty"> <lightning:button...
I tried this, and WORKING! CloseModel.cmp ``` <aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName"> <aura:attribute name="isOpen" type="boolean" default="false"/> <div onclick="{!c.stopPropagation}"> <lightning:button varian...
61,328,985
How can I change the behaviour of a b-dropdown-item-button within a b-dropdown-component so that it does not close automatically when I click on it? The dropdown is syntactically structured as follows: ``` <b-dropdown> <b-dropdown-item-button> <span>Mark as read</span> <b-dropdown-item-button> <b...
2020/04/20
[ "https://Stackoverflow.com/questions/61328985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8668135/" ]
Placing `@click.native.capture.stop` directive on any subcomponent of `<b-dropdown>` will prevent it from closing the dropdown. For example: ``` <b-dropdown> <b-dropdown-item-button @click.native.capture.stop> <span>Mark as read</span> <b-dropdown-item-button> <b-dropdown-group @click.native.capture.stop> ...
> > * First: make a reference which you want to stay show (i.e, b-drowpdown) > * then make an function onClick which will work on click of button > * finally remain shown the dropdown by this.$refs.dropdown.show(true) which override the defaults > > > ``` <template> <b-dropdown ref="dropdown"> <b-dropd...
61,328,985
How can I change the behaviour of a b-dropdown-item-button within a b-dropdown-component so that it does not close automatically when I click on it? The dropdown is syntactically structured as follows: ``` <b-dropdown> <b-dropdown-item-button> <span>Mark as read</span> <b-dropdown-item-button> <b...
2020/04/20
[ "https://Stackoverflow.com/questions/61328985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8668135/" ]
> > * First: make a reference which you want to stay show (i.e, b-drowpdown) > * then make an function onClick which will work on click of button > * finally remain shown the dropdown by this.$refs.dropdown.show(true) which override the defaults > > > ``` <template> <b-dropdown ref="dropdown"> <b-dropd...
Add a prevent modifier `@click.prevent` to the element which shouldn't close the dropdown on click: ```html <b-dropdown> <b-dropdown-text> <b-form-input @click.prevent></b-form-input> </b-dropdown-text> </b-dropdown> ``` Docs: <https://v2.vuejs.org/v2/guide/events.html#Event-Modifiers>
61,328,985
How can I change the behaviour of a b-dropdown-item-button within a b-dropdown-component so that it does not close automatically when I click on it? The dropdown is syntactically structured as follows: ``` <b-dropdown> <b-dropdown-item-button> <span>Mark as read</span> <b-dropdown-item-button> <b...
2020/04/20
[ "https://Stackoverflow.com/questions/61328985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8668135/" ]
Placing `@click.native.capture.stop` directive on any subcomponent of `<b-dropdown>` will prevent it from closing the dropdown. For example: ``` <b-dropdown> <b-dropdown-item-button @click.native.capture.stop> <span>Mark as read</span> <b-dropdown-item-button> <b-dropdown-group @click.native.capture.stop> ...
Add a prevent modifier `@click.prevent` to the element which shouldn't close the dropdown on click: ```html <b-dropdown> <b-dropdown-text> <b-form-input @click.prevent></b-form-input> </b-dropdown-text> </b-dropdown> ``` Docs: <https://v2.vuejs.org/v2/guide/events.html#Event-Modifiers>
64,466,829
I have 4 APIs and I need to fetch details and store it on a bar graph according to the name (Name on x-axis and Details on y-axis, 4 bars for each name): The API result shows following details: API 1: Ontime ``` [ { "Name": "Apoorva", "Ontime": 3 }, { "Name": "Rani", "Onti...
2020/10/21
[ "https://Stackoverflow.com/questions/64466829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
One a possible easy solution will be to use `ShapeableImageView` ``` <com.google.android.material.imageview.ShapeableImageView android:id="@+id/iv" android:layout_width="50dp" android:layout_height="50dp" android:padding="4dp" app:shapeAppearanceOverlay="@style/ImageCircleTh...
I managed figure out a little bit of a workaround for those wanting to create `ImageViews` where the background colour can dynamically change. All you will need to have is an `PNG` of a sqaure with a transparent circle in the middle, where the colour of your square will need to match the colour of the background that y...
35,042,934
``` @echo off set Counter=0 set folders=(14370437 14707356 16048938 16818856) for %%f in (*.jpg) do call :p "%%f" goto :eof :p set /a Counter+=1 set /a X=Counter %% 6 %name% = folders[Counter] ??? mkdir C:\output\%name% if %X%==1 copy %1 C:\output\%name%\front-image.jpg goto :eof ``` I have a...
2016/01/27
[ "https://Stackoverflow.com/questions/35042934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/521446/" ]
`batch` can't work with lists or arrays, but you can simulate an array: ``` @echo off setlocal enabledelayedexpansion set folders=(14370437 14707356 16048938 16818856) set i=0 for %%i in %folders% do ( set /a i+=1 set element[!i!]=%%i ) set element echo %element[2]% ``` Although this works, I strongly suggest, u...
You may "shift" or "rotate" the elements in a list this way: ``` @echo off set Counter=0 set folders=14370437 14707356 16048938 16818856 set "folders2=%folders%" for %%f in (*.jpg) do call :p "%%f" goto :eof :p set /a Counter+=1 set /a X=Counter %% 6 for /F "tokens=1*" %%a in ("%folders2%") do ( ...
19,928,832
This is my code, in emulator the code work correctly and print ``` <!doctype html> <html itemscope="" itemtype="http://schema.org/WebPage"> <head> <meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you'...
2013/11/12
[ "https://Stackoverflow.com/questions/19928832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1988022/" ]
Use a thread and a handler to easily run the network related operations ``` //Handler to send commands to UI thread Handler handler = new Handler(); Thread th = new Thread(new Runnable() { public void run() { try { url = new URL("http://google.com/"); } catch (MalformedURLException e) { textView...
Use Jsoup Library for HTml Parsing for network operation use asynctask or below code <http://jsoup.org/> ``` public static int SDK_INT = android.os.Build.VERSION.SDK_INT; if (SDK_INT >= 10) { ThreadPolicy tp = ThreadPolicy.LAX; StrictMode.setThreadPolicy(tp); } HttpClient client = new DefaultHttpClient(); Ht...
29,220
In a school setting, what is a way to allude that a school is full of students, without making new characters or overusing pre-existing ones? A school is the main setting of a book. The main and secondary characters majorly consist of students. In classes and school gatherings, I assume it would be overwhelming to alw...
2017/07/14
[ "https://writers.stackexchange.com/questions/29220", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/25782/" ]
If a character knows the people in a crowded scene, they think of them by name, which indicates to the reader that they are in familiar surroundings. If they don't know the people in a scene, then they will tend to notice some prominent feature or action they are performing. If you don't name the individual students ...
If they won't be mentioned again, it's not worth giving them a name - so your first example would be somewhat wasteful. The reader doesn't need to know that the redhead with an aggressive attitude is called Rob (and maybe it's realistic that your character, Suzy, doesn't even know him by name - exspecially if she is in...
29,220
In a school setting, what is a way to allude that a school is full of students, without making new characters or overusing pre-existing ones? A school is the main setting of a book. The main and secondary characters majorly consist of students. In classes and school gatherings, I assume it would be overwhelming to alw...
2017/07/14
[ "https://writers.stackexchange.com/questions/29220", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/25782/" ]
This is why the clique system is such a wonderful tool for authors. For any group that tends to hang out you only need to ever name one or two of the most prominent members, and then describe actions of those groups by reference to those members. Compare: "Harold, Mike, Jules, Ron, Gregor and Paul were being rowdy as ...
If they won't be mentioned again, it's not worth giving them a name - so your first example would be somewhat wasteful. The reader doesn't need to know that the redhead with an aggressive attitude is called Rob (and maybe it's realistic that your character, Suzy, doesn't even know him by name - exspecially if she is in...
29,220
In a school setting, what is a way to allude that a school is full of students, without making new characters or overusing pre-existing ones? A school is the main setting of a book. The main and secondary characters majorly consist of students. In classes and school gatherings, I assume it would be overwhelming to alw...
2017/07/14
[ "https://writers.stackexchange.com/questions/29220", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/25782/" ]
If a character knows the people in a crowded scene, they think of them by name, which indicates to the reader that they are in familiar surroundings. If they don't know the people in a scene, then they will tend to notice some prominent feature or action they are performing. If you don't name the individual students ...
This is why the clique system is such a wonderful tool for authors. For any group that tends to hang out you only need to ever name one or two of the most prominent members, and then describe actions of those groups by reference to those members. Compare: "Harold, Mike, Jules, Ron, Gregor and Paul were being rowdy as ...