Search is not available for this dataset
qid
int64
1
74.7M
question
stringlengths
1
70k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
0
115k
response_k
stringlengths
0
60.5k
score_j
int64
0
14
score_k
int64
-1
10
47,539,905
I am very new to CSS and javascript, so take it easy on me. I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below) I have tried the following in Tampermonkey, but it doesn't seem to work: ``` (function() { 'use strict'; disable-st...
2017/11/28
[ "https://Stackoverflow.com/questions/47539905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6632302/" ]
``` var divs =document.getElementsByClassName("stream-notifications"); divs=Array.from(divs); divs.forEach(function(div){ div.classList.remove('disable-stream'); }); ```
Use something like this using jQuery ``` $(".disable-stream div").removeClass("disable-stream"); ``` [Plunker demo](https://plnkr.co/edit/hP4IyF64trUEjTmZpwBK?p=preview)
2
0
47,539,905
I am very new to CSS and javascript, so take it easy on me. I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below) I have tried the following in Tampermonkey, but it doesn't seem to work: ``` (function() { 'use strict'; disable-st...
2017/11/28
[ "https://Stackoverflow.com/questions/47539905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6632302/" ]
That looks to be an AJAX-driven web page, so you need to use AJAX-aware techniques to deal with it. EG [waitForKeyElements](https://gist.github.com/2625891), or `MutationObserver`, or similar. Here's **a complete script** that should work: ``` // ==UserScript== // @name _Remove a select class from nodes // @match...
Use something like this using jQuery ``` $(".disable-stream div").removeClass("disable-stream"); ``` [Plunker demo](https://plnkr.co/edit/hP4IyF64trUEjTmZpwBK?p=preview)
3
0
47,539,905
I am very new to CSS and javascript, so take it easy on me. I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below) I have tried the following in Tampermonkey, but it doesn't seem to work: ``` (function() { 'use strict'; disable-st...
2017/11/28
[ "https://Stackoverflow.com/questions/47539905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6632302/" ]
That looks to be an AJAX-driven web page, so you need to use AJAX-aware techniques to deal with it. EG [waitForKeyElements](https://gist.github.com/2625891), or `MutationObserver`, or similar. Here's **a complete script** that should work: ``` // ==UserScript== // @name _Remove a select class from nodes // @match...
``` var divs =document.getElementsByClassName("stream-notifications"); divs=Array.from(divs); divs.forEach(function(div){ div.classList.remove('disable-stream'); }); ```
3
2
13,769,762
Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially. What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode exits (con...
2012/12/07
[ "https://Stackoverflow.com/questions/13769762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337455/" ]
It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w...
You just have to use : ``` listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); ```
2
0
13,769,762
Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially. What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode exits (con...
2012/12/07
[ "https://Stackoverflow.com/questions/13769762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337455/" ]
Just call: ``` mListView.setItemChecked(-1, true); ``` ListView's actionMode will be started without selecting any list element. Make sure you've properly set your ListView before call: ``` mListView.setMultiChoiceModeListener( ... ) mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); or mListView.setChoiceM...
You just have to use : ``` listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); ```
1
0
13,769,762
Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially. What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode exits (con...
2012/12/07
[ "https://Stackoverflow.com/questions/13769762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337455/" ]
It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w...
If you want to change the action bar, call this from your activity: > startActionMode(new ActionMode.Callback { > > > > ``` > @Override > public boolean onCreateActionMode(ActionMode mode, Menu menu) { > return false; > } > > @Override > public boolean onPrepareActionMode(ActionMode mod...
2
0
13,769,762
Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially. What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode exits (con...
2012/12/07
[ "https://Stackoverflow.com/questions/13769762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337455/" ]
Just call: ``` mListView.setItemChecked(-1, true); ``` ListView's actionMode will be started without selecting any list element. Make sure you've properly set your ListView before call: ``` mListView.setMultiChoiceModeListener( ... ) mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); or mListView.setChoiceM...
If you want to change the action bar, call this from your activity: > startActionMode(new ActionMode.Callback { > > > > ``` > @Override > public boolean onCreateActionMode(ActionMode mode, Menu menu) { > return false; > } > > @Override > public boolean onPrepareActionMode(ActionMode mod...
1
0
13,769,762
Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially. What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode exits (con...
2012/12/07
[ "https://Stackoverflow.com/questions/13769762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337455/" ]
It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w...
Just call: ``` mListView.setItemChecked(-1, true); ``` ListView's actionMode will be started without selecting any list element. Make sure you've properly set your ListView before call: ``` mListView.setMultiChoiceModeListener( ... ) mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); or mListView.setChoiceM...
2
1
62,287,390
I am working on a web application at the moment that has a an api at the top level domain (mydomain.com) and an SPA at subdomain (spa.mydomain.com). In the SPA I have added, `axios.defaults.withCredentials = true` To login in I run the following code, ``` axios.get('/sanctum/csrf-cookie').then(response => { axi...
2020/06/09
[ "https://Stackoverflow.com/questions/62287390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57872/" ]
Turns out when our Azure DevOps instance was first set up, all our users set up Microsoft accounts with their company emails. Later when we finally stood up Azure AD but before we connected it to DevOps we added a new project and set the permissions for a few existing employees. For some reason the user permissions on ...
It sounds like you have multiple users in your azure ad tenant with the same UPN. maybe you created a cloud account with the same UPN before sync'ing the on premise with azure ad connect? or something else of that nature. try to go to graph explorer <https://developer.microsoft.com/en-us/graph/graph-explorer> log in...
3
1
62,287,390
I am working on a web application at the moment that has a an api at the top level domain (mydomain.com) and an SPA at subdomain (spa.mydomain.com). In the SPA I have added, `axios.defaults.withCredentials = true` To login in I run the following code, ``` axios.get('/sanctum/csrf-cookie').then(response => { axi...
2020/06/09
[ "https://Stackoverflow.com/questions/62287390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57872/" ]
Turns out when our Azure DevOps instance was first set up, all our users set up Microsoft accounts with their company emails. Later when we finally stood up Azure AD but before we connected it to DevOps we added a new project and set the permissions for a few existing employees. For some reason the user permissions on ...
According to [this doc](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/faq-azure-access?view=azure-devops#q-why-did-i-get-an-error-stating-that-my-organization-has-multiple-active-identities-with-the-same-upn): > During the connect process, we map existing users to members of the Azure AD tenant...
3
1
31,079,002
I have a solution with a C# project of 'library' and a project 'JavaScript' after that compiled it generates a .winmd file being taken to another project. But this project is built on x86 and I need to compile for x64, to run the application in order x64 get the following error: ``` 'WWAHost.exe' (Script): Loaded 'Scr...
2015/06/26
[ "https://Stackoverflow.com/questions/31079002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
It looks like you were making calls with no Access Token at all, to data that's publicly visible on Facebook.com v1.0 of Facebook's Graph API was deprecated in April 2014 and scheduled for removal after 2015-04-30 - one of the changes between v1.0 and v2.0 was that in v2.0 all calls require an Access Token - the depre...
I finally realized that since May 1, it is **necessary** to create an app and then generate a token and use it in my JSON call URL. So this: ``` $.getJSON('https://graph.facebook.com/616894958361877/photos?limit=100&callback=? ``` Became this: ``` $.getJSON('https://graph.facebook.com/616894958361877/photos?acce...
1
0
31,079,002
I have a solution with a C# project of 'library' and a project 'JavaScript' after that compiled it generates a .winmd file being taken to another project. But this project is built on x86 and I need to compile for x64, to run the application in order x64 get the following error: ``` 'WWAHost.exe' (Script): Loaded 'Scr...
2015/06/26
[ "https://Stackoverflow.com/questions/31079002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
It looks like you were making calls with no Access Token at all, to data that's publicly visible on Facebook.com v1.0 of Facebook's Graph API was deprecated in April 2014 and scheduled for removal after 2015-04-30 - one of the changes between v1.0 and v2.0 was that in v2.0 all calls require an Access Token - the depre...
You need an App Access Token. Go to <http://developers.facebook.com/apps/> and create an app for the client's Facebook page. When you're presented with the options, select the "Website" type of app. You can skip the configuration option using the "Skip and Create App ID" button in the top right corner. Give it a Disp...
1
0
334,167
I am late game Alien Crossfire, attacking with gravitons aremed with [string disruptor](https://strategywiki.org/wiki/Sid_Meier%27s_Alpha_Centauri/Weapon#String_Disruptor). Unfortunately, the others have gotten wise and are building everything [AAA](https://strategywiki.org/wiki/Sid_Meier%27s_Alpha_Centauri/Special_Ab...
2018/06/24
[ "https://gaming.stackexchange.com/questions/334167", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/92813/" ]
Psi attack/defense is orthogonal to conventional weapons. Its result depends on *Morale* levels of attacking/defending units. If an attacker/defender is a *Mind Worm*, they have their own class, plus both faction's *Planet (Green)* scores/attitudes largely affect the outcome of the fight. **Answer:** see what's your ...
If you have dominant weapons, mixing in hovertanks and even air-dropped infantry will let you continue leveraging those dominant weapons. Psi-combat is mostly useful when facing technologically superior enemies that your weapons cannot defeat. Switching from overwhelming firepower to psi-attack will make you lose as m...
3
1
43,377,941
**Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data. **Example**: Suppose I aim to reduce the K variables ...
2017/04/12
[ "https://Stackoverflow.com/questions/43377941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634399/" ]
From the author himself (<https://lvdmaaten.github.io/tsne/>): > Once I have a t-SNE map, how can I embed incoming test points in that > map? > > > t-SNE learns a non-parametric mapping, which means that it does not > learn an explicit function that maps data from the input space to the > map. Therefore, it is no...
t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool. If you are trying to apply t-SNE to "new" data, you are probably not...
3
0
43,377,941
**Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data. **Example**: Suppose I aim to reduce the K variables ...
2017/04/12
[ "https://Stackoverflow.com/questions/43377941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634399/" ]
t-SNE does not really work this way: The following is an expert from the t-SNE author's website (<https://lvdmaaten.github.io/tsne/>): > Once I have a t-SNE map, how can I embed incoming test points in that > map? > > > t-SNE learns a non-parametric mapping, which means that it does not > learn an explicit funct...
t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool. If you are trying to apply t-SNE to "new" data, you are probably not...
3
0
43,377,941
**Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data. **Example**: Suppose I aim to reduce the K variables ...
2017/04/12
[ "https://Stackoverflow.com/questions/43377941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634399/" ]
This the mail answer from the author (Jesse Krijthe) of the Rtsne package: > Thank you for the very specific question. I had an earlier request for > this and it is noted as an open issue on GitHub > (<https://github.com/jkrijthe/Rtsne/issues/6>). The main reason I am > hesitant to implement something like this is ...
t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool. If you are trying to apply t-SNE to "new" data, you are probably not...
4
0
43,377,941
**Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data. **Example**: Suppose I aim to reduce the K variables ...
2017/04/12
[ "https://Stackoverflow.com/questions/43377941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634399/" ]
This the mail answer from the author (Jesse Krijthe) of the Rtsne package: > Thank you for the very specific question. I had an earlier request for > this and it is noted as an open issue on GitHub > (<https://github.com/jkrijthe/Rtsne/issues/6>). The main reason I am > hesitant to implement something like this is ...
From the author himself (<https://lvdmaaten.github.io/tsne/>): > Once I have a t-SNE map, how can I embed incoming test points in that > map? > > > t-SNE learns a non-parametric mapping, which means that it does not > learn an explicit function that maps data from the input space to the > map. Therefore, it is no...
4
3
43,377,941
**Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data. **Example**: Suppose I aim to reduce the K variables ...
2017/04/12
[ "https://Stackoverflow.com/questions/43377941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634399/" ]
This the mail answer from the author (Jesse Krijthe) of the Rtsne package: > Thank you for the very specific question. I had an earlier request for > this and it is noted as an open issue on GitHub > (<https://github.com/jkrijthe/Rtsne/issues/6>). The main reason I am > hesitant to implement something like this is ...
t-SNE does not really work this way: The following is an expert from the t-SNE author's website (<https://lvdmaaten.github.io/tsne/>): > Once I have a t-SNE map, how can I embed incoming test points in that > map? > > > t-SNE learns a non-parametric mapping, which means that it does not > learn an explicit funct...
4
3
62,380,246
As the title says is there a way to programmatically render (into a DOM element) a component in angular? For example, in React I can use `ReactDOM.render` to turn a component into a DOM element. I am wondering if it's possible to something similar in Angular?
2020/06/15
[ "https://Stackoverflow.com/questions/62380246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6009213/" ]
At first you'll need to have a template in your HTML file at the position where you'll want to place the dynamically loaded component. ```html <ng-template #placeholder></ng-template> ``` In the component you can inject the `DynamicFactoryResolver` inside the constructor. Once you'll execute the `loadComponent()` fu...
If you want to render the angular component into a Dom element which is not compiled by angular, Then we can't obtain a ViewContainerRef. Then you can use Angular cdk portal and portal host concepts to achieve this. Create portal host with any DOMElememt, injector, applicationRef, componentFactoryResolver. Create porta...
5
0
12,881
No matter how I rearrange this, the increment compare always returns false.... I have even taken it out of the if, and put it in its own if: ``` int buttonFSM(button *ptrButton) { int i; i = digitalRead(ptrButton->pin); switch(ptrButton->buttonState) { case SW_UP: if(i==0 && ++ptrButton-...
2015/06/24
[ "https://arduino.stackexchange.com/questions/12881", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/10817/" ]
Looks to me like the path where the if doesn't happen are getting you. You don't show what DBNC\_TICS is set to, but I'm assuming it's > 1. ptrButton->debounceTics will never be greater than 1 because you always: ``` ptrButton->debounceTics = 0; ```
The error is due to wrong expectations on operators precedence: ++ and -> have the same precedence, so they are evaluated left to right. See <http://en.cppreference.com/w/c/language/operator_precedence> . Overall, the lack of parenthesis makes the readability poor. The code can be improved by dropping the switch and ...
1
0
12,881
No matter how I rearrange this, the increment compare always returns false.... I have even taken it out of the if, and put it in its own if: ``` int buttonFSM(button *ptrButton) { int i; i = digitalRead(ptrButton->pin); switch(ptrButton->buttonState) { case SW_UP: if(i==0 && ++ptrButton-...
2015/06/24
[ "https://arduino.stackexchange.com/questions/12881", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/10817/" ]
Looks to me like the path where the if doesn't happen are getting you. You don't show what DBNC\_TICS is set to, but I'm assuming it's > 1. ptrButton->debounceTics will never be greater than 1 because you always: ``` ptrButton->debounceTics = 0; ```
```C++ if(i==0 && ++ptrButton->debounceTics == DBNC_TICS) //swtich went down { ptrButton->buttonState = SW_DOWN; ptrButton->debounceTics = 0; return SW_TRANS_UD; } ptrButton->debounceTics = 0; ``` I'm going to agree with user3877595 but explain why, as his/her answer got a...
1
0
64,999,490
Hi I'm learning right now how to upload images to database, but I'm getting this error/notice. ``` </select> <input type="text" name="nama" class="input-control" placeholder="Nama Produk" required> <input type="text" name="harga" class="input-control" placeholder="Harga Produk" require...
2020/11/25
[ "https://Stackoverflow.com/questions/64999490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14704128/" ]
You need to add `enctype="multipart/form-data"` to your form <https://www.php.net/manual/en/features.file-upload.post-method.php> > **Note:** > Be sure your file upload form has attribute > enctype="multipart/form-data" otherwise the file upload will not work.
When you want to submit file from form you should put "enctype="multipart/form-data". ``` <form "enctype="multipart/form-data" ...> </form> ``` Do you put it?
1
0
21,657,910
Can we change the color of the text based on the color of the background image? I have a background image which i have appended it to body. When you reload the page every time the background image gets changed. But i have my menus which are positioned on the image having text color as black. If the background image is ...
2014/02/09
[ "https://Stackoverflow.com/questions/21657910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1999172/" ]
use switch case to handle ``` switch(backgroundimage){ case "black.jpg": document.body.color = "white"; break; case "white.jpg": document.body.color = "black"; break; case "green.jpg": document.body.color = "gray"; break; } ```
If you know what will be the image that will be loaded you can create a dictionary with the image name and the css class that will be appended to the text for it. then on page load attach the class to the body classes. If you dont know the image that will be loaded there are some solutions but they are not complete. l...
2
0
2,274,695
My colleague has been using "new function()" with a lower case "f" to define new objects in JavaScript. It seems to work well in all major browsers and it also seems to be fairly effective at hiding private variables. Here's an example: ``` var someObj = new function () { var inner = 'some value'; ...
2010/02/16
[ "https://Stackoverflow.com/questions/2274695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/188740/" ]
I've seen that technique before, it's valid, you are using a function expression as if it were a [Constructor Function](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function). But IMHO, you can achieve the same with an auto-invoking function expression, I don't really see the point of using the...
Your code is just similar to the less weird construct ``` function Foo () { var inner = 'some value'; this.foo = 'blah'; ... }; var someObj = new Foo; ```
7
4
2,274,695
My colleague has been using "new function()" with a lower case "f" to define new objects in JavaScript. It seems to work well in all major browsers and it also seems to be fairly effective at hiding private variables. Here's an example: ``` var someObj = new function () { var inner = 'some value'; ...
2010/02/16
[ "https://Stackoverflow.com/questions/2274695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/188740/" ]
I've seen that technique before, it's valid, you are using a function expression as if it were a [Constructor Function](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function). But IMHO, you can achieve the same with an auto-invoking function expression, I don't really see the point of using the...
To clarify some aspects and make Douglas Crockford's JSLint not to complain about your code here are some examples of instantiation: ```javascript 1. o = new Object(); // normal call of a constructor 2. o = new Object; // accepted call of a constructor 3. var someObj = new (function () { var inner = 'some va...
7
4
1,806,990
Since nothing so far is working I started a new project with ``` python scrapy-ctl.py startproject Nu ``` I followed the tutorial exactly, and created the folders, and a new spider ``` from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from scrapy....
2009/11/27
[ "https://Stackoverflow.com/questions/1806990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215094/" ]
Please also check the version of scrapy. The latest version uses "name" instead of "domain\_name" attribute to uniquely identify a spider.
Have you included the spider in `SPIDER_MODULES` list in your scrapy\_settings.py? It's not written in the tutorial anywhere that you should to this, but you do have to.
3
2
1,806,990
Since nothing so far is working I started a new project with ``` python scrapy-ctl.py startproject Nu ``` I followed the tutorial exactly, and created the folders, and a new spider ``` from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from scrapy....
2009/11/27
[ "https://Stackoverflow.com/questions/1806990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215094/" ]
Please also check the version of scrapy. The latest version uses "name" instead of "domain\_name" attribute to uniquely identify a spider.
I believe you have syntax errors there. The `name = hxs...` will not work because you don't get defined before the `hxs` object. Try running `python yourproject/spiders/domain.py` to get syntax errors.
3
2
1,806,990
Since nothing so far is working I started a new project with ``` python scrapy-ctl.py startproject Nu ``` I followed the tutorial exactly, and created the folders, and a new spider ``` from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from scrapy....
2009/11/27
[ "https://Stackoverflow.com/questions/1806990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215094/" ]
Please also check the version of scrapy. The latest version uses "name" instead of "domain\_name" attribute to uniquely identify a spider.
These two lines look like they're causing trouble: ``` u = names.pop() rules = (Rule(SgmlLinkExtractor(allow=(u, )), callback='parse_item'),) ``` * Only one rule will be followed each time the script is run. Consider creating a rule for each URL. * You haven't created a `parse_item` callback, which means that the r...
3
2
1,806,990
Since nothing so far is working I started a new project with ``` python scrapy-ctl.py startproject Nu ``` I followed the tutorial exactly, and created the folders, and a new spider ``` from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from scrapy....
2009/11/27
[ "https://Stackoverflow.com/questions/1806990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215094/" ]
Please also check the version of scrapy. The latest version uses "name" instead of "domain\_name" attribute to uniquely identify a spider.
You are overriding the `parse` method, instead of implementing a new `parse_item` method.
3
2
20,931,619
I got nearly 10 functions in class having similar pattern like following function ``` SQLiteDatabase database = this.getWritableDatabase(); try { //Some different code , all other code(try,catch,finally) is same in all functions } catch (SQLiteException e) { Log.e(this.getClass().getName...
2014/01/05
[ "https://Stackoverflow.com/questions/20931619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1033305/" ]
There are a number of frameworks out there that drastically simplify database interaction that you can use, but if you want to do things on your own, and are interested in the Java way to do things like this, here's the idea: Make your "executor" like so: ``` public class Executor { public static void runOperation(...
**To expand further on [Ray Toal's original answer](https://stackoverflow.com/a/20931708/1134080),** it is worth noting that using anonymous inner class will help avoid creating a separate class file for each operation. So the original class with 10 or so functions can remain the same way, except being refactored to us...
3
1
32,580,318
Please help me for How to convert data from {"rOjbectId":["abc","def",ghi","ghikk"]} to "["abc", "def", "ghi", "ghikk"] using ajax
2015/09/15
[ "https://Stackoverflow.com/questions/32580318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003128/" ]
You can load a placeholder image, but then you must *load* that image (when you're already loading another image). If you load something like a spinner via a `GET` request, that should be ok since you can set cache headers from the server so the browser does not actually make any additional requests for that loading im...
you can use placeholder image, which is very light weight and use that in place of each image. same time while loading page, you can load all the images in hidden div. then on document ready you can replace all the images with jQuery. e.g. HTML ---- ``` <img src="tiny_placeholder_image" alt="" data-src="original...
2
0
32,580,318
Please help me for How to convert data from {"rOjbectId":["abc","def",ghi","ghikk"]} to "["abc", "def", "ghi", "ghikk"] using ajax
2015/09/15
[ "https://Stackoverflow.com/questions/32580318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003128/" ]
I found a good solution on GitHub. Just use the **CSS** code below: ```css img[src=""], img:not([src]) { visibility: hidden; } ``` Link: <https://github.com/wp-media/rocket-lazy-load/issues/60>
you can use placeholder image, which is very light weight and use that in place of each image. same time while loading page, you can load all the images in hidden div. then on document ready you can replace all the images with jQuery. e.g. HTML ---- ``` <img src="tiny_placeholder_image" alt="" data-src="original...
2
0
9,458,253
Perhaps I am worrying over nothing. I desire for data members to closely follow the RAII idiom. How can I initialise a protected pointer member in an abstract base class to null? I know it should be null, but wouldn't it be nicer to ensure that is universally understood? Putting initialization code outside of the ini...
2012/02/26
[ "https://Stackoverflow.com/questions/9458253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/866333/" ]
I have had this problem in the past - and fixed it. The images you're displaying are much too large. I love using html or css to resize my images (because who wants to do it manually), but the fact remains that most browsers will hiccup when moving them around. I'm not sure why. With the exception of Opera, which us...
Performance in JavaScript is slow, as you're going through many layers of abstraction to get any work done, and many manipulations with objects on the screen are happening in the background. Performance cannot be guaranteed from system to system. You'll find that with all jQuery animation, you will get a higher "frame...
2
0
34,211,201
I have a Python script that uploads a Database file to my website every 5 minutes. My website lets the user query the Database using PHP. If a user tries to run a query while the database is being uploaded, they will get an error message > PHP Warning: SQLite3::prepare(): Unable to prepare statement: 11, database dis...
2015/12/10
[ "https://Stackoverflow.com/questions/34211201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2893712/" ]
First of all there is a weird thing with your implementation: you use a parameter `n` that you never use, but simply keep passing and you never modify. Secondly the second recursive call is incorrect: ``` else: m = y*power(y, x//2, n) #Print statement only used as check print(x, m) return m*m ``` If...
here is my approach accornding to the c version of this problem it works with both positives and negatives exposents: ``` def power(a,b): """this function will raise a to the power b but recursivelly""" #first of all we need to verify the input if isinstance(a,(int,float)) and isinstance(b,int): if a==0: ...
2
0
38,921,847
I want to remove the card from the `@hand` array if it has the same rank as the given input. I'm looping through the entire array, why doesn't it get rid of the last card? Any help is greatly appreciated! Output: ``` 2 of Clubs 2 of Spades 2 of Hearts 2 of Diamonds 3 of Clubs 3 of Spades ------------ 2 of Clubs 2 of ...
2016/08/12
[ "https://Stackoverflow.com/questions/38921847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5140582/" ]
`remove_cards(value)` has an issue: one should not `delete` during iteration. The correct way would be to [`Array#reject!`](http://ruby-doc.org/core-2.3.1/Array.html#method-i-reject-21) cards from a hand: ``` def remove_cards(value) @hands.reject! { |hand_card| hand_card.rank == value } end ```
Your issue is in this line ``` @hands.each_with_index do |hand_card, i| ``` You have an instance variable `@hand`, not `@hands`
2
0
13,540,903
TextView.setAllCaps() started as of API 14. What is its equivalent for older APIs (e.g. 13 and lowers)? I cannot find such method on lower APIs. Is maybe setTransformationMethod() responsible for this on older APIs? If yes, how should I use it? `TextView.setTransformationMethod(new TransformationMethod() {...` is a bi...
2012/11/24
[ "https://Stackoverflow.com/questions/13540903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437039/" ]
Try this: ``` textView.setText(textToBeSet.toUpperCase()); ```
What about oldskool `strtoupper()`?
4
2
13,540,903
TextView.setAllCaps() started as of API 14. What is its equivalent for older APIs (e.g. 13 and lowers)? I cannot find such method on lower APIs. Is maybe setTransformationMethod() responsible for this on older APIs? If yes, how should I use it? `TextView.setTransformationMethod(new TransformationMethod() {...` is a bi...
2012/11/24
[ "https://Stackoverflow.com/questions/13540903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437039/" ]
What about oldskool `strtoupper()`?
Bottom line is that `toUpperCase()` is the solution. I can't object that. If you prefer doing the `setAllCaps()` with `TransformationMethod`, take a look at my [answer](https://stackoverflow.com/a/24025691/557179).
2
0
13,540,903
TextView.setAllCaps() started as of API 14. What is its equivalent for older APIs (e.g. 13 and lowers)? I cannot find such method on lower APIs. Is maybe setTransformationMethod() responsible for this on older APIs? If yes, how should I use it? `TextView.setTransformationMethod(new TransformationMethod() {...` is a bi...
2012/11/24
[ "https://Stackoverflow.com/questions/13540903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437039/" ]
Try this: ``` textView.setText(textToBeSet.toUpperCase()); ```
Bottom line is that `toUpperCase()` is the solution. I can't object that. If you prefer doing the `setAllCaps()` with `TransformationMethod`, take a look at my [answer](https://stackoverflow.com/a/24025691/557179).
4
0
6,126,126
If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters\*, Visual Studio will raise warning [CS0108](http://msdn.microsoft.com/en-us/library/3s8070fc.aspx): Example: ``` public class BaseClass { public static void DoSomething() { }...
2011/05/25
[ "https://Stackoverflow.com/questions/6126126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533907/" ]
Members of the SubClass will not be able to access the DoSomething from BaseClass without explicitly indicating the class name. So it is effectively "hidden" to members of SubClass, but still accessible. For example: ``` public class SubClass : BaseClass { public static void DoSomething() { } public ...
It's just a warning. The compiler just wants to make sure you intentionally used the same method name.
3
0
6,126,126
If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters\*, Visual Studio will raise warning [CS0108](http://msdn.microsoft.com/en-us/library/3s8070fc.aspx): Example: ``` public class BaseClass { public static void DoSomething() { }...
2011/05/25
[ "https://Stackoverflow.com/questions/6126126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533907/" ]
Members of the SubClass will not be able to access the DoSomething from BaseClass without explicitly indicating the class name. So it is effectively "hidden" to members of SubClass, but still accessible. For example: ``` public class SubClass : BaseClass { public static void DoSomething() { } public ...
> Why is this considered method hiding? Neither method is involved in the inheritance hierarchy and can only be invoked by using the class name. That is not true. You can call DoSomething from any inherited class name: ``` public Class A { public static void C() {...} } public Class B: A { } B.C() // Valid ca...
3
2
6,126,126
If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters\*, Visual Studio will raise warning [CS0108](http://msdn.microsoft.com/en-us/library/3s8070fc.aspx): Example: ``` public class BaseClass { public static void DoSomething() { }...
2011/05/25
[ "https://Stackoverflow.com/questions/6126126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533907/" ]
Members of the SubClass will not be able to access the DoSomething from BaseClass without explicitly indicating the class name. So it is effectively "hidden" to members of SubClass, but still accessible. For example: ``` public class SubClass : BaseClass { public static void DoSomething() { } public ...
Visual Studio, and Philippe, are saying it's a warning so your code will compile and run. However, 'CodeNaked' nicely demonstrates why it is hidden. This code compiles without throwing errors or warnings. Thanks to 'CodeNaked' ``` public class BaseClass { public virtual void DoSomething() { } } public class ...
3
0
6,126,126
If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters\*, Visual Studio will raise warning [CS0108](http://msdn.microsoft.com/en-us/library/3s8070fc.aspx): Example: ``` public class BaseClass { public static void DoSomething() { }...
2011/05/25
[ "https://Stackoverflow.com/questions/6126126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533907/" ]
> Why is this considered method hiding? Neither method is involved in the inheritance hierarchy and can only be invoked by using the class name. That is not true. You can call DoSomething from any inherited class name: ``` public Class A { public static void C() {...} } public Class B: A { } B.C() // Valid ca...
It's just a warning. The compiler just wants to make sure you intentionally used the same method name.
2
0
6,126,126
If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters\*, Visual Studio will raise warning [CS0108](http://msdn.microsoft.com/en-us/library/3s8070fc.aspx): Example: ``` public class BaseClass { public static void DoSomething() { }...
2011/05/25
[ "https://Stackoverflow.com/questions/6126126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533907/" ]
> Why is this considered method hiding? Neither method is involved in the inheritance hierarchy and can only be invoked by using the class name. That is not true. You can call DoSomething from any inherited class name: ``` public Class A { public static void C() {...} } public Class B: A { } B.C() // Valid ca...
Visual Studio, and Philippe, are saying it's a warning so your code will compile and run. However, 'CodeNaked' nicely demonstrates why it is hidden. This code compiles without throwing errors or warnings. Thanks to 'CodeNaked' ``` public class BaseClass { public virtual void DoSomething() { } } public class ...
2
0
14,847,913
I try to implement the zoom in/out by spread/pinch gesture and the drag and drop functions on a Relative Layout. This is the code of my OnPinchListener to handle the zoom effect. The **mainView** is the RelativeLayout defined in the layout xml file. I implement the touch listener in the **fakeview** which should be...
2013/02/13
[ "https://Stackoverflow.com/questions/14847913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2067294/" ]
you need to get the transformation matrix and use that to transform your original points. so something like this (after you do the scaling): ``` Matrix m = view.getMatrix(); //gives you the transform matrix m.mapPoints(newPoints, oldPoints); //transform the original points. ```
This is how I solved it in my case (`getViewRect` should be called after view was laid out, for example through `view.post(Runnable)`, so `view.getWidth()/getHeight()` returns actual values): ``` public static Rect getViewRect(View view) { Rect outRect = new Rect(); outRect.right = (int)(view.getWidth() * getS...
1
0
3,851,022
$A^{2}-2A=\begin{bmatrix} 5 & -6 \\ -4 & 2 \end{bmatrix}$ Can someone help me solve this? I've been trying to solve it for a while, but no matter what I try, the only information that I manage to get about A is that if $A=\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ then $c=\frac{2b}{3}$. Any help would be apprec...
2020/10/04
[ "https://math.stackexchange.com/questions/3851022", "https://math.stackexchange.com", "https://math.stackexchange.com/users/832188/" ]
Denote by $I$ the identity matrix. Then, completing squares you can write $$A^2 - 2A = A^2 -2IA + I^2 -I^2 = (A-I)^2 -I^2.$$ Hence, your equation is equivalent to $$(A-I)^2 = X + I$$ since $I^2 = I$. Denote by $Y=X+I$ the new matrix (which is known). You want to find $B$ such that $B^2=Y.$ Here, I recommend to diagonal...
$$A^{2}-2A+I=\begin{bmatrix} 5 & -6 \\ -4 & 2 \end{bmatrix}+I \\ (A-I)^2=\begin{bmatrix} 6 & -6 \\ -4 & 3 \end{bmatrix} $$ We know that, if$$\begin{align}M&=PDP^{-1} \\ M^n&=PD^nP^{-1}\end{align}$$ Let $B=A-I$ then, $$B=\sqrt{\begin{bmatrix} 6 & -6 \\ -4 & 3 \end{bmatrix}}$$ Diagonalise $B^2$ as, $$\left(\begin{mat...
2
0
3,851,022
$A^{2}-2A=\begin{bmatrix} 5 & -6 \\ -4 & 2 \end{bmatrix}$ Can someone help me solve this? I've been trying to solve it for a while, but no matter what I try, the only information that I manage to get about A is that if $A=\begin{bmatrix} a & b \\ c & d \end{bmatrix}$ then $c=\frac{2b}{3}$. Any help would be apprec...
2020/10/04
[ "https://math.stackexchange.com/questions/3851022", "https://math.stackexchange.com", "https://math.stackexchange.com/users/832188/" ]
Denote by $I$ the identity matrix. Then, completing squares you can write $$A^2 - 2A = A^2 -2IA + I^2 -I^2 = (A-I)^2 -I^2.$$ Hence, your equation is equivalent to $$(A-I)^2 = X + I$$ since $I^2 = I$. Denote by $Y=X+I$ the new matrix (which is known). You want to find $B$ such that $B^2=Y.$ Here, I recommend to diagonal...
$\newcommand{\Tr}{\mathrm{Tr}\,}$ Let $Y=A-I$, $X=B+I$, $B$ for the rhs matrix. Then $\Tr X = 9$, $\det X=-6$, and we need to solve $$Y^2=X$$ for $Y$. Write $\alpha=\Tr Y$, $\beta = \det Y$. Then $$Y^2-\alpha Y + \beta I=0$$ or $$\alpha Y = \beta I + X$$ so that finding allowed values of $\alpha$, $\beta$ solves the pr...
2
0
68,767,520
I have a discord bot that gets info from an API. The current issue I'm having is actually getting the information to be sent when the command is run. ``` const axios = require('axios'); axios.get('https://mcapi.us/server/status?ip=asean.my.to') .then(response => { console.log(response.data); }); module.exports = { ...
2021/08/13
[ "https://Stackoverflow.com/questions/68767520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15076973/" ]
probably your page is refreshed, try to use preventDefault to prevent the refresh ``` $('#submit').click(function(event){ //your code here event.preventDefault(); } ```
You have a button with type `"submit"`. ```html <input type="submit" id="submit" value="Save"> ``` As the click-event occurs on this button, your form will be send to the server. You have no action attribute defined on your form, so it redirects after submit to the same URL. As [Sterko](https://stackoverflow.com/us...
3
0
238,163
I have Echo's buried in code all over my notebook, I'd like a flag to turn them all on or off globally. * Sure `Unprotect[Echo];Echo=Identity` would disable them, but then you can't re-enable them * A solution that works for all the various types of Echos (EchoName, EchoEvaluation, ...) would be nice * `QuietEcho` doe...
2021/01/13
[ "https://mathematica.stackexchange.com/questions/238163", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/403/" ]
[`Echo`](http://reference.wolfram.com/language/ref/Echo) has an autoload, so you need to make sure the symbol is autoloaded before you modify its values: ``` DisableEcho[] := (Unprotect[Echo]; Echo; Echo = #&; Protect[Echo];) EnableEcho[] := (Unprotect[Echo]; Echo=.; Protect[Echo];) ``` Test: ``` DisableEcho[] Ec...
I would recommend using `QuietEcho` rather than redefining `Echo`: ``` In[62]:= $Pre = QuietEcho; In[63]:= Echo[3] Out[63]= 3 ``` This has the added benefit of disabling printing for all `Echo` functions, not just `Echo`.
5
2
29,922,241
Here is my Database: `bott_no_mgmt_data` ``` random_no ; company_id ; bottle_no ; date ; returned ; returned_to_stock ; username 30201 ; MY COMP ; 1 ; 2015-04-28 ; 10 ; NULL ; ANDREW 30202 ; MY COMP ; 2 ; 2015-04-28 ; 10 ; NULL ; ANDREW 3020...
2015/04/28
[ "https://Stackoverflow.com/questions/29922241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4842148/" ]
All joins should be written before Where clause as Daan mentions: ``` select yt.* from bott_no_mgmt_data yt inner join( select bottle_no, max(random_no) random_no from bott_no_mgmt_data WHERE username = 'ANDREW' group by bottle_no ) ss on yt.bottle_no = ss.bottle_no and yt.random_no = ss.random_no LEFT ...
A couple of things. You don't need that first inner join at all, it's pointless. Also, you said "I wish to compare them and only return those that match." - so that means you want INNER JOIN not LEFT JOIN. ``` SELECT MAX(random_no) AS random_no, company_id, yt.bottle_no, `date`, returned, username FROM bott_no_mgmt_da...
0
-1
17,435,721
I have a project with multiple modules say "Application A" and "Application B" modules (these are separate module with its own pom file but are not related to each other). In the dev cycle, each of these modules have its own feature branch. Say, ``` Application A --- Master \ - F...
2013/07/02
[ "https://Stackoverflow.com/questions/17435721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/710802/" ]
You can do this with a before update trigger. You would use such a trigger to assign the value of `offer_nr` based on the historical values. The key code would be: ``` new.offer_nr = (select coalesce(1+max(offer_nr), 1) from offers o where o.company_id = new.company_id ) ...
Don't make it this way. Have autoincremented company ids as well as independent order ids. That's how it works. There is no such thing like "number" in database. Numbers appears only at the time of select.
1
-1
35,029,058
HTML CODE ``` <select class="form-control" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` JQuery Code ``` var val1[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ``` when i run this c...
2016/01/27
[ "https://Stackoverflow.com/questions/35029058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4089992/" ]
The declaration array syntax is in correct.Please check the below code ``` var val1=[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ```
You can try the following **HTML** ``` <select class="form-control min-select" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` **JQUERY** ``` var values = []; $("select.min-select").each(function(i, sel){ var selectedVal = $(sel).val(); v...
4
1
35,029,058
HTML CODE ``` <select class="form-control" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` JQuery Code ``` var val1[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ``` when i run this c...
2016/01/27
[ "https://Stackoverflow.com/questions/35029058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4089992/" ]
The declaration array syntax is in correct.Please check the below code ``` var val1=[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ```
To get the selected value, whether it is multiselect or single select, use jQuery [`.val()`](http://api.jquery.com/val/) method. If it is a multiselect, it will return an array of the selected values. See [jsfiddle for demo](https://jsfiddle.net/txk25c4c/). Check console log
4
1
35,029,058
HTML CODE ``` <select class="form-control" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` JQuery Code ``` var val1[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ``` when i run this c...
2016/01/27
[ "https://Stackoverflow.com/questions/35029058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4089992/" ]
This will also work ``` var val1= $("select[name=\'min_select[]\']").map(function() { return $(this).val(); }).toArray(); ```
You can try the following **HTML** ``` <select class="form-control min-select" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` **JQUERY** ``` var values = []; $("select.min-select").each(function(i, sel){ var selectedVal = $(sel).val(); v...
4
1
35,029,058
HTML CODE ``` <select class="form-control" name="min_select[]"> <option value="15">15</option> <option value="30">30</option> </select> ``` JQuery Code ``` var val1[]; $('select[name="min_select[]"] option:selected').each(function() { val1.push($(this).val()); }); ``` when i run this c...
2016/01/27
[ "https://Stackoverflow.com/questions/35029058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4089992/" ]
This will also work ``` var val1= $("select[name=\'min_select[]\']").map(function() { return $(this).val(); }).toArray(); ```
To get the selected value, whether it is multiselect or single select, use jQuery [`.val()`](http://api.jquery.com/val/) method. If it is a multiselect, it will return an array of the selected values. See [jsfiddle for demo](https://jsfiddle.net/txk25c4c/). Check console log
4
1
28,808,099
I am writing a script which will pick the last created file for the given process instance. The command I use in my script is ``` CONSOLE_FILE=`ls -1 "$ABP_AJTUH_ROOT/console/*${INSTANCE}*" | tail -1` ``` but while the script is getting executed, the above command changes to ``` ls -1 '....../console/*ABP*' ``` ...
2015/03/02
[ "https://Stackoverflow.com/questions/28808099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4623068/" ]
You cannot use double quotes around the wildcard, because that turns the asterisks into literal characters. ``` CONSOLE_FILE=`ls -1 "$ABP_AJTUH_ROOT"/console/*"$INSTANCE"* | tail -1` ``` should work, but see the caveats against <http://mywiki.wooledge.org/ParsingLs> and generally <http://mywiki.wooledge.org/BashPitf...
Try ``` CONSOLE_FILE=`eval ls -1 "$ABP_AJTUH_ROOT/console/*${INSTANCE}*" | tail -1` ``` Also, if you want the last created file, use `ls -1tr`
1
0
60,744,543
I'm trying to get the Download Folder to show on my file explorer. However on Android 9, when I use the getexternalstoragedirectory() method is showing self and emulated directories only and if I press "emulated" I cannot see more folders, it shows an empty folder. So this is how I'm getting the path, it's working fin...
2020/03/18
[ "https://Stackoverflow.com/questions/60744543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10871734/" ]
This is because [dictionaries](https://docs.julialang.org/en/v1/base/collections/#Dictionaries-1) in Julia (`Dict`) are not ordered: each dictionary maintains a *set* of keys. The order in which one gets keys when one iterates on this set is not defined, and can vary as one inserts new entries. There are two things tha...
Try this: ``` fruits = Dict("Mangoes" => 5, "Pomegranates" => 4, "Apples" => 8); for key in sort(collect(keys(fruits))) println("$key => $(fruits[key])") end ``` It gives this result: ``` Apples => 8 Mangoes => 5 Pomegranates => 4 ```
4
2
5,803,170
I have encountered a problem when trying to select data from a table in MySQL in Java by a text column that is in utf-8. The interesting thing is that with code in Python it works well, in Java it doesn't. The table looks as follows: ``` CREATE TABLE `x` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `text` varchar(...
2011/04/27
[ "https://Stackoverflow.com/questions/5803170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/429274/" ]
Okay, my bad. The database was wrongly built. It was built through the mysql client that by default is latin1 so in the database the data were encoded by utf8 twice. The problem and the major difference between the two source codes is in that the Python code doesn't set the default charset (therefore it is latin1) whe...
Use PreparedStatement and set your search string as a positional parameter into that statement. Read this tutorial about PreparedStatements -> <http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html> Also, never create a String literal in Java code that contains non-ASCII characters. If you want to pass...
2
0
24,220,365
I have this SQL server instance which is shared by several client-processes. I want queries to finish taking as little time as possible. Say a call needs to read 1k to 10k records from this shared Sql Server. My natural choice would be to use ExecuteReaderAsync to take advantage of async benefits such as reusing threa...
2014/06/14
[ "https://Stackoverflow.com/questions/24220365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298622/" ]
Whether you use sync or async to call SQL Server makes no difference for the work that SQL Server does and for the CPU-bound work that ADO.NET does to serialize and deserialize request and response. So no matter what you chose the difference will be small. Using async is not about saving CPU time. It is about saving m...
The difference between the async approach and the sync approach is that the async call will cause the compiler to generate a state machine, whereas the sync call will simply block while the work agains't the database is being done. IRL, the best way to choose is to benchmark both approaches. As usr said, usually those...
3
2
3,398,839
I'm trying to prove this by induction, but something doesn't add up. I see a solution given [here](https://www.algebra.com/algebra/homework/word/misc/Miscellaneous_Word_Problems.faq.question.29292.html), but it is actually proving that the expression is **greater** than $2\sqrt{n}$. I'd appreciate some insight.
2019/10/18
[ "https://math.stackexchange.com/questions/3398839", "https://math.stackexchange.com", "https://math.stackexchange.com/users/209695/" ]
Base step: 1<2. Inductive step: $$\sum\_{j=1}^{n+1}\frac1{\sqrt{j}} < 2\sqrt{n}+\frac1{\sqrt{n+1}}$$ So if we prove $$2\sqrt{n}+\frac1{\sqrt{n+1}}<2\sqrt{n+1}$$ we are done. Indeed, that holds true: just square the left hand side sides to get $$4n+2\frac{\sqrt{n}}{\sqrt{n+1}}+\frac1{n+1}<4n+3<4n+4$$ which is the squa...
Note that $$ 2\sqrt{n+1}-2\sqrt n=2\cdot\frac{(\sqrt{n+1}-\sqrt{n})(\sqrt{n+1}+\sqrt{n})}{\sqrt{n+1}+\sqrt{n}}=2\cdot \frac{(n+1)-n}{\sqrt{n+1}+\sqrt{n}}<\frac 2{\sqrt n+\sqrt n}$$
3
0
32,969,687
I have a scenario where I need to auto generate the value of a column if it is null. Ex: `employeeDetails`: ``` empName empId empExtension A 101 null B 102 987 C 103 986 D 104 null E 105 null ``` `employeeDepartment`: ``` deptName empId HR 101 ADMIN 10...
2015/10/06
[ "https://Stackoverflow.com/questions/32969687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622730/" ]
You should be able to do that with a CTE to grab [ROW\_NUMBER](https://msdn.microsoft.com/en-us/library/ms186734.aspx), and then [COALESCE](https://msdn.microsoft.com/en-us/library/ms190349.aspx) to only use that number where the value is NULL: ``` WITH cte AS( SELECT empId, empExtension, ROW_NUMBER() OVER(ORDER BY ...
Just an idea, can you save result of that query into temp table ``` SELECT empdt.empId, empdprt.deptName, empdt.empExtension INTO #TempEmployee FROM employeeDetails empdt LEFT JOIN employeeDepartment empdprt ON empdt.empId = empdprt.empId ``` And after that just do the update of #TempEmployee?
2
0
32,969,687
I have a scenario where I need to auto generate the value of a column if it is null. Ex: `employeeDetails`: ``` empName empId empExtension A 101 null B 102 987 C 103 986 D 104 null E 105 null ``` `employeeDepartment`: ``` deptName empId HR 101 ADMIN 10...
2015/10/06
[ "https://Stackoverflow.com/questions/32969687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622730/" ]
If you just want to create a unique random 5 digit number for those `empExtension` column values are null, then **Query** ``` ;with cte as ( select rn = row_number() over ( order by empId ),* from employeeDetails ) select t1.empId,t2.deptName, case when t1.empExtension is null then t1.rn + (...
Just an idea, can you save result of that query into temp table ``` SELECT empdt.empId, empdprt.deptName, empdt.empExtension INTO #TempEmployee FROM employeeDetails empdt LEFT JOIN employeeDepartment empdprt ON empdt.empId = empdprt.empId ``` And after that just do the update of #TempEmployee?
1
0
32,969,687
I have a scenario where I need to auto generate the value of a column if it is null. Ex: `employeeDetails`: ``` empName empId empExtension A 101 null B 102 987 C 103 986 D 104 null E 105 null ``` `employeeDepartment`: ``` deptName empId HR 101 ADMIN 10...
2015/10/06
[ "https://Stackoverflow.com/questions/32969687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622730/" ]
``` declare @rand int = (rand()* 12345); SELECT empdt.empId, empdprt.deptName, isnull(empdt.empExtension,row_number() over(order by empdt.empId)+@rand) FROM employeeDetails empdt LEFT JOIN employeeDepartment empdprt ON empdt.empId = empdprt.empId ``` Incase the empExtension, get the row\_number + a ra...
Just an idea, can you save result of that query into temp table ``` SELECT empdt.empId, empdprt.deptName, empdt.empExtension INTO #TempEmployee FROM employeeDetails empdt LEFT JOIN employeeDepartment empdprt ON empdt.empId = empdprt.empId ``` And after that just do the update of #TempEmployee?
1
0
32,969,687
I have a scenario where I need to auto generate the value of a column if it is null. Ex: `employeeDetails`: ``` empName empId empExtension A 101 null B 102 987 C 103 986 D 104 null E 105 null ``` `employeeDepartment`: ``` deptName empId HR 101 ADMIN 10...
2015/10/06
[ "https://Stackoverflow.com/questions/32969687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622730/" ]
You should be able to do that with a CTE to grab [ROW\_NUMBER](https://msdn.microsoft.com/en-us/library/ms186734.aspx), and then [COALESCE](https://msdn.microsoft.com/en-us/library/ms190349.aspx) to only use that number where the value is NULL: ``` WITH cte AS( SELECT empId, empExtension, ROW_NUMBER() OVER(ORDER BY ...
If you just want to create a unique random 5 digit number for those `empExtension` column values are null, then **Query** ``` ;with cte as ( select rn = row_number() over ( order by empId ),* from employeeDetails ) select t1.empId,t2.deptName, case when t1.empExtension is null then t1.rn + (...
2
1
32,969,687
I have a scenario where I need to auto generate the value of a column if it is null. Ex: `employeeDetails`: ``` empName empId empExtension A 101 null B 102 987 C 103 986 D 104 null E 105 null ``` `employeeDepartment`: ``` deptName empId HR 101 ADMIN 10...
2015/10/06
[ "https://Stackoverflow.com/questions/32969687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622730/" ]
You should be able to do that with a CTE to grab [ROW\_NUMBER](https://msdn.microsoft.com/en-us/library/ms186734.aspx), and then [COALESCE](https://msdn.microsoft.com/en-us/library/ms190349.aspx) to only use that number where the value is NULL: ``` WITH cte AS( SELECT empId, empExtension, ROW_NUMBER() OVER(ORDER BY ...
``` declare @rand int = (rand()* 12345); SELECT empdt.empId, empdprt.deptName, isnull(empdt.empExtension,row_number() over(order by empdt.empId)+@rand) FROM employeeDetails empdt LEFT JOIN employeeDepartment empdprt ON empdt.empId = empdprt.empId ``` Incase the empExtension, get the row\_number + a ra...
2
1
62,440,916
I'm brand new to python 3 & my google searches have been unproductive. Is there a way to write this: ``` for x in range(10): print(x) ``` as this: ``` print(x) for x in range(10) ``` I do not want to return a list as the `arr = [x for x in X]` list comprehension syntax does. EDIT: I'm not actually in that s...
2020/06/18
[ "https://Stackoverflow.com/questions/62440916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048592/" ]
No, there isn't. Unless you consider this a one liner: ``` for x in range(6): print(x) ``` but there's no reason to do that.
For your specific case to print a range of 6: ```py print(*range(6), sep='\n') ``` This is not a for loop however @Boris is correct.
3
0
62,440,916
I'm brand new to python 3 & my google searches have been unproductive. Is there a way to write this: ``` for x in range(10): print(x) ``` as this: ``` print(x) for x in range(10) ``` I do not want to return a list as the `arr = [x for x in X]` list comprehension syntax does. EDIT: I'm not actually in that s...
2020/06/18
[ "https://Stackoverflow.com/questions/62440916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048592/" ]
No, there isn't. Unless you consider this a one liner: ``` for x in range(6): print(x) ``` but there's no reason to do that.
Looks like you are looking for something like `map`. If the function you are calling returns `None`, then it won't be too expensive. Map will return an iterator, so you are just trying to consume it. One way is: ```py list(map(print, range(6))) ``` Or using a zero length deque if you don't want the actual list ele...
3
1
62,440,916
I'm brand new to python 3 & my google searches have been unproductive. Is there a way to write this: ``` for x in range(10): print(x) ``` as this: ``` print(x) for x in range(10) ``` I do not want to return a list as the `arr = [x for x in X]` list comprehension syntax does. EDIT: I'm not actually in that s...
2020/06/18
[ "https://Stackoverflow.com/questions/62440916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048592/" ]
No, there isn't. Unless you consider this a one liner: ``` for x in range(6): print(x) ``` but there's no reason to do that.
What you are looking for is a generator expression that returns a generator object. ```py print(i for i in range(10)) #<generator object <genexpr> at 0x7f3a5baacdb0> ``` To see the values ```py print(*(i for i in range(10))) # 0 1 2 3 4 5 6 7 8 9 ``` Pros: * Extremely Memory Efficient. * Lazy Evaluation - genera...
3
0
62,440,916
I'm brand new to python 3 & my google searches have been unproductive. Is there a way to write this: ``` for x in range(10): print(x) ``` as this: ``` print(x) for x in range(10) ``` I do not want to return a list as the `arr = [x for x in X]` list comprehension syntax does. EDIT: I'm not actually in that s...
2020/06/18
[ "https://Stackoverflow.com/questions/62440916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048592/" ]
Looks like you are looking for something like `map`. If the function you are calling returns `None`, then it won't be too expensive. Map will return an iterator, so you are just trying to consume it. One way is: ```py list(map(print, range(6))) ``` Or using a zero length deque if you don't want the actual list ele...
For your specific case to print a range of 6: ```py print(*range(6), sep='\n') ``` This is not a for loop however @Boris is correct.
1
0
62,440,916
I'm brand new to python 3 & my google searches have been unproductive. Is there a way to write this: ``` for x in range(10): print(x) ``` as this: ``` print(x) for x in range(10) ``` I do not want to return a list as the `arr = [x for x in X]` list comprehension syntax does. EDIT: I'm not actually in that s...
2020/06/18
[ "https://Stackoverflow.com/questions/62440916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048592/" ]
Looks like you are looking for something like `map`. If the function you are calling returns `None`, then it won't be too expensive. Map will return an iterator, so you are just trying to consume it. One way is: ```py list(map(print, range(6))) ``` Or using a zero length deque if you don't want the actual list ele...
What you are looking for is a generator expression that returns a generator object. ```py print(i for i in range(10)) #<generator object <genexpr> at 0x7f3a5baacdb0> ``` To see the values ```py print(*(i for i in range(10))) # 0 1 2 3 4 5 6 7 8 9 ``` Pros: * Extremely Memory Efficient. * Lazy Evaluation - genera...
1
0
37,455,599
When I run my project on my iphone or in the simulator it works fine. When I try to run it on an ipad I get the below error: *file was built for arm64 which is not the architecture being linked (armv7)* The devices it set to Universal. Does anybody have an idea about what else I should check?
2016/05/26
[ "https://Stackoverflow.com/questions/37455599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5367540/" ]
Just in case somebody has the same problem as me. Some of my target projects had different iOS Deployment target and that is why the linking failed. After moving them all to the same the problem was solved.
I should have added armv6 for iPad 2. Done that and it works now
3
1
2,315,242
I'm just starting a new project on ASP.NET MVC and this will be the first project actually using this technology. As I created my new project with Visual Studio 2010, it created to my sql server a bunch of tables with "aspnet\_" prefix. Part of them deal with the built-in user accounts and permission support. Now, I ...
2010/02/23
[ "https://Stackoverflow.com/questions/2315242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/266159/" ]
If you are choosing to use the Membership API for your site, then this [link](http://www.asp.net/(S(pdfrohu0ajmwt445fanvj2r3))/learn/security/tutorial-08-cs.aspx) has information regarding how to add extra information to a user. I was faced with the same scenario recently and ended up ditching the membership functiona...
Using the membership system in asp.net has its advantages and drawbacks. It's easy to start, because you don't have to worry about validation, user registration, resetting passwords. (Be careful if you plan to modify the table structures, you will have to change them in the views/store procedures generated **However t...
2
-1
2,315,242
I'm just starting a new project on ASP.NET MVC and this will be the first project actually using this technology. As I created my new project with Visual Studio 2010, it created to my sql server a bunch of tables with "aspnet\_" prefix. Part of them deal with the built-in user accounts and permission support. Now, I ...
2010/02/23
[ "https://Stackoverflow.com/questions/2315242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/266159/" ]
I would create [custom membership provider](http://www.15seconds.com/issue/050216.htm) and omit those `aspnet_x` tables completely. I've seen what happens when one `join`s these tables and custom ones with nhibernate mappings - pure nightmare.
Using the membership system in asp.net has its advantages and drawbacks. It's easy to start, because you don't have to worry about validation, user registration, resetting passwords. (Be careful if you plan to modify the table structures, you will have to change them in the views/store procedures generated **However t...
2
-1
7,710,639
I am modifying a regex validator control. The regex at the moment looks like this: ``` (\d*\,?\d{2}?){1}$ ``` As I can understand it allows for a number with 2 decimal places. I need to modify it like this: * The number must range from 0 - 1.000.000. (Zero to one million). * The number may or may not have 2 deci...
2011/10/10
[ "https://Stackoverflow.com/questions/7710639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/817455/" ]
Try this regex: ``` ^(((0|[1-9]\d{0,5})(\,\d{2})?)|(1000000(\,00)?))$ ``` It accepts numbers like: `"4", "4,23", "123456", "1000000", "1000000,00"`, but don't accepts: `",23", "4,7", "1000001", "4,234", "1000000,55"`. If you want accept only numbers with exactly two decimals, use this regex: ``` ^(((0|[1-9]\d{0,...
What about this one ``` ^(?:\d{1,6}(?:\,\d{2})?|1000000)$ ``` See it [here on Regexr](http://regexr.com?2ut4u) It accepts between 1 and 6 digits and an optional fraction with 2 digits OR "1000000". And it allows the number to start with zeros! (001 would be accepted) `^` anchors the regex to the start of the stri...
2
0
7,710,639
I am modifying a regex validator control. The regex at the moment looks like this: ``` (\d*\,?\d{2}?){1}$ ``` As I can understand it allows for a number with 2 decimal places. I need to modify it like this: * The number must range from 0 - 1.000.000. (Zero to one million). * The number may or may not have 2 deci...
2011/10/10
[ "https://Stackoverflow.com/questions/7710639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/817455/" ]
Try this regex: ``` ^(((0|[1-9]\d{0,5})(\,\d{2})?)|(1000000(\,00)?))$ ``` It accepts numbers like: `"4", "4,23", "123456", "1000000", "1000000,00"`, but don't accepts: `",23", "4,7", "1000001", "4,234", "1000000,55"`. If you want accept only numbers with exactly two decimals, use this regex: ``` ^(((0|[1-9]\d{0,...
``` ^(([0-9]|([1-9][0-9]{1,5}))(\.[0-9]{1,2})?)|1000000$ ```
2
0
24,444,188
can someone please tell me what is going wrong? I am trying to create a basic login page and that opens only when a correct password is written ``` <html> <head> <script> function validateForm() { var x=document.forms["myForm"]["fname"].value; if (x==null || x=="") { alert("First name must be filled out"); retu...
2014/06/27
[ "https://Stackoverflow.com/questions/24444188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2771301/" ]
try this ``` BufferedWriter writer = new BufferedWriter(new FileWriter("result.txt")); for (String element : misspelledWords) { writer.write(element); writer.newLine(); } ``` Adding line separator at the end (like "\n") should work on most OS,but to be on safer side you should use **S...
Open your file in append mode like this `FileWriter(String fileName, boolean append)` when you want to make an object of class `FileWrite` in constructor. ``` File file = new File("C:\\Users\\Izak\\Documents\\NetBeansProjects\\addNewLinetoTxtFile\\src\\addnewlinetotxtfile\\a.txt"); try (Writer newLine = new Buf...
3
0
47,331,969
I'm trying to merge informations in two different data frames, but problem begins with uneven dimensions and trying to use not the column index but the information in the column. merge function in R or join's (dplyr) don't work with my data. I have to dataframes (One is subset of the others with updated info in the la...
2017/11/16
[ "https://Stackoverflow.com/questions/47331969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8609239/" ]
`%in%` from base-r is there to rescue. ``` df1=data.frame(Name = print(LETTERS[1:9]), val = seq(1:3), Case = c("NA","1","NA","NA","1","NA","1","NA","NA"), stringsAsFactors = F) df2 = data.frame(Name = c("A","D","H"), val = seq(1:3), Case = "1", stringsAsFactors = F) df1$Case <- ifelse(df1$Name %in% df2$N...
Here is what I would do using `dplyr`: ``` df1 %>% left_join(df2, by = c("Name")) %>% mutate(val = if_else(is.na(val.y), val.x, val.y), Case = if_else(is.na(Case.y), Case.x, Case.y)) %>% select(Name, val, Case) ```
3
1
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
5
-1
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Note: this answer is for [PyMySQL](https://github.com/PyMySQL/PyMySQL), which is a drop-in replacement for MySQLdb and effectively the latest version of MySQLdb since MySQLdb stopped being maintained. I believe everything here is *also* true of the legacy MySQLdb, but haven't checked. First of all, some facts: * Pyth...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
3
-1
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
I think you'll be better off trying to use one cursor for all of your executions, and close it at the end of your code. It's easier to work with, and it might have efficiency benefits as well (don't quote me on that one). ``` conn = MySQLdb.connect("host","user","pass","database") cursor = conn.cursor() cursor.execute...
8
3
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
I think you'll be better off trying to use one cursor for all of your executions, and close it at the end of your code. It's easier to work with, and it might have efficiency benefits as well (don't quote me on that one). ``` conn = MySQLdb.connect("host","user","pass","database") cursor = conn.cursor() cursor.execute...
5
3
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
Note: this answer is for [PyMySQL](https://github.com/PyMySQL/PyMySQL), which is a drop-in replacement for MySQLdb and effectively the latest version of MySQLdb since MySQLdb stopped being maintained. I believe everything here is *also* true of the legacy MySQLdb, but haven't checked. First of all, some facts: * Pyth...
8
3
56,148,199
I am new to the Ruby on Rails ecosystem so might question might be really trivial. I have set up an Active Storage on one of my model ```rb class Sedcard < ApplicationRecord has_many_attached :photos end ``` And I simply want to seed data with `Faker` in it like so: ```rb require 'faker' Sedcard.destroy_all 20....
2019/05/15
[ "https://Stackoverflow.com/questions/56148199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2828594/" ]
I found the problem myself. I was using UUID as my model's primary key which is not natively compatible with ActiveStorage. Thus, I more or less followed the instructions [here](https://www.wrburgess.com/posts/2018-02-03-1.html)
You need to purge the attachments. Try adding this snippet before destroyingthe `Sedcard`'s ``` Sedcard.all.each{ |s| s.photos.purge } ``` Ref: <https://edgeguides.rubyonrails.org/active_storage_overview.html#removing-files>
1
0
199,883
Say I have an expansion of terms containing functions `y[j,t]` and its derivatives, indexed by `j` with the index beginning at 0 whose independent variable are `t`, like so: `Expr = y[0,t]^2 + D[y[0,t],t]*y[0,t] + y[0,t]*y[1,t] + y[0,t]*D[y[1,t],t] + (y[1,t])^2*y[0,t] +` ... etc. Now I wish to define new functions i...
2019/06/06
[ "https://mathematica.stackexchange.com/questions/199883", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/41975/" ]
Since [`Show`](http://reference.wolfram.com/language/ref/Show) uses the [`PlotRange`](http://reference.wolfram.com/language/ref/PlotRange) setting from the first plot, you can just set your plot range when defining the first plot: ``` p1=LogLogPlot[ RO, {t,0.00001,0.05}, PlotRange -> {{10^-5, 10^-4}, All},...
Your syntax is incorrect, it should be ``` Show[{p1,p2},PlotRange->{{x_min,x_max},{y_min,y_max}}] ``` If you want all in y, you can do: ``` Show[{p1,p2},PlotRange->{{10^(-5),10^(-4)},All}] ```
3
1
61,989,976
I am trying to perform JWT auth in spring boot and the request are getting stuck in redirect loop. **JWTAuthenticationProvider** ``` @Component public class JwtAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { @Autowired private JwtUtil jwtUtil; @Override public boolean supp...
2020/05/24
[ "https://Stackoverflow.com/questions/61989976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4457734/" ]
I believe the the reason for this is because you have not actually set the `AuthenticationSuccessHandler` for the bean `JwtAuthenticationFilter`, since it is not actually set it will keep looping around super and chain and later when the error needs to be sent since response is already written in `super()` `chain.doFil...
I solved this problem with another approach. In the JwtAuthenticationFilter class we need to set authentication object in context and call chain.doFilter. Calling super.successfulAuthentication can be skipped as we have overridden the implementation. ``` @Override protected void successfulAuthentication(HttpServle...
2
0
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
Use [`SimpleDateFormat`](http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy [`Date`](http://download.oracle.com/javase/6/docs/api/java/util/Date.html) and use another one to format the parsed `Date` to...
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
4
2
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
One liner in java 8 and above. ``` String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy")); ```
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
0
-1
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
2
-1
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
Use [`SimpleDateFormat`](http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy [`Date`](http://download.oracle.com/javase/6/docs/api/java/util/Date.html) and use another one to format the parsed `Date` to...
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
4
-1
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
One liner in java 8 and above. ``` String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy")); ```
2
0
44,169,413
[Error Message Picture](https://i.stack.imgur.com/kkbkN.png) I basically followed the instructions from the below link EXACTLY and I'm getting this damn error? I have no idea what I'm supposed to do, wtf? Do I need to create some kind of persisted method?? There were several other questions like this and after reading...
2017/05/24
[ "https://Stackoverflow.com/questions/44169413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6484371/" ]
Changed the bottom portion to: ``` def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.email = auth.info.email user.password = Devise.friendly_token[0,20] user.name = auth.info.name # assuming the user model has a name end end ``` ran rails g mig...
The persisted? method is checking whether or not the user exists thereby returning nil value if no such record exists and your user model is not creating new ones. So by uncommenting the code from the example to this: ``` def self.from_omniauth(access_token) data = access_token.info user = User.where(:email => dat...
3
0
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
I think the session items are client sided. You can create a query to count the open connections (hence you're working with a MySQL database.) Another option is to use external software (I use the tawk.to helpchat, which shows the amount of users visiting a page in realtime). You could maybe use that, making the suppor...
1
0
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
That is the problem that you cannot do it using *Session[]* variables. You need to be using a database (or a central data source to store the total number of active users). For example, you can see in your application, when the application starts there is no `Application["UsersOnline"]` variable, you create it at the v...
1
0
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Perhaps I am missing something, but why not something like this: ``` public void Session_OnStart() { Application.Lock(); if (Application["UsersOnline"] == null ) { Application["UsersOnline"] = 0 } Application["UsersOnline"] = (int)Application["UsersOnline"] + 1; Application.UnLock(); ``` }
1
0
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Maybe I'm missing something, but is there a reason you don't just want to use something like Google Analytics? Unless you're looking for more queryable data, in which case I'd suggest what others have; store the login count to a data store. Just keep in mind you also have to have something to decrement that counter wh...
1
0
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Try this. It may help you. ``` void Application_Start(object sender, EventArgs e) { Application["cnt"] = 0; Application["onlineusers"] = 0; // Code that runs on application startup } void Session_Start(object sender, EventArgs e) { Application.Lock(); Application["cnt"] = (int)Application["cnt"...
1
0
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
If using Rails 4.2, you can set the placeholder attribute to true: ``` = f.text_field :first_name, placeholder: true ``` and specify the placeholder text in the locale file like this: ``` en: helpers: placeholder: user: first_name: "Your name" ```
You can view the source on render at <http://rubydoc.info/docs/rails/ActionView/Helpers/Tags/Label> to see how Rails does it. It probably doesn't get a lot better than you have, but you could probably swipe some of Rail's logic and stick it in a helper, if you have a lot of them to do. Alternatively, you may consider u...
5
0
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
With Rails >= 4.2, you can set the placeholder attribute to true `= f.text_field :first_name, placeholder: true` and in your local file (e.g. en.yml): ``` ru: activerecord: attributes: user: first_name: Your name ``` otherwise (Rails >= 3.0) I think you can write something like this: ``` = f.t...
You can view the source on render at <http://rubydoc.info/docs/rails/ActionView/Helpers/Tags/Label> to see how Rails does it. It probably doesn't get a lot better than you have, but you could probably swipe some of Rail's logic and stick it in a helper, if you have a lot of them to do. Alternatively, you may consider u...
1
0
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
If using Rails 4.2, you can set the placeholder attribute to true: ``` = f.text_field :first_name, placeholder: true ``` and specify the placeholder text in the locale file like this: ``` en: helpers: placeholder: user: first_name: "Your name" ```
With Rails >= 4.2, you can set the placeholder attribute to true `= f.text_field :first_name, placeholder: true` and in your local file (e.g. en.yml): ``` ru: activerecord: attributes: user: first_name: Your name ``` otherwise (Rails >= 3.0) I think you can write something like this: ``` = f.t...
5
1
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
You can open the background page's console if you click on the "background.html" link in the extensions list. To access the background page that corresponds to your extensions open `Settings / Extensions` or open a new tab and enter `chrome://extensions`. You will see something like this screenshot. ![Chrome extensi...
Curently with Manifest 3 and service worker, you just need to go to `Extensions Page / Details` and just click `Inspect Views / Service Worker`.
8
1
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
To answer your question directly, when you call `console.log("something")` from the background, this message is logged, to the background page's console. To view it, you may go to `chrome://extensions/` and click on that `inspect view` under your extension. When you click the popup, it's loaded into the current page, ...
It's an old post, with already good answers, but I add my two bits. I don't like to use console.log, I'd rather use a logger that logs to the console, or wherever I want, so I have a module defining a log function a bit like this one ``` function log(...args) { console.log(...args); chrome.extension.getBackgroundP...
6
2