qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
45,115,027 | I am using [qrcode.js](https://davidshimjs.github.io/qrcodejs/) for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add onclick function it add new not to random it.
JSFIDDLE: <https://jsfiddle.n... | 2017/07/15 | [
"https://Stackoverflow.com/questions/45115027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017838/"
] | Try adding `$('#qrcode').html('');` as the first item in the `.click(function(){}`
Like this:
```
$('#lithird').click(function(){
$('#qrcode').html(''); // <---Add this, which should clear it out on the next click
var qrcode = new QRCode("qrcode");
function makeCode () {
function ... | ```js
$(".generatetext").click(function(e) {
e.preventDefault();
var x = randomNumber(13);
$('#output').html('').qrcode(x);
});
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber... |
45,115,027 | I am using [qrcode.js](https://davidshimjs.github.io/qrcodejs/) for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add onclick function it add new not to random it.
JSFIDDLE: <https://jsfiddle.n... | 2017/07/15 | [
"https://Stackoverflow.com/questions/45115027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017838/"
] | Try adding `$('#qrcode').html('');` as the first item in the `.click(function(){}`
Like this:
```
$('#lithird').click(function(){
$('#qrcode').html(''); // <---Add this, which should clear it out on the next click
var qrcode = new QRCode("qrcode");
function makeCode () {
function ... | ```js
$('#lithird').click(function() {
var qrcode = new QRCode("qrcode");
function makeCode() {
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * ... |
45,115,027 | I am using [qrcode.js](https://davidshimjs.github.io/qrcodejs/) for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add onclick function it add new not to random it.
JSFIDDLE: <https://jsfiddle.n... | 2017/07/15 | [
"https://Stackoverflow.com/questions/45115027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017838/"
] | You were missing a function `transfer_new` defined in your `onclick` that was causing a JavaScript error.
```js
function transfer_new() {
$('#qrcode').html('');
}
$('#lithird').click(function() {
var qrcode = new QRCode("qrcode");
function makeCode() {
function randomNumber(len) {
... | ```js
$('#lithird').click(function() {
var qrcode = new QRCode("qrcode");
function makeCode() {
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * ... |
45,115,027 | I am using [qrcode.js](https://davidshimjs.github.io/qrcodejs/) for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add onclick function it add new not to random it.
JSFIDDLE: <https://jsfiddle.n... | 2017/07/15 | [
"https://Stackoverflow.com/questions/45115027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017838/"
] | Just clear the content before generating new
```js
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * 10);
n += randomNumber.toString();
}
return n;
... | ```js
$('#lithird').click(function() {
var qrcode = new QRCode("qrcode");
function makeCode() {
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * ... |
45,115,027 | I am using [qrcode.js](https://davidshimjs.github.io/qrcodejs/) for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add onclick function it add new not to random it.
JSFIDDLE: <https://jsfiddle.n... | 2017/07/15 | [
"https://Stackoverflow.com/questions/45115027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017838/"
] | ```js
$(".generatetext").click(function(e) {
e.preventDefault();
var x = randomNumber(13);
$('#output').html('').qrcode(x);
});
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber... | ```js
$('#lithird').click(function() {
var qrcode = new QRCode("qrcode");
function makeCode() {
function randomNumber(len) {
var randomNumber;
var n = '';
for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * ... |
36,437,489 | I have a problem were I've set an image inside a box but when I run the program i see that the box doesn't contain the image.
I've tried fixing it and realized that when i take out the `align = "left"` attribute the problem goes away.
I don't understand why this happens or how to avoid it if someone could explain it... | 2016/04/05 | [
"https://Stackoverflow.com/questions/36437489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6145977/"
] | you need to set `(max-)width:100%` in `img`, and don't use html `align` nor `hspace`, they are **deprecated**.
When you use `align=left`(used in CSS nowadays as `float:left`) you are taking the element out of normal DOM flow, and placing on the left side of its container, with this content will wrap around the "floate... | Use `overflow:hidden` in your div:
```css
div.body
{
background-color:blue;
padding:15px;
height:auto;
overflow:hidden;
}
```
```html
<div class = "body">
<img id = "full" src = "../Photos/controler.png" alt = "altvalue" hspace = "15" usemap = "imgmap" align = "left"/>
</div>
``` |
36,437,489 | I have a problem were I've set an image inside a box but when I run the program i see that the box doesn't contain the image.
I've tried fixing it and realized that when i take out the `align = "left"` attribute the problem goes away.
I don't understand why this happens or how to avoid it if someone could explain it... | 2016/04/05 | [
"https://Stackoverflow.com/questions/36437489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6145977/"
] | you need to set `(max-)width:100%` in `img`, and don't use html `align` nor `hspace`, they are **deprecated**.
When you use `align=left`(used in CSS nowadays as `float:left`) you are taking the element out of normal DOM flow, and placing on the left side of its container, with this content will wrap around the "floate... | Assuming that you need to have align="left" in there for whatever reason that may be, you can "clear" the parent container by adding `width:100%; overflow:auto;`
```
div.body {
background-color:blue;
padding:15px;
height:auto;
width:100%;
overflow:auto;
}
``` |
36,437,489 | I have a problem were I've set an image inside a box but when I run the program i see that the box doesn't contain the image.
I've tried fixing it and realized that when i take out the `align = "left"` attribute the problem goes away.
I don't understand why this happens or how to avoid it if someone could explain it... | 2016/04/05 | [
"https://Stackoverflow.com/questions/36437489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6145977/"
] | you need to set `(max-)width:100%` in `img`, and don't use html `align` nor `hspace`, they are **deprecated**.
When you use `align=left`(used in CSS nowadays as `float:left`) you are taking the element out of normal DOM flow, and placing on the left side of its container, with this content will wrap around the "floate... | the float element always destroy its child element `height`. So the better solution use `overflow:hidden` or use clearfix hack see [What is clearfix?](https://stackoverflow.com/questions/8554043/what-is-clearfix) and [here](https://css-tricks.com/snippets/css/clear-fix/) |
13,958 | When I create a standard select box using the Drupal 7 form API, the first value (also the one selected on a fresh 'blank form') is `<option selected="selected" value="">- Select -</option>`. This value is not specified in the form definition and I am doing no form altering. (This is fine)
However, when I create a sec... | 2011/10/24 | [
"https://drupal.stackexchange.com/questions/13958",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/3118/"
] | To force the "empty option", assign it with something like:
```
"#empty_option"=>t('- Select -'),
``` | you need change this:
```
'visible' => Array('select[name=first_select]' => array('value' => '2')),
'required' => Array('select[name=first_select]' => array('value' => '2')),
```
select to :input
the correct code is :
```
'visible' => Array(':input[name="first_select"]' => array('value' => '2')),
'required' =>... |
13,958 | When I create a standard select box using the Drupal 7 form API, the first value (also the one selected on a fresh 'blank form') is `<option selected="selected" value="">- Select -</option>`. This value is not specified in the form definition and I am doing no form altering. (This is fine)
However, when I create a sec... | 2011/10/24 | [
"https://drupal.stackexchange.com/questions/13958",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/3118/"
] | To force the "empty option", assign it with something like:
```
"#empty_option"=>t('- Select -'),
``` | To extend doterobcn answer you can also set the empty value (the key) of your empty option.
In Drupal 8:
```
$form['country'] = [
'#type' => 'select',
'#multiple' => FALSE,
'#title' => t('Country:'),
'#required' => FALSE,
'#options' => $countries,
'#default_value' => 'FR',
'#empty_option' => t('- None -... |
13,958 | When I create a standard select box using the Drupal 7 form API, the first value (also the one selected on a fresh 'blank form') is `<option selected="selected" value="">- Select -</option>`. This value is not specified in the form definition and I am doing no form altering. (This is fine)
However, when I create a sec... | 2011/10/24 | [
"https://drupal.stackexchange.com/questions/13958",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/3118/"
] | you need change this:
```
'visible' => Array('select[name=first_select]' => array('value' => '2')),
'required' => Array('select[name=first_select]' => array('value' => '2')),
```
select to :input
the correct code is :
```
'visible' => Array(':input[name="first_select"]' => array('value' => '2')),
'required' =>... | To extend doterobcn answer you can also set the empty value (the key) of your empty option.
In Drupal 8:
```
$form['country'] = [
'#type' => 'select',
'#multiple' => FALSE,
'#title' => t('Country:'),
'#required' => FALSE,
'#options' => $countries,
'#default_value' => 'FR',
'#empty_option' => t('- None -... |
18,247,069 | I have a SQL database linking to a PHP page which produces the following JSON:
`[{"ID":"1","SubjectName":"Subject 1"},{"ID":"2","SubjectName":"Subject 2"}]`
I was wondering how to format and display this in a separate HTML page. For example:
(Using JQuery Mobile)
```
<ul data-role="listview" data-divider-theme="b" d... | 2013/08/15 | [
"https://Stackoverflow.com/questions/18247069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2348732/"
] | An option could be using **AJAX** or any implementation like **jQuery**.
You can use the jQuery AJAX object in the **html** file like this:
```
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
```
1. **type** is the method to send the info, post or get
2. **url** is th... | The JSON `{"ID":"1","SubjectName":"Subject 1"}`
---
```
$.ajax({
url: 'THE_URL_YOU_GET_THE_DATA_FROM',
dataType: 'json'
success: getInfo1
});
function getInfo1(json) {
var r = '<ul data-role="listview">';
var l = json.length;
for (i = 0; i < l; i++) {
r += '<li><h4>' + json[i].SubjectN... |
813,695 | In the Newton-Raphson method we come across the following equation:
$$x\_{n+1}=x\_n - \frac{f(x\_n)}{f'(x\_n)}$$
Can you please let me know if we can calculate the derivative term like this -
$$f'(x\_n) = \frac{f(x\_n) - f(x\_{n-1})}{x\_n-x\_{n-1}}$$
Will rate of convergence of the original Newton-Raphson Method and ... | 2014/05/29 | [
"https://math.stackexchange.com/questions/813695",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/110921/"
] | You have rediscovered the [secant method](http://en.wikipedia.org/wiki/Secant_method).
The secant method a bit slower in the vicinity of the root than Newton-Raphson: its order is $1.618$ instead of $2$. However, since there is just one function evaluation per step (versus two for N-R: $f$ and $f'$), it may actually ... | The answer of user147263 is not correct. The secant method is not the same as the Newton method with numerical gradients.
Generally the Secant method is defined as:
$x\_n
= x\_{n-1} - f(x\_{n-1}) \frac{x\_{n-1} - x\_{n-2}}{f(x\_{n-1}) - f(x\_{n-2})}
= \frac{x\_{n-2} f(x\_{n-1}) - x\_{n-1} f(x\_{n-2})}{f(x\_{n-1}) -... |
11,672,628 | I understand that the /Developer folder no longer exists after installing XCode4.3. To me, this seems it would have bad consequences. First, CUDA installs into /Developer/GPU\_Computing. Second, what happens to the GCC keychain? Eclipse relies on the GCC keychain command line tools, which I'm told disappear with Xcode ... | 2012/07/26 | [
"https://Stackoverflow.com/questions/11672628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/743188/"
] | That's it:
```
^(\d+,)*\d+$
```
The anchors `^$` will make the difference because they will force the whole string (not just a part) to match the pattern | You should try pattern like this:
```
^(?:(\d+),)+(\d)+$
``` |
37,050,123 | Can someone please show me where my code is incorrect for adding form values into a coordinate table? I let user enter number of coordinates to enter (that produces the text boxes on this page) before this page and then the coordinate values should be entered and populated to the database. I keep getting array to strin... | 2016/05/05 | [
"https://Stackoverflow.com/questions/37050123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1334439/"
] | As other authors says, the mysql\_ functions is outdated and does not work in PHP 7, you should choose something different. In addition, you did not sanitize the POST variables and malicious users can do anything with your database.
Here is the replacement with modern PDO:
```php
<?php
if(isset($_POST['add'])) {
... | You have your query string as shown below:
```
$sql = "INSERT INTO coordTable". "(x, y, z)
) ". "VALUES('$textX','$textY',$textZ)";
```
Whereas query string should be as shown below:
```
$sql = "INSERT INTO coordTable". "(x, y, z)
) ". "VALUES('$textX','$textY','$textZ')";
``` |
4,319,939 | Trying to solve 2 equations with 2 unknown using MATLAB and it is not liking my input.
Where c is 3.06 + 2.57j, and v is 12:
```
eq1 = 'c = a/10j'
eq2 = '(6b)/50 + b/10j = a/10j + a/10'
```
Trying to solve for a and b. Any suggestions of how to properly put these in? | 2010/11/30 | [
"https://Stackoverflow.com/questions/4319939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/525883/"
] | Matlab is screwed up, but the syntax is
```
sol = solve(eq1,x1,eq2,x2,..);
```
It would make more sense to make it `solve({eq1,eq2,..},{x1,x2,..})` but no, we have to write out all the arguments one by one.
Anyway the trick is that eq1, eq2, .. are symbolic expressions that must be evaluated to zero. So instead of ... | you need to tell matlab that c,eq1,eq2,a,j (is this not complex?), and b are a symbolic variables. i.e. use the command "syms a b c j eq1 eq2". Then define everything as you have done above minus your single quotes (that's a string!).
then you can just use the 'solve(eq2,'variable you want to solve for'). Easy enough. |
23,436,962 | I need to change the iframe url from the same iframe.
For example: "**<http://parent.com>**" is the Parent Domain URL of my website with an http
and: "**<https://iframe.com>**" is the iframe Domain URL with an https. The two domains are different.
Here's the code of the parent window:
```
<html>
<head>
<... | 2014/05/02 | [
"https://Stackoverflow.com/questions/23436962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3456995/"
] | You can achieve this using NOT EXISTS and MEMBER OF. Something like this
```
$qb->select('q.question_id, q.question_intitule')
->from('MyBundleNameSpace\Entity\Question', 'q')
->where('NOT EXISTS (SELECT 1 FROM MyBundleNameSpace\Entity\Jouer j WHERE j MEMBER OF q.jouers)');
``` | Thank you for your answer FuzzyTree! It works!
I had adapted it in order to put it into my QuestionRepository.
Here is my method:
```
public function findNotAnsweredByJoueurs(Partie $partie, $level)
{
$qb = $this->createQueryBuilder('q');
$qb->where('q.level < ' . $level);
foreach($partie->getJoueurs() as... |
2,200,338 | I use an interface of RenderedImage for reading a tif image.
How can I get all rgb values of this picture in a 2d-Array like this:
```
red[0][128] = 120; // means x=0, y=128, red value = 120
// the value 120 is the value I have to determine (and oall other rgb values)!
```
Does anyone know this?
Thanks a lot for yo... | 2010/02/04 | [
"https://Stackoverflow.com/questions/2200338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/224030/"
] | `getData()` returns a `Raster`, which has a `getData()` method.
Can you call `YourRenderedImage.getData().getPixel(int x, int y, int iArray[])` to get your RGB values?
JavaDoc: Returns the samples in an array of int for the specified pixel. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in... | Like [Abboq](https://stackoverflow.com/users/244168/abboq), I thought you wanted to traverse the `Raster`, which should work. Alternatively, you might be able to use [`BandSelect`](http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-manipulation.doc.html#63344) to get each of the three ban... |
23,285,156 | I have a random list of numbers say 1,8,13,20,25,32,50,55,64,70 now given a number say 35 the lesser value required will be 32 and greater value will be 50.
the way I tried to do this is by iterating all the values
---
```
var value = 35;
var list = new List<int> { 1, 8, 13, 20, 25, 32, 50, 55, 64, 7... | 2014/04/25 | [
"https://Stackoverflow.com/questions/23285156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1349324/"
] | ```
int value = 35;
int[] list = new[] { 1, 8, 13, 20, 25, 32, 50, 55, 64, 70 };
int? floor = null;
int? ceil = null;
int index = Array.BinarySearch(list, value);
if (index >= 0) // element is found
{
if (index > 0)
floor = list[index - 1];
if (index < list.Length - 1)
ceil = list[index + 1];
}
... | If list is sorted, you can do like this:
```
int value = 35;
var lessThan = list.TakeWhile(p => p < value).LastOrDefault();
var greaterThan = list.SkipWhile(p => p <= value).FirstOrDefault();
``` |
47,450,543 | I have created a java class to execute a batch file that is in my desktop so that the commands in the batch file will be executed too. The problem is that, i keep getting the error:
>
> The filename, directory name, or volume label syntax is incorrect.
> The filename, directory name, or volume label syntax is incor... | 2017/11/23 | [
"https://Stackoverflow.com/questions/47450543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8994659/"
] | there is no such thing as `desktop:\`
Instead try something like this.
```
@echo off
echo . %userprofile%\Desktop\testing\dblank.txt
@echo Writing text to draft.txt > %userprofile%\Desktop\testing\dblank.txt
``` | You just need to change a directory and create new subdirectory if it not exist. My offer is change .bat file like this:
```
@echo off
if not exist "%userprofile%\Desktop\testing" mkdir "%userprofile%\Desktop\testing"
echo.>"%userprofile%\Desktop\draft.txt"
@echo Writing text to draft.txt>"%userprofile%\Desktop\draft.... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | I'm not aware that you can do arithmetic or other computations in regexes. If there's a regex engine out there that supports that, it would be really nifty! But my understanding is that wouldn't be practical without hugely slowing down the regex engine.
I think your best bet would be to use the `sub` regex function/me... | Unless gedit is a superset of Python, it won't allow operations inside a replace-regex as you're trying to do with `(\3-2)`. In any case, `\3` is a string and you'd need to convert with int() first.
So you'd have to break it into separate *re.search(...)*, compute the inserted pageno, then insert.
Second issue is that... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | The following code does what you want on the string you gave as an example. One point is that it is very specific to the format of this one string. It can't manage any variability in the string. It is really limited to only this type of string format.
```
import re
ss = '''PART 1 DATA MODELS Chapter
2 Entity-Relation... | I'm not aware that you can do arithmetic or other computations in regexes. If there's a regex engine out there that supports that, it would be really nifty! But my understanding is that wouldn't be practical without hugely slowing down the regex engine.
I think your best bet would be to use the `sub` regex function/me... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | You can pass to `re.sub` lambda function which takes `re.MatchObject` object for every non-overlapping pattern match and returns replacement string. For example:
```
import re
print re.sub("(\d+)\+(\d+)",
lambda m: str(int(m.group(1))+int(m.group(2))),
"If 2+2 is 4 then 1+2+3+4 is 10")
`... | I'm not aware that you can do arithmetic or other computations in regexes. If there's a regex engine out there that supports that, it would be really nifty! But my understanding is that wouldn't be practical without hugely slowing down the regex engine.
I think your best bet would be to use the `sub` regex function/me... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | The following code does what you want on the string you gave as an example. One point is that it is very specific to the format of this one string. It can't manage any variability in the string. It is really limited to only this type of string format.
```
import re
ss = '''PART 1 DATA MODELS Chapter
2 Entity-Relation... | Unless gedit is a superset of Python, it won't allow operations inside a replace-regex as you're trying to do with `(\3-2)`. In any case, `\3` is a string and you'd need to convert with int() first.
So you'd have to break it into separate *re.search(...)*, compute the inserted pageno, then insert.
Second issue is that... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | You can pass to `re.sub` lambda function which takes `re.MatchObject` object for every non-overlapping pattern match and returns replacement string. For example:
```
import re
print re.sub("(\d+)\+(\d+)",
lambda m: str(int(m.group(1))+int(m.group(2))),
"If 2+2 is 4 then 1+2+3+4 is 10")
`... | Unless gedit is a superset of Python, it won't allow operations inside a replace-regex as you're trying to do with `(\3-2)`. In any case, `\3` is a string and you'd need to convert with int() first.
So you'd have to break it into separate *re.search(...)*, compute the inserted pageno, then insert.
Second issue is that... |
6,824,471 | I am using gedit regex plugin (Python style regex). I would like to do some arithmetic operation on a backreference to a group.
For example:
```
PART 1 DATA MODELS Chapter
2 Entity-Relationship Model 27
```
I would like to change it to be
```
PART 1 DATA MODELS Chapter 25
2 Entity-Relationship Model 27
```
My... | 2011/07/26 | [
"https://Stackoverflow.com/questions/6824471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156458/"
] | You can pass to `re.sub` lambda function which takes `re.MatchObject` object for every non-overlapping pattern match and returns replacement string. For example:
```
import re
print re.sub("(\d+)\+(\d+)",
lambda m: str(int(m.group(1))+int(m.group(2))),
"If 2+2 is 4 then 1+2+3+4 is 10")
`... | The following code does what you want on the string you gave as an example. One point is that it is very specific to the format of this one string. It can't manage any variability in the string. It is really limited to only this type of string format.
```
import re
ss = '''PART 1 DATA MODELS Chapter
2 Entity-Relation... |
53,063,693 | I have DataFrame *x* and I would like to replace one column with Series *y*
```
x = DataFrame([[1,2],[3,4]], columns=['C1','C2'], index=['a','b'])
C1 C2
a 1 2
b 3 4
y = Series([5,6,7], index=['a','b','c'])
a 5
b 6
c 7
```
Simple replacement works fine but keeps original index of DataFrame
``... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53063693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10500689/"
] | Similar to your solution but more succinct, you use [`reindex`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html), then [`assign`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.assign.html):
```
res = x.reindex(x.index | y.index).assign(C1=y)
print(res)
... | You can use `concat` but you will have to fix the column names, i.e.
```
import pandas as pd
pd.concat([x.loc[:, 'C2'], y], axis = 1)
```
which gives,
>
>
> ```
> C2 0
> a 2.0 5
> b 4.0 6
> c NaN 7
>
> ```
>
> |
53,063,693 | I have DataFrame *x* and I would like to replace one column with Series *y*
```
x = DataFrame([[1,2],[3,4]], columns=['C1','C2'], index=['a','b'])
C1 C2
a 1 2
b 3 4
y = Series([5,6,7], index=['a','b','c'])
a 5
b 6
c 7
```
Simple replacement works fine but keeps original index of DataFrame
``... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53063693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10500689/"
] | Your cat try use join:
```
pd.DataFrame(y,columns=['C1']).join(x[['C2']])
```
Output:
```
C1 C2
a 5 2.0
b 6 4.0
c 7 NaN
``` | You can use `concat` but you will have to fix the column names, i.e.
```
import pandas as pd
pd.concat([x.loc[:, 'C2'], y], axis = 1)
```
which gives,
>
>
> ```
> C2 0
> a 2.0 5
> b 4.0 6
> c NaN 7
>
> ```
>
> |
53,063,693 | I have DataFrame *x* and I would like to replace one column with Series *y*
```
x = DataFrame([[1,2],[3,4]], columns=['C1','C2'], index=['a','b'])
C1 C2
a 1 2
b 3 4
y = Series([5,6,7], index=['a','b','c'])
a 5
b 6
c 7
```
Simple replacement works fine but keeps original index of DataFrame
``... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53063693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10500689/"
] | ### [`combine_first`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.combine_first.html)
Turn `y` into a `DataFrame` first with `to_frame`
```
y.to_frame('C1').combine_first(x)
C1 C2
a 5 2.0
b 6 4.0
c 7 NaN
```
---
### [`align`](https://pandas.pydata.org/pandas-docs/stable/g... | You can use `concat` but you will have to fix the column names, i.e.
```
import pandas as pd
pd.concat([x.loc[:, 'C2'], y], axis = 1)
```
which gives,
>
>
> ```
> C2 0
> a 2.0 5
> b 4.0 6
> c NaN 7
>
> ```
>
> |
53,063,693 | I have DataFrame *x* and I would like to replace one column with Series *y*
```
x = DataFrame([[1,2],[3,4]], columns=['C1','C2'], index=['a','b'])
C1 C2
a 1 2
b 3 4
y = Series([5,6,7], index=['a','b','c'])
a 5
b 6
c 7
```
Simple replacement works fine but keeps original index of DataFrame
``... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53063693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10500689/"
] | ### [`combine_first`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.combine_first.html)
Turn `y` into a `DataFrame` first with `to_frame`
```
y.to_frame('C1').combine_first(x)
C1 C2
a 5 2.0
b 6 4.0
c 7 NaN
```
---
### [`align`](https://pandas.pydata.org/pandas-docs/stable/g... | Similar to your solution but more succinct, you use [`reindex`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html), then [`assign`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.assign.html):
```
res = x.reindex(x.index | y.index).assign(C1=y)
print(res)
... |
53,063,693 | I have DataFrame *x* and I would like to replace one column with Series *y*
```
x = DataFrame([[1,2],[3,4]], columns=['C1','C2'], index=['a','b'])
C1 C2
a 1 2
b 3 4
y = Series([5,6,7], index=['a','b','c'])
a 5
b 6
c 7
```
Simple replacement works fine but keeps original index of DataFrame
``... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53063693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10500689/"
] | ### [`combine_first`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.combine_first.html)
Turn `y` into a `DataFrame` first with `to_frame`
```
y.to_frame('C1').combine_first(x)
C1 C2
a 5 2.0
b 6 4.0
c 7 NaN
```
---
### [`align`](https://pandas.pydata.org/pandas-docs/stable/g... | Your cat try use join:
```
pd.DataFrame(y,columns=['C1']).join(x[['C2']])
```
Output:
```
C1 C2
a 5 2.0
b 6 4.0
c 7 NaN
``` |
63,837,718 | I have two arrays and I would like to compare if these arrays have duplicated values, then return the values that aren't duplicates. Based on these two arrays I would like to return the string `Eucalipto`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63837718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9630955/"
] | You can use `Array#map` to find all the `kind` values, pass that to the `Set` constructor, and then use `Array#filter` to find all elements of the array not in that `Set`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
const auxPlants = [
"Cana-de-açu... | sounds like you want to filter the array of values you're interested in based on if they're not found in the other array, like so:
```
const nonDuplicates = auxPlants.filter(a => !plants.find(p => p.kind === a))
```
it's unclear if you'd also want values from the `plants` array that are non duplicate as well, or if ... |
63,837,718 | I have two arrays and I would like to compare if these arrays have duplicated values, then return the values that aren't duplicates. Based on these two arrays I would like to return the string `Eucalipto`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63837718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9630955/"
] | You can use `Array#map` to find all the `kind` values, pass that to the `Set` constructor, and then use `Array#filter` to find all elements of the array not in that `Set`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
const auxPlants = [
"Cana-de-açu... | This is the solution to it, I have explained it's working using comments
```js
// create a set in order to store values in it
// assuming you have unique values
let set = new Set();
// iterating over array of object and storing the value of 'kind' in the set
for(obj of plants){
set.add(obj.kind);
}
// iterating ove... |
63,837,718 | I have two arrays and I would like to compare if these arrays have duplicated values, then return the values that aren't duplicates. Based on these two arrays I would like to return the string `Eucalipto`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63837718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9630955/"
] | You can use `Array#map` to find all the `kind` values, pass that to the `Set` constructor, and then use `Array#filter` to find all elements of the array not in that `Set`.
```js
const plants = [
{
id: 59,
kind: "Cana-de-açucar"
},
{
id: 60,
kind: "Citros"
}
];
const auxPlants = [
"Cana-de-açu... | As said, please search for an already posted solution first. [Here's](https://stackoverflow.com/questions/14930516/compare-two-javascript-arrays-and-remove-duplicates) what I found.
Anyhow, the solution would be to separate the types of plants from the first array, as so:
```
const plantsTypes = plants.map(obj => obj... |
54,241,368 | ASP.NET Core 2.x includes some pre-made scaffolded routes, like the login page, settings, etc. I am working on something that only has OAuth login buttons, and no settings. This means that I don't want users to be able to register with an email, and I don't want any settings pages.
I can remove the link to things like... | 2019/01/17 | [
"https://Stackoverflow.com/questions/54241368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79677/"
] | **Approach #1**
We can use [`1D` convolution](https://www.numpy.org/devdocs/reference/generated/numpy.convolve.html) -
```
def nzeros(a, n):
# Define kernel for 1D convolution
k = np.ones(n,dtype=int)
# Get sliding summations for zero matches with that kernel
s = np.convolve(a==0,k)
# Look for s... | Using for loop:
```
def nzeros(a, n):
#Create a numpy array of zeros of length equal to n
b = np.zeros(n)
#Create a numpy array of zeros of same length as array a
c = np.zeros(len(a), dtype=int)
for i in range(0,len(a) - n):
if (b == a[i : i+n]).all(): #Check if array b is equal to slice in a
c[... |
1,488,682 | Find the limit of $f(x)=\frac{\sqrt{5-x}-1}{2-\sqrt{x}}$ when x approaches 4.
I have no idea where to start with this problem. | 2015/10/20 | [
"https://math.stackexchange.com/questions/1488682",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/271941/"
] | **Without using L'Hospital's rule**
Notice,
Rationalizing the numerator & denominator as follows
$$\lim\_{x\to 4}\frac{\sqrt{5-x}-1}{2-\sqrt{x}}$$
$$=\lim\_{x\to 4}\frac{(\sqrt{5-x}-1)(\sqrt{5-x}+1)(2+\sqrt{x})}{(2-\sqrt{x})(2+\sqrt{x})(\sqrt{5-x}+1)}$$
$$=\lim\_{x\to 4}\frac{(5-x-1)(2+\sqrt{x})}{(4-x)(\sqrt{5-... | Notice,
Using l'Hopital's rule for $\frac{0}{0}$ form
$$\lim\_{x\to 4}\frac{\sqrt{5-x}-1}{2-\sqrt{x}}$$
$$=\lim\_{x\to 4}\frac{\frac{d}{dx}(\sqrt{5-x}-1)}{\frac{d}{dx}(2-\sqrt{x})}$$
$$=\lim\_{x\to 4}\frac{\frac{-1}{2\sqrt{5-x}}}{\frac{-1}{2\sqrt{x}}}$$ $$=\lim\_{x\to 4}\frac{\sqrt x}{\sqrt{5-x}}$$ $$=\frac{\sq... |
22,800,628 | I want to send file with OutputStream,
so I use `byte[] = new byte[size of file ]`
but I don't know what the max size is that i can use.
This is my code.
```
File file = new File(sourceFilePath);
if (file.isFile()) {
try {
DataInputStream diStream = new DataInputStream(new Fi... | 2014/04/02 | [
"https://Stackoverflow.com/questions/22800628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2522119/"
] | The reason you're getting an exception is due to this line:
```
long len = (int) file.length();
```
A narrowing conversion from a `long` to an `int` may result in a change in sign, because higher order bits are discarded. See [JLS Chapter 5, section 5.1.3](http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html)... | Well, this is a quite dangerous way to read files. `int` in Java is 32-bit int, so it resides in range -2147483648 - 2147483647, while `long` is 64 bit.
Generally you shouldn't read the whole file at once because your program may exhaust your RAM on big files. Use a [BufferedReader](http://docs.oracle.com/javase/7/doc... |
3,321,166 | If $A$ and $B$ are $n \times n$ matrices such that $A^{2} B^{2} = 0$ then which of the following is true?
a) $B^{2} A^{2} = 0$
b) $AB = 0$
c) Either $A^{2} =0$ or $B^{2} = 0$.
d) Either $A$ or $B$ has zero determinant.
My current reasoning:
$$A^{2} B^{2} = 0. $$
So,
$$\det(A^{2}B^{2}) = 0$$
$$\det(A^{2}) \det(B^{... | 2019/08/12 | [
"https://math.stackexchange.com/questions/3321166",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/569642/"
] | The inequality of arithmetic and geometric means implies that the product can never be larger than $6^3 = 216$. As a rule of thumb, the further you go away from the equal case, the smaller the product gets. So you only need to check the extreme cases, i.e. $(1,2,15)$ here. | Assume (x+y+z)/3=6 thus x+y+z =18. The largest of x,y, and x can be at most 15. (15+2+1)=18. This gives us a volume, (xyz), of 30 units cubed. This is also the smallest volume you can get. This can be visualized in 3D space. Every other combination would have three non zero terms. I haven’t worked out a proof of this b... |
25,617,358 | How much is the overhead of creating following objects everytime sending the message to queue?
Objects: `javax.jms.Connection`, `javax.jms.Session`, `javax.jms.MessageProducer`
In my code, Whenever I want to send a message, I am creating above 3 objects.
I know its good to create object only once and use it but the c... | 2014/09/02 | [
"https://Stackoverflow.com/questions/25617358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3603258/"
] | <https://developer.jboss.org/wiki/ShouldICacheJMSConnectionsAndJMSSessions>
[High Performance JMS Messaging](https://stackoverflow.com/questions/11840630/high-performance-jms-messaging)
:) | It is always a costly affair to create a connection and session to a messaging provider every time. Every time a connection is requested, the underlying messaging library has to create a socket connection to messaging provider, flow some handshake data and establish a channel using which messages can be sent. After mes... |
10,219,923 | I am trying @autowired for the first time, and failing. I have read so many examples, and I seem to be doing everything right, but when my code hits my getLeagueDAO() method, the instance variable is set to null.
I have the following code:
```
package com.example.app.service;
@Service
public class LeagueService {
... | 2012/04/19 | [
"https://Stackoverflow.com/questions/10219923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337819/"
] | The following works
**Unit Test**
```
package com.example.app.service;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
impo... | Have you checked to see if the Spring container is starting when you start the app? It could be an issue with your `web.xml` configuration. |
17,653,294 | I'm trying to implement a ManyToMany relation in a form between 2 entities (say, Product and Category to make simpe) and use the method described in the docs with prototype and javascript (<http://symfony.com/doc/current/cookbook/form/form_collections.html>).
Here is the line from ProductType that create the category ... | 2013/07/15 | [
"https://Stackoverflow.com/questions/17653294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1932520/"
] | I finally found a way to handle that with Event listeners.
This [discussion](https://stackoverflow.com/questions/9651095/description-of-symfony2-form-events) give the meaning of all FormEvents.
In this case, PRE\_BIND (replaced by PRE\_SUBMIT in 2.1 and later) will allow us to modify the data before it is bind to the E... | Since Symfony 3.4 you can pass a closure to `delete_empty`:
```php
$builder
->add('authors', CollectionType::class, [
'delete_empty' => function ($author) {
return empty($author['firstName']);
},
]);
```
<https://github.com/symfony/symfony/commit/c0d99d13c023f9a5c87338581c2a4a674b... |
17,653,294 | I'm trying to implement a ManyToMany relation in a form between 2 entities (say, Product and Category to make simpe) and use the method described in the docs with prototype and javascript (<http://symfony.com/doc/current/cookbook/form/form_collections.html>).
Here is the line from ProductType that create the category ... | 2013/07/15 | [
"https://Stackoverflow.com/questions/17653294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1932520/"
] | Citing the [documentation](http://symfony.com/doc/current/reference/forms/types/collection.html#delete-empty) on 'delete\_empty':
>
> If you want to explicitly remove entirely empty collection entries from your form you have to set this option to true
>
>
>
```
$builder->add('categories', 'collection', array(
... | Since Symfony 3.4 you can pass a closure to `delete_empty`:
```php
$builder
->add('authors', CollectionType::class, [
'delete_empty' => function ($author) {
return empty($author['firstName']);
},
]);
```
<https://github.com/symfony/symfony/commit/c0d99d13c023f9a5c87338581c2a4a674b... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | I think I know what you are going through ... I recently had to deal with a situation where I was (among other things) comparing a meta value that may or may not exist.
The solution I found involved a very crazy SQl statment, with a WHERE IF clause.
In your case, it could look something like this (explanation below):... | ```
// $startday, $endday - format YYYY-MM-DD and field format: YYYY-MM-DD
$args= array();
$args['post_type'] = "event";
$args['meta_query'] = array(
relation' => 'OR',
array(
'key' => 'end_date',
... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... | ```
// $startday, $endday - format YYYY-MM-DD and field format: YYYY-MM-DD
$args= array();
$args['post_type'] = "event";
$args['meta_query'] = array(
relation' => 'OR',
array(
'key' => 'end_date',
... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... | I think I know what you are going through ... I recently had to deal with a situation where I was (among other things) comparing a meta value that may or may not exist.
The solution I found involved a very crazy SQl statment, with a WHERE IF clause.
In your case, it could look something like this (explanation below):... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | I think I know what you are going through ... I recently had to deal with a situation where I was (among other things) comparing a meta value that may or may not exist.
The solution I found involved a very crazy SQl statment, with a WHERE IF clause.
In your case, it could look something like this (explanation below):... | I'm seeing some awesome solutions, here; but could we be overthinking it?
Would this work...
```
$args= array();
$args['post_type'] = "event";
$args['meta_query'] = array();
if (!empty($end_date) && strtotime($end_date)) {
$args['meta_query'][] = array(
'key' => 'end_date',
'compare' =>... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | I think I know what you are going through ... I recently had to deal with a situation where I was (among other things) comparing a meta value that may or may not exist.
The solution I found involved a very crazy SQl statment, with a WHERE IF clause.
In your case, it could look something like this (explanation below):... | I Make this query for your issue. Kindly check it. Let me Know It's working?.
```
$global $wpdb;
$qry = "SELECT * from $wpdb->posts t1 WHERE t1.post_type='event' and t1.ID IN (SELECT t2.post_id from $wpdb->postmeta t2 WHERE ( CASE WHEN t2.meta_key = 'end_date' AND t2.meta_value IS NULL THEN t2.meta_key = 'start_date'... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... | I'm seeing some awesome solutions, here; but could we be overthinking it?
Would this work...
```
$args= array();
$args['post_type'] = "event";
$args['meta_query'] = array();
if (!empty($end_date) && strtotime($end_date)) {
$args['meta_query'][] = array(
'key' => 'end_date',
'compare' =>... |
256,751 | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... | I Make this query for your issue. Kindly check it. Let me Know It's working?.
```
$global $wpdb;
$qry = "SELECT * from $wpdb->posts t1 WHERE t1.post_type='event' and t1.ID IN (SELECT t2.post_id from $wpdb->postmeta t2 WHERE ( CASE WHEN t2.meta_key = 'end_date' AND t2.meta_value IS NULL THEN t2.meta_key = 'start_date'... |
5,735,786 | One part of web development (from a front-end perspective) is laying out forms. There is never a standard set, and I've seen people continuing to use `<tables>` to keep styling consistent. Say you were to lay out this form:

At first glance it seems ... | 2011/04/20 | [
"https://Stackoverflow.com/questions/5735786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396956/"
] | I must say, *the most common way to do this would be to use tables*. Unfortunately, there are problems with table based form layouts (big surprise). One big thing is that tables will bleed over their containers (if overflow is not hidden) and they don't squash their contents like CSS can do. On top of that, rendering t... | Personally? A table. At work? CSS. I go with whatever is required. There's the whole debate about the fact that a form is not in and of itself tabular data (like that of a form), which is true, and there is CSS that can create a cell-like structure.
If you're short on time and comfortable with only tables? Tables. Nex... |
5,735,786 | One part of web development (from a front-end perspective) is laying out forms. There is never a standard set, and I've seen people continuing to use `<tables>` to keep styling consistent. Say you were to lay out this form:

At first glance it seems ... | 2011/04/20 | [
"https://Stackoverflow.com/questions/5735786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396956/"
] | I must say, *the most common way to do this would be to use tables*. Unfortunately, there are problems with table based form layouts (big surprise). One big thing is that tables will bleed over their containers (if overflow is not hidden) and they don't squash their contents like CSS can do. On top of that, rendering t... | Research shows that labels above fields and fields all in one column are the easiest to fill out. Lukew has a lot of form's data/research/info:
<http://www.lukew.com/ff/entry.asp?504>
As a bonus, that's usually the easiest way to build the presentation layer as well. Plus, it's usually much more mobile-friendly out-o... |
5,735,786 | One part of web development (from a front-end perspective) is laying out forms. There is never a standard set, and I've seen people continuing to use `<tables>` to keep styling consistent. Say you were to lay out this form:

At first glance it seems ... | 2011/04/20 | [
"https://Stackoverflow.com/questions/5735786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396956/"
] | I must say, *the most common way to do this would be to use tables*. Unfortunately, there are problems with table based form layouts (big surprise). One big thing is that tables will bleed over their containers (if overflow is not hidden) and they don't squash their contents like CSS can do. On top of that, rendering t... | The practice of using tables as layout made sense prior to CSS, but tables are actually intended to present data and nothing else. The simplest way to layout a form is label above field in a single column, but it is possible to create the same grid-like layout that tables provide using the `<div>` element and some CSS.... |
5,735,786 | One part of web development (from a front-end perspective) is laying out forms. There is never a standard set, and I've seen people continuing to use `<tables>` to keep styling consistent. Say you were to lay out this form:

At first glance it seems ... | 2011/04/20 | [
"https://Stackoverflow.com/questions/5735786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396956/"
] | Research shows that labels above fields and fields all in one column are the easiest to fill out. Lukew has a lot of form's data/research/info:
<http://www.lukew.com/ff/entry.asp?504>
As a bonus, that's usually the easiest way to build the presentation layer as well. Plus, it's usually much more mobile-friendly out-o... | Personally? A table. At work? CSS. I go with whatever is required. There's the whole debate about the fact that a form is not in and of itself tabular data (like that of a form), which is true, and there is CSS that can create a cell-like structure.
If you're short on time and comfortable with only tables? Tables. Nex... |
5,735,786 | One part of web development (from a front-end perspective) is laying out forms. There is never a standard set, and I've seen people continuing to use `<tables>` to keep styling consistent. Say you were to lay out this form:

At first glance it seems ... | 2011/04/20 | [
"https://Stackoverflow.com/questions/5735786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396956/"
] | The practice of using tables as layout made sense prior to CSS, but tables are actually intended to present data and nothing else. The simplest way to layout a form is label above field in a single column, but it is possible to create the same grid-like layout that tables provide using the `<div>` element and some CSS.... | Personally? A table. At work? CSS. I go with whatever is required. There's the whole debate about the fact that a form is not in and of itself tabular data (like that of a form), which is true, and there is CSS that can create a cell-like structure.
If you're short on time and comfortable with only tables? Tables. Nex... |
36,849,633 | I'm really new to Angular (and plan to spend the whole week on it), and I'm following a tutorial on youtube and I think the guy who created it must have took a trip to another galaxy so there's no support anymore (but an awesome tut). I can't seem to get my home..html page to render to the browser and I'm at a total lo... | 2016/04/25 | [
"https://Stackoverflow.com/questions/36849633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You have some small typos when importing angular files:
```
<scripts type="text/javascript" src="libs/angular/angular.js"></scripts>
<scripts type="text/javascript" src="libs/angular-route/angular-route.js"</scripts>
```
should be:
```
<script type="text/javascript" src="lib/angular/angular.js"></script>
<script ty... | There might be something wrong with your hosting. When I browse to <https://chore-master-j-s-thomas-1.c9users.io/> your index page works ok. But when I attempt to access <https://chore-master-j-s-thomas-1.c9users.io/libs/angular/angular.js> I get the "cannot GET" error. Your site isn't loading any of your js libs so An... |
711,006 | I wrote a simple shell script to shutdown an ubuntu server. Then I created a cron job to execute this script at 23:59 everyday.
```
#!/bin/bash
sudo shutdown -h now
```
I got this error message:
```
sudo: no tty present and no askpass program specified
```
when I removed the sudo from the code, I got a different ... | 2014/02/04 | [
"https://superuser.com/questions/711006",
"https://superuser.com",
"https://superuser.com/users/279628/"
] | Make sure the cron script is executable and also running as root, and replace `shutdown` by its full path given to you by:
```
command -v shutdown
```
On Ubuntu GNU/Linux (and GNU/Linux in general), it should be `/sbin/shutdown` :
```
#!/bin/bash
/sbin/shutdown -h now
```
Note that adding a file named like `/etc/... | We can also use the command "sudo halt" to power off the Ubuntu Server. |
711,006 | I wrote a simple shell script to shutdown an ubuntu server. Then I created a cron job to execute this script at 23:59 everyday.
```
#!/bin/bash
sudo shutdown -h now
```
I got this error message:
```
sudo: no tty present and no askpass program specified
```
when I removed the sudo from the code, I got a different ... | 2014/02/04 | [
"https://superuser.com/questions/711006",
"https://superuser.com",
"https://superuser.com/users/279628/"
] | Make sure the cron script is executable and also running as root, and replace `shutdown` by its full path given to you by:
```
command -v shutdown
```
On Ubuntu GNU/Linux (and GNU/Linux in general), it should be `/sbin/shutdown` :
```
#!/bin/bash
/sbin/shutdown -h now
```
Note that adding a file named like `/etc/... | I was able to enable `poweroff` (normally a sudoer command) in an ssh prompt for non-sudoers, by, as a sudoer, adding the +s flag to the command executable. Like so:
`sudo chmod a+s /usr/sbin/poweroff`
After this, non-sudoers were be able to power off the system, over ssh, or even via a shell script running in their ... |
5,591,893 | How to modify default admin action "delete\_selected" | 2011/04/08 | [
"https://Stackoverflow.com/questions/5591893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/696513/"
] | [**`Action docs`**](http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#)
delete selected:
>
> If you wish to override this behavior,
> simply write a custom action which
> accomplishes deletion in your
> preferred manner – for example, by
> calling Model.delete() for each of the
> selected items.
>... | <http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#adding-actions-to-the-modeladmin>
You can write custom actions, so overwriting the delete\_selected action will allow you to carry out whatever functionality you need (see the warning box on the top of the page which mentions overwriting the delete() act... |
5,591,893 | How to modify default admin action "delete\_selected" | 2011/04/08 | [
"https://Stackoverflow.com/questions/5591893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/696513/"
] | <http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#adding-actions-to-the-modeladmin>
You can write custom actions, so overwriting the delete\_selected action will allow you to carry out whatever functionality you need (see the warning box on the top of the page which mentions overwriting the delete() act... | DOC:[Disabling actions](https://docs.djangoproject.com/en/1.10/ref/contrib/admin/actions/#disabling-actions)
Disabling a site-wide action
`admin.site.disable_action('delete_selected')`
Otherwise override `ModelAdmin.get_actions` |
5,591,893 | How to modify default admin action "delete\_selected" | 2011/04/08 | [
"https://Stackoverflow.com/questions/5591893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/696513/"
] | [**`Action docs`**](http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#)
delete selected:
>
> If you wish to override this behavior,
> simply write a custom action which
> accomplishes deletion in your
> preferred manner – for example, by
> calling Model.delete() for each of the
> selected items.
>... | DOC:[Disabling actions](https://docs.djangoproject.com/en/1.10/ref/contrib/admin/actions/#disabling-actions)
Disabling a site-wide action
`admin.site.disable_action('delete_selected')`
Otherwise override `ModelAdmin.get_actions` |
10,852,474 | i'm tying to create an apps in android which will allow the user to edit the personal info and save it again and it must override the old info....i tried but i didnt win :(.. im new in android please help here my code....
database.../////
//--updates a record--
public boolean updateRecords(long rowId, String NAME ,St... | 2012/06/01 | [
"https://Stackoverflow.com/questions/10852474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1430923/"
] | **You call bad update method**
This `db.update(USERS_TABLE, args,COLUMN_ID + "= "+ rowId,null)` is dangerous, replace this with it, maybe will be problem with this. If it won't work, problem will be elsewhere.
```
db.update(USERS_TABLE, args, COLUMN_ID + "=?", new String[] {String.valueOf(rowID)}) > 0;
``` | You should know the contact id in-order to update that.
<http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/> is also helpfull.
Thanks |
74,328,400 | This belongs to the product landing page project on freecodecamp. I created the header with 'position: fixed', and also nested a navigation bar inside the header.
```
<!--HEADER-->
<header id="header">
<img id="header-img" src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-lo... | 2022/11/05 | [
"https://Stackoverflow.com/questions/74328400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19411886/"
] | ```
SELECT UPPER(PROD_NAME)as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE lower(PROD_NAME) like '%documentation%'
and LENGTH(PROD_NAME) <= 35
order by 2 DESC;
``` | When I use PHP with MySQL, I personly use something like:
```
$setgeneral=$db->prepare("SELECT * FROM general where general_id=:general_id");
$setgeneral->execute(array('general_id' => 0));
$getgeneral=$setgeneral->fetch(PDO::FETCH_ASSOC);
```
That code takes the "general" table and brings a row/rows that has genera... |
74,328,400 | This belongs to the product landing page project on freecodecamp. I created the header with 'position: fixed', and also nested a navigation bar inside the header.
```
<!--HEADER-->
<header id="header">
<img id="header-img" src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-lo... | 2022/11/05 | [
"https://Stackoverflow.com/questions/74328400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19411886/"
] | ```
SELECT UPPER(PROD_NAME)as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE lower(PROD_NAME) like '%documentation%'
and LENGTH(PROD_NAME) <= 35
order by 2 DESC;
``` | If you want to get the original PROD\_NAME as it is in the table then don't use UPPER in the select clause...
```sql
SELECT PROD_NAME as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE LOWER(PROD_NAME) like '%documentation%'
-- UPPER(PROD_NAME) like '%DOCUMENTATION%' - instead of LOWER(), you ... |
74,328,400 | This belongs to the product landing page project on freecodecamp. I created the header with 'position: fixed', and also nested a navigation bar inside the header.
```
<!--HEADER-->
<header id="header">
<img id="header-img" src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-lo... | 2022/11/05 | [
"https://Stackoverflow.com/questions/74328400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19411886/"
] | If you want to get the original PROD\_NAME as it is in the table then don't use UPPER in the select clause...
```sql
SELECT PROD_NAME as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE LOWER(PROD_NAME) like '%documentation%'
-- UPPER(PROD_NAME) like '%DOCUMENTATION%' - instead of LOWER(), you ... | When I use PHP with MySQL, I personly use something like:
```
$setgeneral=$db->prepare("SELECT * FROM general where general_id=:general_id");
$setgeneral->execute(array('general_id' => 0));
$getgeneral=$setgeneral->fetch(PDO::FETCH_ASSOC);
```
That code takes the "general" table and brings a row/rows that has genera... |
57,013,503 | I am making a tic tac toe board game and I need the user to enter any position between 1 to 9 then type in X or O. Some conditions I need include is that I want to restrict the user to enter any number greater than 9 and do not enter any character either than 'X' or 'O'. The problem I encounter is that it doesn't follo... | 2019/07/12 | [
"https://Stackoverflow.com/questions/57013503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10970323/"
] | You can simplify with a little math. Given an index `i`, you can get the row/column with:
```
row = i % 3;
col = i / 3;
```
Note that `i` is `0-8` and not `1-9`.
You can use a helper function to convert an index to row/col:
```
void get_row_col(int index, int num_cols, int *row, int *col)
{
*row = index % num_... | ```
if((position > 9) && (xORo !='X') && (xORo !='O'))
{
continue;
}
```
This should be the second condition.
```
else if((position > 0)&&(position < 9)&&(xORo =='X') && (xORo=='O'))
```
This should be the final condition for attaining your desired motive.Also, no need to use do-whil... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
<http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-modul... | Assuming you don't want to install any SMTP client whatsoever, and just want to use windows and perhaps batch files, you could use Telnet to connect to port 25 of your smtp server and send the commands manually.
[Here is an example of how to do this](http://www.activexperts.com/activemail/telnet/).
Anyway, I persona... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | Assuming you don't want to install any SMTP client whatsoever, and just want to use windows and perhaps batch files, you could use Telnet to connect to port 25 of your smtp server and send the commands manually.
[Here is an example of how to do this](http://www.activexperts.com/activemail/telnet/).
Anyway, I persona... | This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "su... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
<http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-modul... | a very nice solution I found generically good if **no authentication** is involved and **no programs can/should be installed or can be assumed to exist** is the following, which should work on Ubuntu and other Linux platforms alike (you can put everything in one line using the `;` command delimiter and removing the `\`... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
<http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-modul... | HowToGeek demonstrates a Windows PowerShell script that works very well at [How To Send Email From the Command Line in Windows Without Extra Software](http://www.howtogeek.com/120011/stupid-geek-tricks-how-to-send-email-from-the-command-line-in-windows-without-extra-software/)
Here is the method:
First you're defining... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
<http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-modul... | **To send mail from command line in windows:-**
Save this in a text file and name that file something like **sendmail.ps1**
```
$EmailFrom = "from@gmail.com"
$EmailTo = "to@domain.com"
$Subject = "The subject of your email"
$Body = "What do you want your email to say"
$SMTPServer = "smtp.gmail.com"
$SMTPClient... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | I got this resolved without using any SMTP clients. I used Windows Powershell script to send mail and it is working very well.
Please check the below link
<http://blogs.msdn.com/b/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-modul... | This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "su... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | a very nice solution I found generically good if **no authentication** is involved and **no programs can/should be installed or can be assumed to exist** is the following, which should work on Ubuntu and other Linux platforms alike (you can put everything in one line using the `;` command delimiter and removing the `\`... | This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "su... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | HowToGeek demonstrates a Windows PowerShell script that works very well at [How To Send Email From the Command Line in Windows Without Extra Software](http://www.howtogeek.com/120011/stupid-geek-tricks-how-to-send-email-from-the-command-line-in-windows-without-extra-software/)
Here is the method:
First you're defining... | This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "su... |
5,153,983 | Can anyone help me out, we need to send mail through command line from Window server. We cannot use Blat as per security issue and neither do we want to install Exchange resource kit. We have our own Mail exchange server we can make use of it.
May be if any batch which could be run to access our SMTP mail server.
Tha... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5153983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188822/"
] | **To send mail from command line in windows:-**
Save this in a text file and name that file something like **sendmail.ps1**
```
$EmailFrom = "from@gmail.com"
$EmailTo = "to@domain.com"
$Subject = "The subject of your email"
$Body = "What do you want your email to say"
$SMTPServer = "smtp.gmail.com"
$SMTPClient... | This is an example to send mail from your Gmail address, for other servers you need to change the -smtp and -port
$securepass = ConvertTo-SecureString -String $yourpassword -A -F
$credential=new-object PSCredential $yourusername,$securepass
send-mailmessage -from "$yourusername@gmail.com" -to $recipient -subject "su... |
9,754,160 | I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?
String.split obviously relies on delimiters, which are then discarded, whic... | 2012/03/17 | [
"https://Stackoverflow.com/questions/9754160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276270/"
] | Brute force is likely to be your best option, both in terms of code and performance.
Alternatively, you could use a `Matcher`
```
Pattern p = Pattern.compile("[a-gA-G]#?");
Matcher m = p.march(inputString);
List<String> matches = new ArrayList<String>();
while(m.find())
matches.add(m.group());
``` | If you forsee changes in pattern you can use:
```
String s = "DADF#AD";
Pattern p = Pattern.compile("([a-gA-G]#?)");
Matcher matcher = p.matcher(s);
while (matcher.find()) {
System.out.println(matcher.group());
}
``` |
9,754,160 | I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?
String.split obviously relies on delimiters, which are then discarded, whic... | 2012/03/17 | [
"https://Stackoverflow.com/questions/9754160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276270/"
] | Brute force is likely to be your best option, both in terms of code and performance.
Alternatively, you could use a `Matcher`
```
Pattern p = Pattern.compile("[a-gA-G]#?");
Matcher m = p.march(inputString);
List<String> matches = new ArrayList<String>();
while(m.find())
matches.add(m.group());
``` | Using lookahead and lookbehind works: `String regex = "(?<=.)(?=\\w#?)";`
e.g.,
```
import java.util.Arrays;
public class Foo {
public static void main(String[] args) {
String[] tests = {"EADGBE", "DADF#AD"};
String regex = "(?<=.)(?=\\w#?)";
for (String test : tests) {
System.out.print... |
9,754,160 | I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?
String.split obviously relies on delimiters, which are then discarded, whic... | 2012/03/17 | [
"https://Stackoverflow.com/questions/9754160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276270/"
] | Brute force is likely to be your best option, both in terms of code and performance.
Alternatively, you could use a `Matcher`
```
Pattern p = Pattern.compile("[a-gA-G]#?");
Matcher m = p.march(inputString);
List<String> matches = new ArrayList<String>();
while(m.find())
matches.add(m.group());
``` | How about that: add delimiters, then split:
This methods adds delimiters
```
private static String delimit(String in) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < in.length()-1; i++) {
sb.append(in.charAt(i));
if (in.charAt(i+1) != '#')
sb.append(';');
}
return sb.toString();
}
... |
9,754,160 | I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?
String.split obviously relies on delimiters, which are then discarded, whic... | 2012/03/17 | [
"https://Stackoverflow.com/questions/9754160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276270/"
] | If you forsee changes in pattern you can use:
```
String s = "DADF#AD";
Pattern p = Pattern.compile("([a-gA-G]#?)");
Matcher matcher = p.matcher(s);
while (matcher.find()) {
System.out.println(matcher.group());
}
``` | How about that: add delimiters, then split:
This methods adds delimiters
```
private static String delimit(String in) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < in.length()-1; i++) {
sb.append(in.charAt(i));
if (in.charAt(i+1) != '#')
sb.append(';');
}
return sb.toString();
}
... |
9,754,160 | I want to split strings in the form of EADGBE or DADF#AD into separate strings, each containing either one letter or one letter plus a # sign. Is there any more elegant way than iterating through the string with a brute-force sort of approach?
String.split obviously relies on delimiters, which are then discarded, whic... | 2012/03/17 | [
"https://Stackoverflow.com/questions/9754160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276270/"
] | Using lookahead and lookbehind works: `String regex = "(?<=.)(?=\\w#?)";`
e.g.,
```
import java.util.Arrays;
public class Foo {
public static void main(String[] args) {
String[] tests = {"EADGBE", "DADF#AD"};
String regex = "(?<=.)(?=\\w#?)";
for (String test : tests) {
System.out.print... | How about that: add delimiters, then split:
This methods adds delimiters
```
private static String delimit(String in) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < in.length()-1; i++) {
sb.append(in.charAt(i));
if (in.charAt(i+1) != '#')
sb.append(';');
}
return sb.toString();
}
... |
532,415 | I am currently reading my text, for my electromagnetics course, and we are discussing guided waves. The text casually mentions the term "guided modes", and never really defines what that means. | 2020/11/15 | [
"https://electronics.stackexchange.com/questions/532415",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/252083/"
] | A *mode* is a configuration of the electromagnetic field that is stable as the system evolves in time according to Maxwell's equations. Mathematically, it's an eigenstate of the differential equations and boundary conditions describing the system.
A guided mode is a mode that is confined within a guiding structure of ... | I would typically use "guided mode" to refer to a mode moving down a waveguide. For example, the LP01 mode of an optical fiber would be a guided mode. The opposite of a guided mode would be a mode in free space.
There may be other uses depending on context however. |
74,391,030 | I'm decoding a base64 image with the following code:
```py
def string_to_image(base64_string):
decoded = base64.b64decode(base64_string)
np_data = np.frombuffer(decoded, np.uint8)
img = cv2.imdecode(np_data, cv2.IMREAD_UNCHANGED)
return img
```
The goal is to receive an image from the request body, d... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74391030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16524788/"
] | You could reshape the array by using `tf.squeeze` after reshaping the tensor. According to documentation, `tf.squeeze` will remove axis with dimensions 1.
```
image_resized = tf.reshape(decoded_image, (-1, 256, 256, 3, 1))
image_resized = tf.squeeze(image_resized)
``` | With *vijayachandran mariappan* comment and *AndreaYolo* answer I figured out a solution. First, change the channels of the image and then resize its dimensions:
```py
decoded_image = string_to_image(image_base64)
decoded_image = decoded_image[:,:,:3]
image_resized = tf.image.resize(decoded_image, (256, 256))
```
My... |
1,952,931 | Why this is non-deterministic and how to fix it?
```
<xs:element name="activeyears">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="from" minOccurs="1" maxOccurs="1"/>
... | 2009/12/23 | [
"https://Stackoverflow.com/questions/1952931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/213618/"
] | A schema is *non-deterministic* when there are two branches that begin with the same element - so that you cannot tell which branch to take without looking ahead after that element. A simple example is `ab|ac` - when you see an `a`, you don't know which branch to take. For loops, the "branch" is whether to repeat the l... | This is a simple edit of your code; I haven't tried it:
```
<xs:element name="activeyears">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element ref="from" minOccurs="1" maxOccurs="1"/>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
... |
5,833,115 | I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox. The code of listbox is as follows:
```
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPane... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5833115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265103/"
] | you can wrap the TextBlock with a Grid, and give it a Transparent color. Then you attach a NavigateToPageAction to the Grid, something like this,
```
xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=... | I'd recommend using a `Tap` gesture (from the [Silverlight Toolkit](http://silverlight.codeplex.com/releases/view/60291)) on the TextBlock. This will avoid issues with incorrectly detecting mousebutton up or down events when the user is scrolling the listbox. In my opinion this also provides a better user experience th... |
5,833,115 | I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox. The code of listbox is as follows:
```
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPane... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5833115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265103/"
] | you can wrap the TextBlock with a Grid, and give it a Transparent color. Then you attach a NavigateToPageAction to the Grid, something like this,
```
xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=... | Here is what I did using VS2010.
1. Select the TextBlock control in the xaml window.
2. In the properties window, select Events.
3. Locate `MouseLeftButtonUp`, and double-click in the empty value text box, that will lead you to the xaml.cs code behind window, and will create a new method.
4. Place `this.Close();` in t... |
5,833,115 | I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox. The code of listbox is as follows:
```
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPane... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5833115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265103/"
] | you can wrap the TextBlock with a Grid, and give it a Transparent color. Then you attach a NavigateToPageAction to the Grid, something like this,
```
xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=... | As workaround for a similar problem I faced in WP8 (Silverlight), I used a Button with transparent background and a Click event handler.
Now the problem with this is that, whenever the user touches/clicks on the button, a solid PhoneAccent color is set as the button's background (for the time period user holds it).
... |
5,833,115 | I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox. The code of listbox is as follows:
```
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPane... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5833115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265103/"
] | I'd recommend using a `Tap` gesture (from the [Silverlight Toolkit](http://silverlight.codeplex.com/releases/view/60291)) on the TextBlock. This will avoid issues with incorrectly detecting mousebutton up or down events when the user is scrolling the listbox. In my opinion this also provides a better user experience th... | As workaround for a similar problem I faced in WP8 (Silverlight), I used a Button with transparent background and a Click event handler.
Now the problem with this is that, whenever the user touches/clicks on the button, a solid PhoneAccent color is set as the button's background (for the time period user holds it).
... |
5,833,115 | I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox. The code of listbox is as follows:
```
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPane... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5833115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265103/"
] | Here is what I did using VS2010.
1. Select the TextBlock control in the xaml window.
2. In the properties window, select Events.
3. Locate `MouseLeftButtonUp`, and double-click in the empty value text box, that will lead you to the xaml.cs code behind window, and will create a new method.
4. Place `this.Close();` in t... | As workaround for a similar problem I faced in WP8 (Silverlight), I used a Button with transparent background and a Click event handler.
Now the problem with this is that, whenever the user touches/clicks on the button, a solid PhoneAccent color is set as the button's background (for the time period user holds it).
... |
32,860,232 | I have a table that keeps track of IP addresses with 3 fields -- ID, IP, TOTAL.
If I'm inserting a duplicate IP value, I'd like to just increment the TOTAL field by 1.
How should I do this? | 2015/09/30 | [
"https://Stackoverflow.com/questions/32860232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5125523/"
] | You can use a query like this if your IP is UNIQUE
```
INSERT INTO tablename (id, ip, total) VALUES (1, xxx.xxx.x.x, 1)
ON DUPLICATE KEY UPDATE total = total+1;
``` | You mean counting the total ? then add 1 if `IP` is already existing ?
```
DECLARE @Total INT = (SELECT COUNT(Total) From TableName)
IF EXIST (SELECT IP From TableName)
BEGIN
SET @Total = @Total + 1
END
INSERT INTO...
``` |
32,860,232 | I have a table that keeps track of IP addresses with 3 fields -- ID, IP, TOTAL.
If I'm inserting a duplicate IP value, I'd like to just increment the TOTAL field by 1.
How should I do this? | 2015/09/30 | [
"https://Stackoverflow.com/questions/32860232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5125523/"
] | You can use a query like this if your IP is UNIQUE
```
INSERT INTO tablename (id, ip, total) VALUES (1, xxx.xxx.x.x, 1)
ON DUPLICATE KEY UPDATE total = total+1;
``` | **sp\_visitors.sql**
```
delimiter $$
create procedure sp_visitors (IN in_ip varchar(50))
begin
declare var_total int;
set var_total = (select total from ip_table where ip = in_ip);
if (var_total is null) then
insert into ip_table (ip, total) values (in_ip, 1);
else
update ip_table set ... |
296,803 | I've been switching hosts using a VPS each time and I'm just really not sure I'm finding the right VPS's. I've used a VPS from burst.net & rubyringtech and I just feel like it's slowly killing my site because of the slow speed. I really don't know if it's the network or the VPS itself but I really wish to fix this. Whe... | 2011/05/24 | [
"https://serverfault.com/questions/296803",
"https://serverfault.com",
"https://serverfault.com/users/82120/"
] | I use Linode with Gentoo 32-bit. I also use vBulletin, with the supporting software for it being Apache, PHP, and MySQL.
It's been a long road of tweaking both Apache and MySQL; we're using the 768 MB Linode, and I've finished tweaking Apache for memory/CPU usage. Currently I'm still tweaking MySQL to allow for enoug... | I have had success with [Rackspace Cloud servers](http://www.rackspace.com/cloud/cloud_hosting_products/servers/) (similar to a VPS). You maintain full root access and have the ability to scale up the server if needed. Performance has been quite good and if you need to put the database on its own server you have that o... |
296,803 | I've been switching hosts using a VPS each time and I'm just really not sure I'm finding the right VPS's. I've used a VPS from burst.net & rubyringtech and I just feel like it's slowly killing my site because of the slow speed. I really don't know if it's the network or the VPS itself but I really wish to fix this. Whe... | 2011/05/24 | [
"https://serverfault.com/questions/296803",
"https://serverfault.com",
"https://serverfault.com/users/82120/"
] | I use Linode with Gentoo 32-bit. I also use vBulletin, with the supporting software for it being Apache, PHP, and MySQL.
It's been a long road of tweaking both Apache and MySQL; we're using the 768 MB Linode, and I've finished tweaking Apache for memory/CPU usage. Currently I'm still tweaking MySQL to allow for enoug... | I'm using Linode for my website and it's had a good track record for me. I personally love using Arch Linux x86-64. There are also a good amount of public "stack scripts" now which will set everything up for you, such as LAMP and similar. They also are one-up on most of the competition because they give you 512M of RAM... |
61,700,961 | I have a git repository, call it `Repo1`:
```
Repo1
Folder1
Other stuff...
```
and I have two folders that contain a subset of the files in `Repo1`. A `Baseline` folder:
```
Baseline
Folder1
```
...and a `ChangeSet` folder:
```
ChangeSet
Folder1
```
`Baseline` contains the files from `Repo1` th... | 2020/05/09 | [
"https://Stackoverflow.com/questions/61700961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2226357/"
] | **Edit:** You're on the right track in your own answer: cherry-pick is almost certainly the way to go, for your actual case. The trick is to put their original tree in as an "orphan branch" (independent commit) and then to put their patch in as the second commit on this branch, then to go back to your own branch and us... | I haven't written the entire script yet, but here's what I think will work.
First, do what I said here:
>
> I've looked into creating a temporary repository containing two commits, the first for the baseline, and the second for the changeset.
>
>
>
So I'll create a temporary repository containing my commit to ba... |
64,853,673 | I need to get current location information. For now I am using [getLastKnownLocation](https://developer.android.com/reference/android/location/LocationManager#getLastKnownLocation(java.lang.String)) but sometimes it might return null or obsolete information. I'm trying to use [requestSingleUpdate](https://developer.and... | 2020/11/16 | [
"https://Stackoverflow.com/questions/64853673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11199199/"
] | I've solved. Here is the code.
```
locationManager.getCurrentLocation(
LocationManager.GPS_PROVIDER,
null,
application.getMainExecutor(),
new Consumer<Location>() {
@Override
public void accept(Location location) {
// code
}
});
``` | N.B. Below is **deprecated in API 30** (it still works at present) - but may be useful for older target devices
In a class that implements LocationListener, e.g. an Activity:
```
val locationMgr = getSystemService(Context.LOCATION_SERVICE) as LocationManager
...
locationMgr.requestSingleUpdate(LocationManager.GPS_PRO... |
778 | Mandelbrot set is defined using the complex equation $P\_c (z)=z^2 +c$ where $c$ is a complex number
Let Set $M=${$(c,k,m) |$ the sequence $P\_c (0),P\_c (P\_c (0)), P\_c (P\_c (P\_c (0)))...$ is unbounded and some number $P^n\_c (0)$ has a complex magnitude greater than 2 (but less than $m$) for some integer $n$ > $k... | 2010/08/30 | [
"https://cstheory.stackexchange.com/questions/778",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/495/"
] | Let's look at $M$ for fixed $k$ first.
Given a fixed $k$ in unary, the problem essentially reduces to figuring out the algebraic set $|P\_c^{(k)}(0)| = 2$. Since the level sets 'at infinity' are properly nested, the question becomes a membership test in an algebraic set. The issue is that the minimal polynomial is of ... | This problem related to Mandelbrot set seems to be $NP$-complete:
$M=${$(c,k,r) |$ In the sequence $P\_c (0),P\_c (P\_c (0)), P\_c (P\_c (P\_c (0)))...$ of first $k$ complex numbers, there is a subset $T$ of complex numbers such that the sum of the real parts $\gt$ $r.k$ and the sum of imaginary parts $\gt$ $r.k$}
$r... |
778 | Mandelbrot set is defined using the complex equation $P\_c (z)=z^2 +c$ where $c$ is a complex number
Let Set $M=${$(c,k,m) |$ the sequence $P\_c (0),P\_c (P\_c (0)), P\_c (P\_c (P\_c (0)))...$ is unbounded and some number $P^n\_c (0)$ has a complex magnitude greater than 2 (but less than $m$) for some integer $n$ > $k... | 2010/08/30 | [
"https://cstheory.stackexchange.com/questions/778",
"https://cstheory.stackexchange.com",
"https://cstheory.stackexchange.com/users/495/"
] | This answer combines some of my comments to the question and improves them.
The set M is decidable in linear time on a Turing machine over the reals.
Here is why. The definition of the set M in the question consists of two conditions, but note that the first condition is redundant: it is well-known that the infinite ... | This problem related to Mandelbrot set seems to be $NP$-complete:
$M=${$(c,k,r) |$ In the sequence $P\_c (0),P\_c (P\_c (0)), P\_c (P\_c (P\_c (0)))...$ of first $k$ complex numbers, there is a subset $T$ of complex numbers such that the sum of the real parts $\gt$ $r.k$ and the sum of imaginary parts $\gt$ $r.k$}
$r... |
24,515,258 | So I have a jquery event that is inside of `$(document).ready(function() { //.....// });`. It has the following code:
```
$('.puzzle_cells').keyup(function(event) {
});
```
The next thing I need to do is get the ID of the `<input>` element with a class `'puzzle_cells'` (BTW every `<input>` with a class of `'puzzle_... | 2014/07/01 | [
"https://Stackoverflow.com/questions/24515258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534323/"
] | You can get it like this, can't you?
```
$('.puzzle_cells').keyup(function(event) {
var id = this.id; // or $(this).attr('id')
});
``` | ```
$('.puzzle_cells').keyup(function(event){
this.cellID = event.srcElement.id;
});
```
Not very familiar with JQuery, but this should work. |
24,515,258 | So I have a jquery event that is inside of `$(document).ready(function() { //.....// });`. It has the following code:
```
$('.puzzle_cells').keyup(function(event) {
});
```
The next thing I need to do is get the ID of the `<input>` element with a class `'puzzle_cells'` (BTW every `<input>` with a class of `'puzzle_... | 2014/07/01 | [
"https://Stackoverflow.com/questions/24515258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534323/"
] | You can get it like this, can't you?
```
$('.puzzle_cells').keyup(function(event) {
var id = this.id; // or $(this).attr('id')
});
``` | Not sure why you need it "in a jquery way". It can work just as you say with `this.id`.
But if really needed:
```
$('.puzzle_cells').keyup(function (event) {
console.log($(this).attr('id'));
});
``` |
24,515,258 | So I have a jquery event that is inside of `$(document).ready(function() { //.....// });`. It has the following code:
```
$('.puzzle_cells').keyup(function(event) {
});
```
The next thing I need to do is get the ID of the `<input>` element with a class `'puzzle_cells'` (BTW every `<input>` with a class of `'puzzle_... | 2014/07/01 | [
"https://Stackoverflow.com/questions/24515258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534323/"
] | You can get it like this, can't you?
```
$('.puzzle_cells').keyup(function(event) {
var id = this.id; // or $(this).attr('id')
});
``` | Just use `$(this).attr("id")` like any other element
```
$('.puzzle_cells').keyup(function(event) {
console.log($(this).attr("id"));
});
```
[JSfiddle](http://jsfiddle.net/CA5EY/) |
24,515,258 | So I have a jquery event that is inside of `$(document).ready(function() { //.....// });`. It has the following code:
```
$('.puzzle_cells').keyup(function(event) {
});
```
The next thing I need to do is get the ID of the `<input>` element with a class `'puzzle_cells'` (BTW every `<input>` with a class of `'puzzle_... | 2014/07/01 | [
"https://Stackoverflow.com/questions/24515258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534323/"
] | ```
$('.puzzle_cells').keyup(function(event){
this.cellID = event.srcElement.id;
});
```
Not very familiar with JQuery, but this should work. | Just use `$(this).attr("id")` like any other element
```
$('.puzzle_cells').keyup(function(event) {
console.log($(this).attr("id"));
});
```
[JSfiddle](http://jsfiddle.net/CA5EY/) |
24,515,258 | So I have a jquery event that is inside of `$(document).ready(function() { //.....// });`. It has the following code:
```
$('.puzzle_cells').keyup(function(event) {
});
```
The next thing I need to do is get the ID of the `<input>` element with a class `'puzzle_cells'` (BTW every `<input>` with a class of `'puzzle_... | 2014/07/01 | [
"https://Stackoverflow.com/questions/24515258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534323/"
] | Not sure why you need it "in a jquery way". It can work just as you say with `this.id`.
But if really needed:
```
$('.puzzle_cells').keyup(function (event) {
console.log($(this).attr('id'));
});
``` | Just use `$(this).attr("id")` like any other element
```
$('.puzzle_cells').keyup(function(event) {
console.log($(this).attr("id"));
});
```
[JSfiddle](http://jsfiddle.net/CA5EY/) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.