qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
39,490 | I have a PC where the desktop background options are disabled. I have tried resetting the ActiveDesktop - AllowChangingWallpaper (something like that) to no avail. There is no security enabled on the machine, it is running BitDefender after a recent trojan attack. That is all I know at the moment, but nowhere can I fin... | 2009/09/11 | [
"https://superuser.com/questions/39490",
"https://superuser.com",
"https://superuser.com/users/10670/"
] | Although the recommended method is to install XP and then Windows 7, there is no need to reinstall in your case.
Follow this [guide](http://www.ehow.com/how_4900122_use-easybcd-windows-xp.html) (edited below) using a free tool called [EasyBCD](http://neosmart.net/dl.php?id=1).
>
> 1. Download and install [**EasyBCD*... | Also is installing xp completely needed why do you need xp for?
First check if all of the programs if you could use all of those in either vista or win7.
(for me I use a website called FileHippo is has an update checker to check all of you're programs for an update)
Than if there is a reason you have to use win7 tha... |
39,490 | I have a PC where the desktop background options are disabled. I have tried resetting the ActiveDesktop - AllowChangingWallpaper (something like that) to no avail. There is no security enabled on the machine, it is running BitDefender after a recent trojan attack. That is all I know at the moment, but nowhere can I fin... | 2009/09/11 | [
"https://superuser.com/questions/39490",
"https://superuser.com",
"https://superuser.com/users/10670/"
] | Why don't you install and run XP from a VHD file?
[Windows 7 is able to natively boot VHD files](http://edge.technet.com/Media/Windows-7-Boot-from-VHD/), so this might be the easiest way to get XP installed.
If you still want to install XP and Win7 side by side, I'd install XP first, then Windows 7. Why? Because XPs i... | Also is installing xp completely needed why do you need xp for?
First check if all of the programs if you could use all of those in either vista or win7.
(for me I use a website called FileHippo is has an update checker to check all of you're programs for an update)
Than if there is a reason you have to use win7 tha... |
326,595 | I have a university email account which provides access only via IMAP and webmail, and which does not provide a usable email forwarding service. Is there any way of getting emails from this account automatically downloaded to my gmail? The only thing I could think of would be to set up my own POP server to shadow the I... | 2011/08/22 | [
"https://superuser.com/questions/326595",
"https://superuser.com",
"https://superuser.com/users/95192/"
] | It will take awhile depending on how many messages you have and how big, but you can set your gmail account to allow an imap connection and connect to both with an application like Thunderbird and simply drag your mail from one to the other. Once you have the two set up, you can setup a filter rule that will move new m... | imapsync worked fine for me ...
```
imapsync \
--host1 "${from_host}" --user1 "${from_login}" --password1 "${from_passwd}" \
--ssl1 \
--host2 "${to_host}" --user2 "${to_login}" --password2 "${to_passwd}" \
--ssl2 \
--authuser1 "${from_login}" --authmech1 LOGIN \
--authmech2 LOGIN \
--syncin... |
59,004,671 | I am using Visual Studio Code as my IDE and I am a bit of a beginner with Python so I decided to try out the turtle library built into Python to learn some of the syntax. However, when I tried running just a simple script to see if it would work, the window flashed open for less than a second then closed. I have tried ... | 2019/11/23 | [
"https://Stackoverflow.com/questions/59004671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12055356/"
] | The screen flashed on and then closed because when the application is done, Python exits and thus so does the screen. This has nothing to do with VS Code or the Python extension and simply how applications work.
Probably the easiest way to keep the window open is add the following line at the very end:
```py
input("P... | You can create a canvas into **turtle** like a blank space to draw on. Use this code just to import the module an hold on the graphic window open -Pen It will work with Visual Studio Code, Spyder or Python IDLE
```
import turtle
window = turtle.Screen()
geoff = turtle.Turtle()
t = turtle.Pen()
window.exitonclick()
``... |
59,004,671 | I am using Visual Studio Code as my IDE and I am a bit of a beginner with Python so I decided to try out the turtle library built into Python to learn some of the syntax. However, when I tried running just a simple script to see if it would work, the window flashed open for less than a second then closed. I have tried ... | 2019/11/23 | [
"https://Stackoverflow.com/questions/59004671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12055356/"
] | The screen flashed on and then closed because when the application is done, Python exits and thus so does the screen. This has nothing to do with VS Code or the Python extension and simply how applications work.
Probably the easiest way to keep the window open is add the following line at the very end:
```py
input("P... | **The easiest solution is to add the following line in your V.S. Code:-**
```
turtle.done()
```
**This would prevent the window (Python Turtle Graphics) from closing after running the code:)** |
59,004,671 | I am using Visual Studio Code as my IDE and I am a bit of a beginner with Python so I decided to try out the turtle library built into Python to learn some of the syntax. However, when I tried running just a simple script to see if it would work, the window flashed open for less than a second then closed. I have tried ... | 2019/11/23 | [
"https://Stackoverflow.com/questions/59004671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12055356/"
] | You can use exitonclick() to avoid the window from shutting down.
```
import turtle
window = turtle.Screen()
geoff = turtle.Turtle()
geoff.forward(100)
window.exitonclick()
```
This way, the graphics window will shut only after you click. | You can create a canvas into **turtle** like a blank space to draw on. Use this code just to import the module an hold on the graphic window open -Pen It will work with Visual Studio Code, Spyder or Python IDLE
```
import turtle
window = turtle.Screen()
geoff = turtle.Turtle()
t = turtle.Pen()
window.exitonclick()
``... |
59,004,671 | I am using Visual Studio Code as my IDE and I am a bit of a beginner with Python so I decided to try out the turtle library built into Python to learn some of the syntax. However, when I tried running just a simple script to see if it would work, the window flashed open for less than a second then closed. I have tried ... | 2019/11/23 | [
"https://Stackoverflow.com/questions/59004671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12055356/"
] | You can use exitonclick() to avoid the window from shutting down.
```
import turtle
window = turtle.Screen()
geoff = turtle.Turtle()
geoff.forward(100)
window.exitonclick()
```
This way, the graphics window will shut only after you click. | **The easiest solution is to add the following line in your V.S. Code:-**
```
turtle.done()
```
**This would prevent the window (Python Turtle Graphics) from closing after running the code:)** |
59,004,671 | I am using Visual Studio Code as my IDE and I am a bit of a beginner with Python so I decided to try out the turtle library built into Python to learn some of the syntax. However, when I tried running just a simple script to see if it would work, the window flashed open for less than a second then closed. I have tried ... | 2019/11/23 | [
"https://Stackoverflow.com/questions/59004671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12055356/"
] | **The easiest solution is to add the following line in your V.S. Code:-**
```
turtle.done()
```
**This would prevent the window (Python Turtle Graphics) from closing after running the code:)** | You can create a canvas into **turtle** like a blank space to draw on. Use this code just to import the module an hold on the graphic window open -Pen It will work with Visual Studio Code, Spyder or Python IDLE
```
import turtle
window = turtle.Screen()
geoff = turtle.Turtle()
t = turtle.Pen()
window.exitonclick()
``... |
38,766 | I noticed that《汉语大词典》opts for 風景綫 over what most other reference works write as 風景線.
**KEY** does mention that 綫 is a:
>
> 1 (variant of the more commonly used xìan 線) line, thread, wire, string
>
>
>
[zisea](http://zisea.com/zscontent.asp?uni=7EBF) also seems so say that 线 is:
>
> 【綫】的简体字。拼音xian4
>
>
>
[z... | 2020/04/19 | [
"https://chinese.stackexchange.com/questions/38766",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/4136/"
] | My understanding is that when characters were being simplified in Mainland China, they first had to standardize traditional characters (i.e. What should these new characters be simplified from?). 「綫」 was chosen as the traditional standard, thus in the PRC's [Table of General Standard Chinese Characters (通用規範漢字表)](https... | There probably isn’t a preferred choice between 線 and 綫.
In Hong Kong, traditional characters are used. The MTR Corporation officially refers to their MTR lines as XX綫. However, if you take some feeder minibuses, they will often refer to those lines as XX線. This means both characters can be accepted as “official”, si... |
38,766 | I noticed that《汉语大词典》opts for 風景綫 over what most other reference works write as 風景線.
**KEY** does mention that 綫 is a:
>
> 1 (variant of the more commonly used xìan 線) line, thread, wire, string
>
>
>
[zisea](http://zisea.com/zscontent.asp?uni=7EBF) also seems so say that 线 is:
>
> 【綫】的简体字。拼音xian4
>
>
>
[z... | 2020/04/19 | [
"https://chinese.stackexchange.com/questions/38766",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/4136/"
] | There probably isn’t a preferred choice between 線 and 綫.
In Hong Kong, traditional characters are used. The MTR Corporation officially refers to their MTR lines as XX綫. However, if you take some feeder minibuses, they will often refer to those lines as XX線. This means both characters can be accepted as “official”, si... | (Not enough reputation to comment, so I am posting this as an answer instead)
In addition to MTR's example,
TVB uses "綫": `無綫電視`/`無綫新聞台`
But another company, i-CABLE TV, uses "線": `有線新聞`.
And "wireless" in "wireless network" is usually written as "無線".
From my observation, nowadays people usually write "線", an... |
38,766 | I noticed that《汉语大词典》opts for 風景綫 over what most other reference works write as 風景線.
**KEY** does mention that 綫 is a:
>
> 1 (variant of the more commonly used xìan 線) line, thread, wire, string
>
>
>
[zisea](http://zisea.com/zscontent.asp?uni=7EBF) also seems so say that 线 is:
>
> 【綫】的简体字。拼音xian4
>
>
>
[z... | 2020/04/19 | [
"https://chinese.stackexchange.com/questions/38766",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/4136/"
] | My understanding is that when characters were being simplified in Mainland China, they first had to standardize traditional characters (i.e. What should these new characters be simplified from?). 「綫」 was chosen as the traditional standard, thus in the PRC's [Table of General Standard Chinese Characters (通用規範漢字表)](https... | (Not enough reputation to comment, so I am posting this as an answer instead)
In addition to MTR's example,
TVB uses "綫": `無綫電視`/`無綫新聞台`
But another company, i-CABLE TV, uses "線": `有線新聞`.
And "wireless" in "wireless network" is usually written as "無線".
From my observation, nowadays people usually write "線", an... |
18,100,516 | I have an array something like below.We need to create three array from this array.We need to seperate all for facebook inside another array and something like other twitter,email.
Is this possible?
```
Array
(
[01] => Array
(
[facebook] => 375
[twitter] => 3276
[email]... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18100516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2533926/"
] | ```
$your_array = //here you have your original array
$facebook = array();
$twitter = array();
$email = array();
foreach($your_array as $sub_array) {
$facebook[] = $sub_array["facebook"];
$twitter[] = $sub_array["twitter"];
$email[] = $sub_array["email"];
}
``` | You can create three arrays easily :-)
let say main array name is $mainarray
```
$facebookarr = array();
$twitterarr = array();
$emailarr = array();
foreach($mainarray as $socialarray)
{
$facebookarr[] = $socialarray['facebook'];
$twitterarr[] = $socialarray['twitter']
$e... |
18,100,516 | I have an array something like below.We need to create three array from this array.We need to seperate all for facebook inside another array and something like other twitter,email.
Is this possible?
```
Array
(
[01] => Array
(
[facebook] => 375
[twitter] => 3276
[email]... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18100516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2533926/"
] | ```
$your_array = //here you have your original array
$facebook = array();
$twitter = array();
$email = array();
foreach($your_array as $sub_array) {
$facebook[] = $sub_array["facebook"];
$twitter[] = $sub_array["twitter"];
$email[] = $sub_array["email"];
}
``` | Try [array\_column](http://www.php.net/manual/en/function.array-column.php)
```
$fb=array_column($array, 'facebook');
```
OR
```
$fb=array_map( function ($i) { return $i['facebook'];},$array);
``` |
18,100,516 | I have an array something like below.We need to create three array from this array.We need to seperate all for facebook inside another array and something like other twitter,email.
Is this possible?
```
Array
(
[01] => Array
(
[facebook] => 375
[twitter] => 3276
[email]... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18100516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2533926/"
] | Try [array\_column](http://www.php.net/manual/en/function.array-column.php)
```
$fb=array_column($array, 'facebook');
```
OR
```
$fb=array_map( function ($i) { return $i['facebook'];},$array);
``` | You can create three arrays easily :-)
let say main array name is $mainarray
```
$facebookarr = array();
$twitterarr = array();
$emailarr = array();
foreach($mainarray as $socialarray)
{
$facebookarr[] = $socialarray['facebook'];
$twitterarr[] = $socialarray['twitter']
$e... |
1,856,457 | I am trying to accomplish the following:
```
SELECT col1, col2 FROM table1
UNION
SELECT col2, col3 FROM table2
```
With the result:
```
col1, col2, col3
1 , 1 , NULL
NULL, 1 , 1
```
The union of the columns *and* the rows is returned. You could think of it as the UNION equivalent of a FULL OUTER JOIN.
The ... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1856457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/125292/"
] | My interpretation of your question is that you want to be able to support an ad-hoc query, given the talk about dynamic SQL & column names & data types...
This query will give you a list of columns & their data types for a specific table:
```
SELECT @columnName = c.name AS columnName,
@columnDataType = ty.name... | After a quick try, the closest I can get in T-SQL without jumping through loads of flaming hoops of hackiness is using a FULL OUTER JOIN with a false condition...
e.g.
```
DECLARE @TableA TABLE (Col1 INTEGER IDENTITY(1,1), Col2 INTEGER)
DECLARE @TableB TABLE (Col2 INTEGER IDENTITY(1,1), Col3 INTEGER)
INSERT @TableA V... |
1,856,457 | I am trying to accomplish the following:
```
SELECT col1, col2 FROM table1
UNION
SELECT col2, col3 FROM table2
```
With the result:
```
col1, col2, col3
1 , 1 , NULL
NULL, 1 , 1
```
The union of the columns *and* the rows is returned. You could think of it as the UNION equivalent of a FULL OUTER JOIN.
The ... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1856457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/125292/"
] | I threw in the towel on this one and wrote a bunch of nasty dynamic T-SQL and executed it with sp\_executesql. Thanks for the help! | After a quick try, the closest I can get in T-SQL without jumping through loads of flaming hoops of hackiness is using a FULL OUTER JOIN with a false condition...
e.g.
```
DECLARE @TableA TABLE (Col1 INTEGER IDENTITY(1,1), Col2 INTEGER)
DECLARE @TableB TABLE (Col2 INTEGER IDENTITY(1,1), Col3 INTEGER)
INSERT @TableA V... |
1,856,457 | I am trying to accomplish the following:
```
SELECT col1, col2 FROM table1
UNION
SELECT col2, col3 FROM table2
```
With the result:
```
col1, col2, col3
1 , 1 , NULL
NULL, 1 , 1
```
The union of the columns *and* the rows is returned. You could think of it as the UNION equivalent of a FULL OUTER JOIN.
The ... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1856457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/125292/"
] | My interpretation of your question is that you want to be able to support an ad-hoc query, given the talk about dynamic SQL & column names & data types...
This query will give you a list of columns & their data types for a specific table:
```
SELECT @columnName = c.name AS columnName,
@columnDataType = ty.name... | Will this help(joining upon some dummy column) in giving some insight?
```
declare @t1 table(col1 varchar(10),col2 varchar(10))
declare @t2 table(col2 varchar(10),col3 varchar(10))
insert into @t1 select '1','1' union all select '10','1'
insert into @t2 select '1',null union all select '10','1'
;with cte1 as(select R... |
1,856,457 | I am trying to accomplish the following:
```
SELECT col1, col2 FROM table1
UNION
SELECT col2, col3 FROM table2
```
With the result:
```
col1, col2, col3
1 , 1 , NULL
NULL, 1 , 1
```
The union of the columns *and* the rows is returned. You could think of it as the UNION equivalent of a FULL OUTER JOIN.
The ... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1856457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/125292/"
] | I threw in the towel on this one and wrote a bunch of nasty dynamic T-SQL and executed it with sp\_executesql. Thanks for the help! | Will this help(joining upon some dummy column) in giving some insight?
```
declare @t1 table(col1 varchar(10),col2 varchar(10))
declare @t2 table(col2 varchar(10),col3 varchar(10))
insert into @t1 select '1','1' union all select '10','1'
insert into @t2 select '1',null union all select '10','1'
;with cte1 as(select R... |
30,608,282 | I have a list of over million tuples and want a list of 100,000 tuples randomly sampled from that original list without replacement. I have read:
[How do I pick 2 random items from a Python set?](https://stackoverflow.com/questions/1262955/how-do-i-pick-2-random-items-from-a-python-set)
but the solution provided (usi... | 2015/06/02 | [
"https://Stackoverflow.com/questions/30608282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4757234/"
] | You can sample your list regardless of if the elements are hashable or not:
```python
data = create_dataset() # List of data to be sampled
n_samples = 100000
samples = random.sample(data,n_samples)
``` | Not sure if I fully understand your question, but `random.sample` can accept both lists and tuples:
```
random.sample([1,2,3,4,5],2)
Out[620]: [2, 5]
random.sample((1,2,3,4,5),2)
Out[621]: [4, 1]
``` |
27,907,491 | I've been tasked with cleaning up someone else's code and i'm new to web development stuff and this seems to be a little over my head. I wanted to make the table so that the background of the row and text color change and have looked at examples but could not figure out how to integrate them into this code.
```
... | 2015/01/12 | [
"https://Stackoverflow.com/questions/27907491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4446294/"
] | Try this with your css:
```
table tr {
background-color: lightblue;
}
table tr:hover {
background-color: blue;
}
```
---
Check here:
<http://jsfiddle.net/dboxs77z/>
--- | Use Css
>
> Put following code in Head section
>
>
>
```
<style type="text/css">
table tr {background-color:Red;}
table tr:hover {background-color:Blue;}
</style>
``` |
27,907,491 | I've been tasked with cleaning up someone else's code and i'm new to web development stuff and this seems to be a little over my head. I wanted to make the table so that the background of the row and text color change and have looked at examples but could not figure out how to integrate them into this code.
```
... | 2015/01/12 | [
"https://Stackoverflow.com/questions/27907491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4446294/"
] | Try this with your css:
```
table tr {
background-color: lightblue;
}
table tr:hover {
background-color: blue;
}
```
---
Check here:
<http://jsfiddle.net/dboxs77z/>
--- | CSS Is Used for that Purpose
>
> Put following code in Head section
>
>
>
```
<style type="text/css">
table tr {background-color:Blue;}
table tr:hover {background-color:Red;}
</style>
```
Replace Blue & Red With your desired colors |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | You can add `line-height:51px` to `#AlertDiv h1` if you know it's only ever going to be one line. Also add `text-align:center` to `#AlertDiv`.
```
#AlertDiv {
top:198px;
left:365px;
width:62px;
height:51px;
color:white;
position:absolute;
text-align:center;
background-color:black;
}
#A... | ```
<div id="AlertDiv" style="width:600px;height:400px;border:SOLID 1px;">
<h1 style="width:100%;height:10%;text-align:center;position:relative;top:40%;">Yes</h1>
</div>
```
You can try the code here:
<http://htmledit.squarefree.com/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | You can add `line-height:51px` to `#AlertDiv h1` if you know it's only ever going to be one line. Also add `text-align:center` to `#AlertDiv`.
```
#AlertDiv {
top:198px;
left:365px;
width:62px;
height:51px;
color:white;
position:absolute;
text-align:center;
background-color:black;
}
#A... | You can use `display: table-cell` in order to render the div as a table cell and then use `vertical-align` like you would do in a normal table cell.
```
#AlertDiv {
display: table-cell;
vertical-align: middle;
text-align: center;
}
```
You can try it here:
<http://jsfiddle.net/KaXY5/424/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | There is a new way using transforms. Apply this to the element to centre. It nudges down by half the container height and then 'corrects' by half the element height.
```
position: relative;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
```
It works most ... | ```
<div id="AlertDiv" style="width:600px;height:400px;border:SOLID 1px;">
<h1 style="width:100%;height:10%;text-align:center;position:relative;top:40%;">Yes</h1>
</div>
```
You can try the code here:
<http://htmledit.squarefree.com/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | On the hX tag
```
width: 100px;
margin-left: auto;
margin-right: auto;
``` | You could add padding to the `h1`:
```
#AlertDiv h1 {
padding:15px 18px;
}
``` |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | Started a **jsFiddle** [here](http://jsfiddle.net/Jby3m/3/).
It seems the *horizontal alignment* works with a `text-align : center`. Still trying to get the vertical align to work; might have to use `absolute` positioning and something like `top: 50%` or a pre-calculated `padding` from the top. | You can use `display: table-cell` in order to render the div as a table cell and then use `vertical-align` like you would do in a normal table cell.
```
#AlertDiv {
display: table-cell;
vertical-align: middle;
text-align: center;
}
```
You can try it here:
<http://jsfiddle.net/KaXY5/424/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | There is a new way using transforms. Apply this to the element to centre. It nudges down by half the container height and then 'corrects' by half the element height.
```
position: relative;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
```
It works most ... | Started a **jsFiddle** [here](http://jsfiddle.net/Jby3m/3/).
It seems the *horizontal alignment* works with a `text-align : center`. Still trying to get the vertical align to work; might have to use `absolute` positioning and something like `top: 50%` or a pre-calculated `padding` from the top. |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | On the hX tag
```
width: 100px;
margin-left: auto;
margin-right: auto;
``` | Started a **jsFiddle** [here](http://jsfiddle.net/Jby3m/3/).
It seems the *horizontal alignment* works with a `text-align : center`. Still trying to get the vertical align to work; might have to use `absolute` positioning and something like `top: 50%` or a pre-calculated `padding` from the top. |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | There is a new way using transforms. Apply this to the element to centre. It nudges down by half the container height and then 'corrects' by half the element height.
```
position: relative;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
```
It works most ... | You can use `display: table-cell` in order to render the div as a table cell and then use `vertical-align` like you would do in a normal table cell.
```
#AlertDiv {
display: table-cell;
vertical-align: middle;
text-align: center;
}
```
You can try it here:
<http://jsfiddle.net/KaXY5/424/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | On the hX tag
```
width: 100px;
margin-left: auto;
margin-right: auto;
``` | You can use `display: table-cell` in order to render the div as a table cell and then use `vertical-align` like you would do in a normal table cell.
```
#AlertDiv {
display: table-cell;
vertical-align: middle;
text-align: center;
}
```
You can try it here:
<http://jsfiddle.net/KaXY5/424/> |
6,254,793 | I have the following `<div>` inside a `<body>` tag:
```
<div id="AlertDiv"><h1>Yes</h1></div>
```
And these are their CSS classes:
```
#AlertDiv {
position:absolute;
height: 51px;
left: 365px;
top: 198px;
width: 62px;
background-color:black;
color:white;
}
#AlertDiv h1{
margin:auto;... | 2011/06/06 | [
"https://Stackoverflow.com/questions/6254793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68571/"
] | You can add `line-height:51px` to `#AlertDiv h1` if you know it's only ever going to be one line. Also add `text-align:center` to `#AlertDiv`.
```
#AlertDiv {
top:198px;
left:365px;
width:62px;
height:51px;
color:white;
position:absolute;
text-align:center;
background-color:black;
}
#A... | There is a new way using transforms. Apply this to the element to centre. It nudges down by half the container height and then 'corrects' by half the element height.
```
position: relative;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
```
It works most ... |
65,268,300 | I've tried multiple solutions and read some other answers talking about the visibility of the class, but I've no added any private or protected modifier.
The point is, that I'm just have a very simple ViewBinding configuration, but it's showing the following message when I try to run it.
>
> e: /app/src/main/java/co... | 2020/12/12 | [
"https://Stackoverflow.com/questions/65268300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1820599/"
] | You're not supposed to use the constructors of data binding classes (they're private, as your error message says). Use the method `ActivityMainBinding.inflate()` to create your binding object
```
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
```
This is shown in the [official doc... | I would recommend using `dataBinding` which includs `viewBinding` and other powerful features you may need in the future.
**1. Enable `dataBinding` in Build Gradle File:**
```
apply plugin: 'kotlin-kapt'
android {
...
buildFeatures {
dataBinding true
}
...
}
```
**2. Wrap the Whole Layou... |
37,492,145 | Usually i do:
```
onclick="myFunction()"
```
on my submit button, but what i want to do now on html is
```
<form id="myForm">
<input type="text" id="myTextBox" required> <!-- we're gonna use this id: myTextBox because we're using the getElementById() -->
<input type="submit" value="Click Me"> <!-- we call the func... | 2016/05/27 | [
"https://Stackoverflow.com/questions/37492145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366860/"
] | Use the `outer` function:
```
nameMatrix <- outer(LETTERS[1:8], 1:12, paste, sep = "")
nameMatrix
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10" "A11" "A12"
[2,] "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" "B12"
[3,] "C1" "C2" "C... | Something like this?
```
df <- expand.grid(LETTERS[1:8], 1:12)
v <- paste0(df[[1]], df[[2]])
m <- matrix(v, 8, 12)
> m
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10" "A11" "A12"
[2,] "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" "... |
37,492,145 | Usually i do:
```
onclick="myFunction()"
```
on my submit button, but what i want to do now on html is
```
<form id="myForm">
<input type="text" id="myTextBox" required> <!-- we're gonna use this id: myTextBox because we're using the getElementById() -->
<input type="submit" value="Click Me"> <!-- we call the func... | 2016/05/27 | [
"https://Stackoverflow.com/questions/37492145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366860/"
] | Firstly, you can do this quickly and easily, in one line, with `sapply()`.
```
m1 <- t(sapply(LETTERS[1:8], paste0, 1:12, USE.NAMES = FALSE))
```
But you want to use a `for()` loop. So for that you can create an empty character matrix with desired dimensions first, then assign the rows in the loop.
```
m2 <- matrix... | Something like this?
```
df <- expand.grid(LETTERS[1:8], 1:12)
v <- paste0(df[[1]], df[[2]])
m <- matrix(v, 8, 12)
> m
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10" "A11" "A12"
[2,] "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" "... |
37,492,145 | Usually i do:
```
onclick="myFunction()"
```
on my submit button, but what i want to do now on html is
```
<form id="myForm">
<input type="text" id="myTextBox" required> <!-- we're gonna use this id: myTextBox because we're using the getElementById() -->
<input type="submit" value="Click Me"> <!-- we call the func... | 2016/05/27 | [
"https://Stackoverflow.com/questions/37492145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366860/"
] | Firstly, you can do this quickly and easily, in one line, with `sapply()`.
```
m1 <- t(sapply(LETTERS[1:8], paste0, 1:12, USE.NAMES = FALSE))
```
But you want to use a `for()` loop. So for that you can create an empty character matrix with desired dimensions first, then assign the rows in the loop.
```
m2 <- matrix... | Use the `outer` function:
```
nameMatrix <- outer(LETTERS[1:8], 1:12, paste, sep = "")
nameMatrix
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" "A10" "A11" "A12"
[2,] "B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" "B12"
[3,] "C1" "C2" "C... |
2,320,553 | I've a custom SplitButton implementation in which contains a ComboBox with several ComboBoxItems bound to commands. I can bind to the Name, and Text properties of the command just fine but have no way of binding the ComboBoxItem's **IsEnabled** property to the result of a Command's **CanExecute** method because it is a... | 2010/02/23 | [
"https://Stackoverflow.com/questions/2320553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83658/"
] | Another solution by ViewModel. Below is how I used a ViewModel to solve my problem. And please note that the nifty NotifyPropertyChanged method is part of my base ViewModel class.
```
public class RoutedUICommandViewModel : ViewModel
{
private RoutedUICommand _command;
private IInputElement _target;
publi... | You can put a button(if you dont have one in the controltemplate bound to the ICommand) inside ItemContainerStyle(ComboBoxItem style) and Bind the command to it
And add a Trigger to check the Button.IsEnabled and set that value to the ComboBoxItem. So here we used Button as a CommandSource just to get the IsEnabled fro... |
2,320,553 | I've a custom SplitButton implementation in which contains a ComboBox with several ComboBoxItems bound to commands. I can bind to the Name, and Text properties of the command just fine but have no way of binding the ComboBoxItem's **IsEnabled** property to the result of a Command's **CanExecute** method because it is a... | 2010/02/23 | [
"https://Stackoverflow.com/questions/2320553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83658/"
] | You can put a button(if you dont have one in the controltemplate bound to the ICommand) inside ItemContainerStyle(ComboBoxItem style) and Bind the command to it
And add a Trigger to check the Button.IsEnabled and set that value to the ComboBoxItem. So here we used Button as a CommandSource just to get the IsEnabled fro... | The way I solved this problem in my code was to add an event handler on the ComboBox for the PreviewMouseDown event. Here's the handler:
```
private void comboBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
ViewModel vm = this.DataContext as ViewModel;
if (vm != null)
... |
2,320,553 | I've a custom SplitButton implementation in which contains a ComboBox with several ComboBoxItems bound to commands. I can bind to the Name, and Text properties of the command just fine but have no way of binding the ComboBoxItem's **IsEnabled** property to the result of a Command's **CanExecute** method because it is a... | 2010/02/23 | [
"https://Stackoverflow.com/questions/2320553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83658/"
] | Another solution by ViewModel. Below is how I used a ViewModel to solve my problem. And please note that the nifty NotifyPropertyChanged method is part of my base ViewModel class.
```
public class RoutedUICommandViewModel : ViewModel
{
private RoutedUICommand _command;
private IInputElement _target;
publi... | I found [this discussion](http://social.msdn.microsoft.com/forums/en-US/wpf/thread/66e49c70-e705-4019-95ea-c3d9f8937054/?prof=required) on MSDN forums where [Dr. WPF](http://drwpf.com/blog/) had recommended the use of an [attached behavior](http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx) to solve this exact p... |
2,320,553 | I've a custom SplitButton implementation in which contains a ComboBox with several ComboBoxItems bound to commands. I can bind to the Name, and Text properties of the command just fine but have no way of binding the ComboBoxItem's **IsEnabled** property to the result of a Command's **CanExecute** method because it is a... | 2010/02/23 | [
"https://Stackoverflow.com/questions/2320553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83658/"
] | Another solution by ViewModel. Below is how I used a ViewModel to solve my problem. And please note that the nifty NotifyPropertyChanged method is part of my base ViewModel class.
```
public class RoutedUICommandViewModel : ViewModel
{
private RoutedUICommand _command;
private IInputElement _target;
publi... | The way I solved this problem in my code was to add an event handler on the ComboBox for the PreviewMouseDown event. Here's the handler:
```
private void comboBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
ViewModel vm = this.DataContext as ViewModel;
if (vm != null)
... |
2,320,553 | I've a custom SplitButton implementation in which contains a ComboBox with several ComboBoxItems bound to commands. I can bind to the Name, and Text properties of the command just fine but have no way of binding the ComboBoxItem's **IsEnabled** property to the result of a Command's **CanExecute** method because it is a... | 2010/02/23 | [
"https://Stackoverflow.com/questions/2320553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83658/"
] | I found [this discussion](http://social.msdn.microsoft.com/forums/en-US/wpf/thread/66e49c70-e705-4019-95ea-c3d9f8937054/?prof=required) on MSDN forums where [Dr. WPF](http://drwpf.com/blog/) had recommended the use of an [attached behavior](http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx) to solve this exact p... | The way I solved this problem in my code was to add an event handler on the ComboBox for the PreviewMouseDown event. Here's the handler:
```
private void comboBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
ViewModel vm = this.DataContext as ViewModel;
if (vm != null)
... |
74,388,661 | how can i sort 2D mutable list of array by the first element of array?
```
val books = mutableListOf<Any>(
listof("abc","b",1),
listof("abb","y",2),
listof("abcl"."i",3)
)
```
i want to get sort this mutablelist by alphabetical order of the first element of each list.
output should be
```
[listof("abb","y",2... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74388661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20463529/"
] | Using `sed`
```
$ sed '/e/{s/1 2 3/4 5 6/;h;d};/k/{G}' input_file
a b c d 1 2 3
i j k l 1 2 3
e f g h 4 5 6
m n o p 1 2 3
``` | This `awk` should work for you:
```bash
awk '
/(^| )e( |$)/ {
sub(/1 2 3/, "4 5 6")
p = $0
next
}
1
/(^| )k( |$)/ {
print p
p = ""
}' file
a b c d 1 2 3
i j k l 1 2 3
e f g h 4 5 6
m n o p 1 2 3
``` |
74,388,661 | how can i sort 2D mutable list of array by the first element of array?
```
val books = mutableListOf<Any>(
listof("abc","b",1),
listof("abb","y",2),
listof("abcl"."i",3)
)
```
i want to get sort this mutablelist by alphabetical order of the first element of each list.
output should be
```
[listof("abb","y",2... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74388661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20463529/"
] | Here is a GNU awk solution:
```
awk '
/\<e\>/{
s=$0
sub("1 2 3", "4 5 6", s)
next
}
/\<k\>/ && s {
printf("%s\n%s\n",$0,s)
next
} 1
' file
```
Or POSIX awk:
```
awk '
function has(x) {
for(i=1; i<=NF; i++) if ($i==x) return 1
return 0
}
has("e") {
s=$0
sub("1 2 3", "4 5 6", s)
... | This `awk` should work for you:
```bash
awk '
/(^| )e( |$)/ {
sub(/1 2 3/, "4 5 6")
p = $0
next
}
1
/(^| )k( |$)/ {
print p
p = ""
}' file
a b c d 1 2 3
i j k l 1 2 3
e f g h 4 5 6
m n o p 1 2 3
``` |
74,388,661 | how can i sort 2D mutable list of array by the first element of array?
```
val books = mutableListOf<Any>(
listof("abc","b",1),
listof("abb","y",2),
listof("abcl"."i",3)
)
```
i want to get sort this mutablelist by alphabetical order of the first element of each list.
output should be
```
[listof("abb","y",2... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74388661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20463529/"
] | Using `sed`
```
$ sed '/e/{s/1 2 3/4 5 6/;h;d};/k/{G}' input_file
a b c d 1 2 3
i j k l 1 2 3
e f g h 4 5 6
m n o p 1 2 3
``` | Here is a GNU awk solution:
```
awk '
/\<e\>/{
s=$0
sub("1 2 3", "4 5 6", s)
next
}
/\<k\>/ && s {
printf("%s\n%s\n",$0,s)
next
} 1
' file
```
Or POSIX awk:
```
awk '
function has(x) {
for(i=1; i<=NF; i++) if ($i==x) return 1
return 0
}
has("e") {
s=$0
sub("1 2 3", "4 5 6", s)
... |
74,388,661 | how can i sort 2D mutable list of array by the first element of array?
```
val books = mutableListOf<Any>(
listof("abc","b",1),
listof("abb","y",2),
listof("abcl"."i",3)
)
```
i want to get sort this mutablelist by alphabetical order of the first element of each list.
output should be
```
[listof("abb","y",2... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74388661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20463529/"
] | Using `sed`
```
$ sed '/e/{s/1 2 3/4 5 6/;h;d};/k/{G}' input_file
a b c d 1 2 3
i j k l 1 2 3
e f g h 4 5 6
m n o p 1 2 3
``` | This might work for you (GNU sed):
```
sed -n '/e/{s/1 2 3/4 5 6/;s#.*#/e/d;/k/s/.*/\&\\n&/#p};' file | sed -f - file
```
Design a sed script by passing the file twice and applying the sed instructions from the first pass to the second.
---
Another solution is to use ed:
```
cat <<\! | ed file
/e/s/1 2 3/4 5 6/
/... |
74,388,661 | how can i sort 2D mutable list of array by the first element of array?
```
val books = mutableListOf<Any>(
listof("abc","b",1),
listof("abb","y",2),
listof("abcl"."i",3)
)
```
i want to get sort this mutablelist by alphabetical order of the first element of each list.
output should be
```
[listof("abb","y",2... | 2022/11/10 | [
"https://Stackoverflow.com/questions/74388661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20463529/"
] | Here is a GNU awk solution:
```
awk '
/\<e\>/{
s=$0
sub("1 2 3", "4 5 6", s)
next
}
/\<k\>/ && s {
printf("%s\n%s\n",$0,s)
next
} 1
' file
```
Or POSIX awk:
```
awk '
function has(x) {
for(i=1; i<=NF; i++) if ($i==x) return 1
return 0
}
has("e") {
s=$0
sub("1 2 3", "4 5 6", s)
... | This might work for you (GNU sed):
```
sed -n '/e/{s/1 2 3/4 5 6/;s#.*#/e/d;/k/s/.*/\&\\n&/#p};' file | sed -f - file
```
Design a sed script by passing the file twice and applying the sed instructions from the first pass to the second.
---
Another solution is to use ed:
```
cat <<\! | ed file
/e/s/1 2 3/4 5 6/
/... |
10,858,810 | I am working on a project which requires making discrete values out of numeric quantities all over the place. At present I'm using cascaded if / elseif / else constructs, for example:
```
if M > 6
evidence{2} = 3;
elseif M > 2
evidence{2} = 2;
else
evidence{2} = 1;
end
```
I w... | 2012/06/02 | [
"https://Stackoverflow.com/questions/10858810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/415540/"
] | How about:
```
evidence{2} = sum( M > [-inf 2 6] )
```
Basically, you are searching for the interval in which M lies: (-inf,2], (2,6], (6,+inf)
So even if your values were not 1/2/3, you could then map the range index found to some other values... | ```
evidence{2} = 1 + (M > 2) + (M > 6);
```
but in my opinion, it is less maintainable. Yours is better. |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | The error comes from the fact that the return value of `Test-Path` is a Boolean type.
Hence, **don't compare it to strings representation of Boolean but rather to the actual `$false`/`$true` values.** Like so,
```
$Path = Test-Path c:\temp\First
if ($Path -eq $false)
{
Write-Host "notthere" -ForegroundColor Yel... | If I'm not mistaken, one can simple say:
`if($Path)`
OR
`if(!$Path)`
But I might be wrong as I can't test atm.
Additionally there is the `Test-Path` cmdlet available. Unfortunately I cannot describe the difference or suggest the most suitable method without knowing the case and scenario.
[EDITED TO CLARIFY ANSWER]
... |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | The error comes from the fact that the return value of `Test-Path` is a Boolean type.
Hence, **don't compare it to strings representation of Boolean but rather to the actual `$false`/`$true` values.** Like so,
```
$Path = Test-Path c:\temp\First
if ($Path -eq $false)
{
Write-Host "notthere" -ForegroundColor Yel... | In a comparison operation PowerShell automatically converts the second operand to the type of the first operand. Since you're comparing a boolean value to a string, the string will be cast to a boolean value. Empty strings will be cast to `$false` and non-empty strings will be cast to `$true`. Jeffrey Snover wrote an a... |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | The error comes from the fact that the return value of `Test-Path` is a Boolean type.
Hence, **don't compare it to strings representation of Boolean but rather to the actual `$false`/`$true` values.** Like so,
```
$Path = Test-Path c:\temp\First
if ($Path -eq $false)
{
Write-Host "notthere" -ForegroundColor Yel... | To make some things clear, always use Test-Path (or Test-Path with Leaf to check for a file).
**Examples I've tested:**
```
$File = "c:\path\file.exe"
$IsPath = Test-Path -Path $File -PathType Leaf
# using -Not or ! to check if a file doesn't exist
if (-Not(Test-Path -Path $File -PathType Leaf)) {
Write-Host "1 ... |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | In a comparison operation PowerShell automatically converts the second operand to the type of the first operand. Since you're comparing a boolean value to a string, the string will be cast to a boolean value. Empty strings will be cast to `$false` and non-empty strings will be cast to `$true`. Jeffrey Snover wrote an a... | If I'm not mistaken, one can simple say:
`if($Path)`
OR
`if(!$Path)`
But I might be wrong as I can't test atm.
Additionally there is the `Test-Path` cmdlet available. Unfortunately I cannot describe the difference or suggest the most suitable method without knowing the case and scenario.
[EDITED TO CLARIFY ANSWER]
... |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | If I'm not mistaken, one can simple say:
`if($Path)`
OR
`if(!$Path)`
But I might be wrong as I can't test atm.
Additionally there is the `Test-Path` cmdlet available. Unfortunately I cannot describe the difference or suggest the most suitable method without knowing the case and scenario.
[EDITED TO CLARIFY ANSWER]
... | To make some things clear, always use Test-Path (or Test-Path with Leaf to check for a file).
**Examples I've tested:**
```
$File = "c:\path\file.exe"
$IsPath = Test-Path -Path $File -PathType Leaf
# using -Not or ! to check if a file doesn't exist
if (-Not(Test-Path -Path $File -PathType Leaf)) {
Write-Host "1 ... |
51,388,862 | Basically I want to do a check if a directory exists then run this section, if not exit.
The script I have is:
```
$Path = Test-Path c:\temp\First
if ($Path -eq "False")
{
Write-Host "notthere" -ForegroundColor Yellow
}
elseif ($Path -eq "true")
{
Write-Host " what the smokes"
}
```
But it returns nothing. | 2018/07/17 | [
"https://Stackoverflow.com/questions/51388862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964812/"
] | In a comparison operation PowerShell automatically converts the second operand to the type of the first operand. Since you're comparing a boolean value to a string, the string will be cast to a boolean value. Empty strings will be cast to `$false` and non-empty strings will be cast to `$true`. Jeffrey Snover wrote an a... | To make some things clear, always use Test-Path (or Test-Path with Leaf to check for a file).
**Examples I've tested:**
```
$File = "c:\path\file.exe"
$IsPath = Test-Path -Path $File -PathType Leaf
# using -Not or ! to check if a file doesn't exist
if (-Not(Test-Path -Path $File -PathType Leaf)) {
Write-Host "1 ... |
611,046 | I have read this question:
<https://physics.stackexchange.com/a/561125/132371>
where cuevobat says:
>
> You will note if you examine the tables on conductors that some metals that are good electrical conductors also conduct heat well for the same reason - heat is also a vibration of electrons and depends on free el... | 2021/01/29 | [
"https://physics.stackexchange.com/questions/611046",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/132371/"
] | >
> Why do metals conduct electricity faster than heat?
>
>
>
If by electricity you mean the flow of current, then the question only makes sense (at least to me) under transient conditions with respect to how quickly steady heat flow is establish vs how quickly steady current flow is established, as discussed belo... | Sippose you have hosepipe full of water, and turn on the tap. You see that water comes out of the nozzle end of the pipe almost immediately. The "push" from the water at the tap end reaches the water at the nozzle end at the speed of sound in water --- more than 1,000 feet per second. The water entering the pipe at the... |
611,046 | I have read this question:
<https://physics.stackexchange.com/a/561125/132371>
where cuevobat says:
>
> You will note if you examine the tables on conductors that some metals that are good electrical conductors also conduct heat well for the same reason - heat is also a vibration of electrons and depends on free el... | 2021/01/29 | [
"https://physics.stackexchange.com/questions/611046",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/132371/"
] | In the case of heat transfer, the wire stays electrically neutral, so one electron can only interact with other electrons in it's close vicinity by collisions, but has no effect on electrons far away. So the signal about the increased temperature (i.e. higher thermal velocity) travels by collisions from one electron to... | Sippose you have hosepipe full of water, and turn on the tap. You see that water comes out of the nozzle end of the pipe almost immediately. The "push" from the water at the tap end reaches the water at the nozzle end at the speed of sound in water --- more than 1,000 feet per second. The water entering the pipe at the... |
611,046 | I have read this question:
<https://physics.stackexchange.com/a/561125/132371>
where cuevobat says:
>
> You will note if you examine the tables on conductors that some metals that are good electrical conductors also conduct heat well for the same reason - heat is also a vibration of electrons and depends on free el... | 2021/01/29 | [
"https://physics.stackexchange.com/questions/611046",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/132371/"
] | >
> Why do metals conduct electricity faster than heat?
>
>
>
If by electricity you mean the flow of current, then the question only makes sense (at least to me) under transient conditions with respect to how quickly steady heat flow is establish vs how quickly steady current flow is established, as discussed belo... | In the case of heat transfer, the wire stays electrically neutral, so one electron can only interact with other electrons in it's close vicinity by collisions, but has no effect on electrons far away. So the signal about the increased temperature (i.e. higher thermal velocity) travels by collisions from one electron to... |
15,977,707 | I am developing an app that needs to be debugged under a slow connection. My issue is that I only own an iPhone 5 that uses LTE. I can disable LTE in my Settings for a 4G connection but this 4G connection is still to fast for my testing purposes. I would like to know if there is a way to programmatically force the test... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15977707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368547/"
] | You'll want to test flaky in addition to just going slow - you can simulate this with apple's network link conditioner and running your iPhone through your mac's internet connection (or run simulator). See [Installing Apple's Network Link Conditioner Tool](https://stackoverflow.com/questions/9659382/installing-apples-n... | >
> I can disable LTE in my Settings for a 4G connection but this 4G connection is still to fast for my testing purposes
>
>
>
LTE **is** (a kind of) 4G.
If you disable it, it will fall back to EDGE. Alternatively, you may switch to a Wi-Fi connection and slow it down (if your router has such a feature). |
15,977,707 | I am developing an app that needs to be debugged under a slow connection. My issue is that I only own an iPhone 5 that uses LTE. I can disable LTE in my Settings for a 4G connection but this 4G connection is still to fast for my testing purposes. I would like to know if there is a way to programmatically force the test... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15977707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368547/"
] | Network Link Conditioner also exists on the device in recent iOS builds, i'm not positive of when they added it.
But its present in Settings, under the Developer menu. | >
> I can disable LTE in my Settings for a 4G connection but this 4G connection is still to fast for my testing purposes
>
>
>
LTE **is** (a kind of) 4G.
If you disable it, it will fall back to EDGE. Alternatively, you may switch to a Wi-Fi connection and slow it down (if your router has such a feature). |
15,977,707 | I am developing an app that needs to be debugged under a slow connection. My issue is that I only own an iPhone 5 that uses LTE. I can disable LTE in my Settings for a 4G connection but this 4G connection is still to fast for my testing purposes. I would like to know if there is a way to programmatically force the test... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15977707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368547/"
] | You'll want to test flaky in addition to just going slow - you can simulate this with apple's network link conditioner and running your iPhone through your mac's internet connection (or run simulator). See [Installing Apple's Network Link Conditioner Tool](https://stackoverflow.com/questions/9659382/installing-apples-n... | Network Link Conditioner also exists on the device in recent iOS builds, i'm not positive of when they added it.
But its present in Settings, under the Developer menu. |
65,183,308 | I have dates in my data frame and I want to create a new variables where I uses the date to group them into time periods. The time periods would be
1980-1989
1990-1999
2000-2012
They are of class date
```
date_of_delivery
1984-02-03
1997-08-01
2007-04-25
1999-04-05
```
The new column would look like
```
date_of_d... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65183308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14705785/"
] | Use `cut`:
```r
cutoffs <- setNames(as.Date(c("1980-01-01", "1990-01-01", "2000-01-01", "2013-01-01")), c("1980-1989", "1990-1999", "2000-2012", "Future"))
cutoffs
# 1980-1989 1990-1999 2000-2012 Future
# "1980-01-01" "1990-01-01" "2000-01-01" "2013-01-01"
cut(dat$date_of_delivery, cutoffs, labels = n... | You could try the Date method of `cut` from base R.
```
data$dod_group <- cut(as.Date(c("1980-01-01",data$date_of_delivery),
"%Y-%m-%d"),
breaks = "10 years")[-1]
data
# date_of_delivery dod_group
#1 1984-02-03 1980-01-01
#2 1997-08-01 1990-01-01
#3 ... |
35,692,111 | I have the following JSON string which comes from a HTTP request:
```
{ '{firstname:\'Joe\'}': '' } // output of console.log(req.body);
```
I have tried to print the value to console using:
```
console.log(req.body.firstname);
```
but it says the value is undefined. How can I get the value of firstname?
To see w... | 2016/02/29 | [
"https://Stackoverflow.com/questions/35692111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2924127/"
] | You missed ' code after **CodeCompiler** so change your query from
```
INSERT INTO futureposts (ID, username, postedby, link, message, picture, name, caption, description, groups, type) VALUES ('','1','CodeCompiler','CodeCompiler,'','','','','','','default','daily')
```
to
```
INSERT INTO futureposts (ID, username... | You missed ' (closing quote) after **CodeCompiler**
....VALUES ('','1','CodeCompiler','**CodeCompiler**,'','....
Also one change that you need to do that is you are giving 12 values to 11 column..I have checked personally in my phpmyadmin by creating same table.
So your final query will be
```
INSERT INTO futurepo... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | As @Eugene Obrezkov pointed out, your issue is related to where you are uploading your images and the grunt task runner. All the assets are copied from that folder (`/assets`) to the `.tmp`, and changes are watched by the grunt task runner, but that doesn't include new image files(If you are to an empty folder in the a... | If you take a look into `tasks` folder, you can find Grunt task that copies all the `assets` folder to `.tmp` folder and make `.tmp` folder as static public folder.
When you are running Sails application, it runs these Grunt tasks, so that if you uploading file direct to `assets` folder it will not be accessible until... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | If you take a look into `tasks` folder, you can find Grunt task that copies all the `assets` folder to `.tmp` folder and make `.tmp` folder as static public folder.
When you are running Sails application, it runs these Grunt tasks, so that if you uploading file direct to `assets` folder it will not be accessible until... | You can achieve without modifing any grunt task. I had the same issue and I have just solved it.
I see you already have an explanation of what's happening in other comments, so I'll go straight to my solution. I uploaded the files to the .tmp folder, and on the callback of the upload, I coppied them to the assets fold... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | If you take a look into `tasks` folder, you can find Grunt task that copies all the `assets` folder to `.tmp` folder and make `.tmp` folder as static public folder.
When you are running Sails application, it runs these Grunt tasks, so that if you uploading file direct to `assets` folder it will not be accessible until... | This is how I solved this problem. The answer requires several steps. I am assuming you want to place your recently uploaded images in a folder called users.
**Steps:**
1. `npm install express --save` (If you don't have it installed)
2. Create a **Users** folder in your apps root directory.
3. Open the text editor a... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | As @Eugene Obrezkov pointed out, your issue is related to where you are uploading your images and the grunt task runner. All the assets are copied from that folder (`/assets`) to the `.tmp`, and changes are watched by the grunt task runner, but that doesn't include new image files(If you are to an empty folder in the a... | You can achieve without modifing any grunt task. I had the same issue and I have just solved it.
I see you already have an explanation of what's happening in other comments, so I'll go straight to my solution. I uploaded the files to the .tmp folder, and on the callback of the upload, I coppied them to the assets fold... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | As @Eugene Obrezkov pointed out, your issue is related to where you are uploading your images and the grunt task runner. All the assets are copied from that folder (`/assets`) to the `.tmp`, and changes are watched by the grunt task runner, but that doesn't include new image files(If you are to an empty folder in the a... | This is how I solved this problem. The answer requires several steps. I am assuming you want to place your recently uploaded images in a folder called users.
**Steps:**
1. `npm install express --save` (If you don't have it installed)
2. Create a **Users** folder in your apps root directory.
3. Open the text editor a... |
32,333,740 | know anyone how can I split my seach view in 2 activity? Before the click on search icon you are in one activity and after you click on it you will be in anther activity were you can write what do you want. | 2015/09/01 | [
"https://Stackoverflow.com/questions/32333740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697187/"
] | You can achieve without modifing any grunt task. I had the same issue and I have just solved it.
I see you already have an explanation of what's happening in other comments, so I'll go straight to my solution. I uploaded the files to the .tmp folder, and on the callback of the upload, I coppied them to the assets fold... | This is how I solved this problem. The answer requires several steps. I am assuming you want to place your recently uploaded images in a folder called users.
**Steps:**
1. `npm install express --save` (If you don't have it installed)
2. Create a **Users** folder in your apps root directory.
3. Open the text editor a... |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | This completely removes the modal from the DOM , is working for the "appended" modals as well .
#pickoptionmodal is the id of my modal window.
==============================================
```
$(document).on('hidden.bs.modal','#pickoptionmodal',function(e){
e.preventDefault();
$("#pickoptionmodal").remove();
});... | With ui-router this may be an option for you. It reloads the controller on close so reinitializes the modal contents before it fires next time.
```
$("#myModalId").on('hidden.bs.modal', function () {
$state.reload(); //resets the modal
});
``` |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | if is bootstrap 3 you can use:
```js
$("#mimodal").on('hidden.bs.modal', function () {
$(this).data('bs.modal', null);
});
``` | I had to use same modal for different link clicks. I just replaced the html content with empty "" of the modal in hidden callback. |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | *NOTE: This solution works only for Bootstrap before version 3. For a Bootstrap 3 answer, refer to [this one by user2612497](https://stackoverflow.com/a/18169689/177710).*
What you want to do is:
```
$('#modalElement').on('hidden', function(){
$(this).data('modal', null);
});
```
that will cause the modal to in... | Single line complete removal on hide ( ES6 )
`$("#myModal").on('hidden.bs.modal', (e)=>e.currentTarget.remove());` |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | *NOTE: This solution works only for Bootstrap before version 3. For a Bootstrap 3 answer, refer to [this one by user2612497](https://stackoverflow.com/a/18169689/177710).*
What you want to do is:
```
$('#modalElement').on('hidden', function(){
$(this).data('modal', null);
});
```
that will cause the modal to in... | From what i understand, you don't wanna remove it, nor hide it ? Because you might wanna reuse it later ..but don't want it to have the old content if ever you open it up again ?
```
<div class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidde... |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | For 3.x version
```
$( '.modal' ).modal( 'hide' ).data( 'bs.modal', null );
```
For 2.x version (risky; read comments below)
When you create bootstrap modal three elements on your page being changed. So if you want to completely rollback all changes, you have to do it manually for each of it.
```
$( '.modal' ).remo... | My approach would be to use the [`clone()`](http://api.jquery.com/clone/) method of jQuery. It creates a copy of your element, and that's what you want : a copy of your first unaltered modal, that you can replace at your wish : [Demo (jsfiddle)](http://jsfiddle.net/Sherbrow/8XCps/)
```js
var myBackup = $('#myModal').c... |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | My approach would be to use the [`clone()`](http://api.jquery.com/clone/) method of jQuery. It creates a copy of your element, and that's what you want : a copy of your first unaltered modal, that you can replace at your wish : [Demo (jsfiddle)](http://jsfiddle.net/Sherbrow/8XCps/)
```js
var myBackup = $('#myModal').c... | this worked for me on BS4:
```
let $modal = $(this);
$modal.modal('hide').on("hidden.bs.modal", function (){
$modal.remove();
});
```
we remove the modal after it is completely hidden.
from BS doc:
>
> hidden.bs.modal: This event is fired when the modal has finished being
> hidden from the user (will wait for ... |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | This completely removes the modal from the DOM , is working for the "appended" modals as well .
#pickoptionmodal is the id of my modal window.
==============================================
```
$(document).on('hidden.bs.modal','#pickoptionmodal',function(e){
e.preventDefault();
$("#pickoptionmodal").remove();
});... | If modal shadow remains darker and not going for showing more than one modal then this will be helpful
```
$('.modal').live('hide',function(){
if($('.modal-backdrop').length>1){
$('.modal-backdrop')[0].remove();
}
});
``` |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | bootstrap 3 + jquery 2.0.3:
```
$('#myModal').on('hide.bs.modal', function () {
$('#myModal').removeData();
})
``` | With ui-router this may be an option for you. It reloads the controller on close so reinitializes the modal contents before it fires next time.
```
$("#myModalId").on('hidden.bs.modal', function () {
$state.reload(); //resets the modal
});
``` |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | I have tried accepted answer but it isn't seems working on my end and I don't know how the accepted answer suppose to work.
```
$('#modalId').on('hidden.bs.modal', function () {
$(this).remove();
})
```
This is working perfectly fine on my side. BS Version > 3 | If modal shadow remains darker and not going for showing more than one modal then this will be helpful
```
$('.modal').live('hide',function(){
if($('.modal-backdrop').length>1){
$('.modal-backdrop')[0].remove();
}
});
``` |
13,177,426 | I've made use of **modal window** for a wizard implementation which has around 4,5 steps. I need to destroy it completely after the **last step**(onFinish) and **OnCancel step without having a page refresh**. I can of course hide it, but hiding modal windows restores everything as such when i open up it again. Could an... | 2012/11/01 | [
"https://Stackoverflow.com/questions/13177426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242378/"
] | My approach would be to use the [`clone()`](http://api.jquery.com/clone/) method of jQuery. It creates a copy of your element, and that's what you want : a copy of your first unaltered modal, that you can replace at your wish : [Demo (jsfiddle)](http://jsfiddle.net/Sherbrow/8XCps/)
```js
var myBackup = $('#myModal').c... | Single line complete removal on hide ( ES6 )
`$("#myModal").on('hidden.bs.modal', (e)=>e.currentTarget.remove());` |
1,806,909 | [Tacit or point-free style programming](http://en.wikipedia.org/wiki/Tacit_programming) allows one to create functions without regard to their arguments. Can this be done in F#? | 2009/11/27 | [
"https://Stackoverflow.com/questions/1806909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14139/"
] | Just to go with Chuck's answer & Chris Smiths' comment, you could write
```
let digits = string_of_int >> String.length
digits 9000;; // 4
[1; 10; 100] |> List.map digits;; // [1;2;3]
```
When you combine those composition & pipeline operators with higher-order functions, you can do complicated stuff very succinctly... | Sure. All you need is function composition and currying, and both of these are possible in F#.
```
let compose f1 f2 = fun x -> f1 (f2 x);;
let digits = compose String.length string_of_int;;
digits 9000;; // 4
``` |
48,570,209 | This is my first time on the website. I have a big problem with my hangman.
I have a wordBank:
```
wordBank = ["pizza", "pie", "cookie", "candy", "salad", "chicken", "pork", "burger", "fries"]
```
I have a variable that chooses a random word from the wordBank and makes it into a array:
```
randomChosenWord ... | 2018/02/01 | [
"https://Stackoverflow.com/questions/48570209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005223/"
] | You can loop through the length of the random word, checking each letter to see if it is the chosen letter. If it is, replace the character at that index.
```
for(var i = 0; i < randomChosenWord.length; i++) {
if(randomChosenWord[i] === this.letter){
lettersChosen.splice(i, 1, this.letter);
}
}
```
This woul... | You can change this line: `if (randomChosenWord.includes(this.letter)) {` to a while loop. |
48,570,209 | This is my first time on the website. I have a big problem with my hangman.
I have a wordBank:
```
wordBank = ["pizza", "pie", "cookie", "candy", "salad", "chicken", "pork", "burger", "fries"]
```
I have a variable that chooses a random word from the wordBank and makes it into a array:
```
randomChosenWord ... | 2018/02/01 | [
"https://Stackoverflow.com/questions/48570209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005223/"
] | Short way of doing it:
```
lettersChosen.split('').map(function (letter, i) {
return randomChosenWord[i] === this.letter ? this.letter : letter;
}).join('')
```
Split the lettersChosen into an array of individual letters, iterate through them using array.map and replace all matching letters, then join into a str... | You can change this line: `if (randomChosenWord.includes(this.letter)) {` to a while loop. |
48,570,209 | This is my first time on the website. I have a big problem with my hangman.
I have a wordBank:
```
wordBank = ["pizza", "pie", "cookie", "candy", "salad", "chicken", "pork", "burger", "fries"]
```
I have a variable that chooses a random word from the wordBank and makes it into a array:
```
randomChosenWord ... | 2018/02/01 | [
"https://Stackoverflow.com/questions/48570209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005223/"
] | You can loop through the length of the random word, checking each letter to see if it is the chosen letter. If it is, replace the character at that index.
```
for(var i = 0; i < randomChosenWord.length; i++) {
if(randomChosenWord[i] === this.letter){
lettersChosen.splice(i, 1, this.letter);
}
}
```
This woul... | Short way of doing it:
```
lettersChosen.split('').map(function (letter, i) {
return randomChosenWord[i] === this.letter ? this.letter : letter;
}).join('')
```
Split the lettersChosen into an array of individual letters, iterate through them using array.map and replace all matching letters, then join into a str... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | You can see how call feature detection is done in [CordovaCallNumberPlugin](https://github.com/Rohfosho/CordovaCallNumberPlugin).
There are tablets which support calling so I would check for this, but this is of course up to you and depends on your application.
**Android:**
```
private boolean isTelephonyEnabled(){
... | It depends what platforms you are supporting as to how easy this is.
Cordova "out-of-the-box" can't determine if a device is a tablet.
For iOS, a simple bit of Javascript can be used to detect if the device is an iPad by examining the user agent string:
```
var isTablet = !!navigator.userAgent.match(/iPad/i);
```
... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | It depends what platforms you are supporting as to how easy this is.
Cordova "out-of-the-box" can't determine if a device is a tablet.
For iOS, a simple bit of Javascript can be used to detect if the device is an iPad by examining the user agent string:
```
var isTablet = !!navigator.userAgent.match(/iPad/i);
```
... | You can use ngCordova plugin `$cordovaDevice`: <http://ngcordova.com/docs/plugins/device/>
Just add `$cordovaDevice` as a dependency in your controller and use it to tell what device is being used.
Perhaps you can build an array of models and check if the model is inside of that array, if it is, then disable the butt... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | It depends what platforms you are supporting as to how easy this is.
Cordova "out-of-the-box" can't determine if a device is a tablet.
For iOS, a simple bit of Javascript can be used to detect if the device is an iPad by examining the user agent string:
```
var isTablet = !!navigator.userAgent.match(/iPad/i);
```
... | Ionic adds various platform classes to the document body. In iOS you can simply check for the classes `platform-ipad` or `platform-ipod` to check for a non-iPhone. Source: [Ionic Platform Body Classes](https://github.com/delta98/ionic-platform-body-classes/) & [Platform Classes](http://ionicframework.com/docs/platform-... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | It depends what platforms you are supporting as to how easy this is.
Cordova "out-of-the-box" can't determine if a device is a tablet.
For iOS, a simple bit of Javascript can be used to detect if the device is an iPad by examining the user agent string:
```
var isTablet = !!navigator.userAgent.match(/iPad/i);
```
... | Found an easier way that doesn't need plugins and works for both IOS and Android tablets.
Just add to the `run` function of your app the following piece of code.
```
angular.module('app').run(function ($rootScope, $window) {
// Get the current platform.
var platform = ionic.Platform.platform();
// Initia... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | You can see how call feature detection is done in [CordovaCallNumberPlugin](https://github.com/Rohfosho/CordovaCallNumberPlugin).
There are tablets which support calling so I would check for this, but this is of course up to you and depends on your application.
**Android:**
```
private boolean isTelephonyEnabled(){
... | You can use ngCordova plugin `$cordovaDevice`: <http://ngcordova.com/docs/plugins/device/>
Just add `$cordovaDevice` as a dependency in your controller and use it to tell what device is being used.
Perhaps you can build an array of models and check if the model is inside of that array, if it is, then disable the butt... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | You can see how call feature detection is done in [CordovaCallNumberPlugin](https://github.com/Rohfosho/CordovaCallNumberPlugin).
There are tablets which support calling so I would check for this, but this is of course up to you and depends on your application.
**Android:**
```
private boolean isTelephonyEnabled(){
... | Ionic adds various platform classes to the document body. In iOS you can simply check for the classes `platform-ipad` or `platform-ipod` to check for a non-iPhone. Source: [Ionic Platform Body Classes](https://github.com/delta98/ionic-platform-body-classes/) & [Platform Classes](http://ionicframework.com/docs/platform-... |
32,762,046 | I am working on an ionic app and we have a button to Call someone. This doesn't make a whole lot of sense when using a tablet so I would like to not show this button if the person is using a tablet.
Is there an easy way using ionic/cordova that I can detect if the device is a tablet (or I suppose I could also detect i... | 2015/09/24 | [
"https://Stackoverflow.com/questions/32762046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | You can see how call feature detection is done in [CordovaCallNumberPlugin](https://github.com/Rohfosho/CordovaCallNumberPlugin).
There are tablets which support calling so I would check for this, but this is of course up to you and depends on your application.
**Android:**
```
private boolean isTelephonyEnabled(){
... | Found an easier way that doesn't need plugins and works for both IOS and Android tablets.
Just add to the `run` function of your app the following piece of code.
```
angular.module('app').run(function ($rootScope, $window) {
// Get the current platform.
var platform = ionic.Platform.platform();
// Initia... |
363,259 | I've been discussing the usage of "in Church Road" over "on Church Road" with my colleagues in a sentence such as "The supermarket is in Church Road". Whilst it is overwhelming clear that "on Church Road" is the favoured option in this discussion, it remains unclear as to whether the use of "in Church Road" is complete... | 2016/12/13 | [
"https://english.stackexchange.com/questions/363259",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/210625/"
] | [british-english](/questions/tagged/british-english "show questions tagged 'british-english'")
In British English, *in* is the preferred preposition. It specifies that the location is *within the bounds or extent of the street,* not actually buried in the tarmac.
>
> I live in Church Road.
>
>
>
*On* is becoming... | I'm a native English speaker and I am working on my MA in Linguistics.
When referring to buildings, you should always say "on Church Street" or "on Church Road". Using "in" implies that the building is inside the road, which doesn't make a lot of sense. |
363,259 | I've been discussing the usage of "in Church Road" over "on Church Road" with my colleagues in a sentence such as "The supermarket is in Church Road". Whilst it is overwhelming clear that "on Church Road" is the favoured option in this discussion, it remains unclear as to whether the use of "in Church Road" is complete... | 2016/12/13 | [
"https://english.stackexchange.com/questions/363259",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/210625/"
] | I'm a native English speaker and I am working on my MA in Linguistics.
When referring to buildings, you should always say "on Church Street" or "on Church Road". Using "in" implies that the building is inside the road, which doesn't make a lot of sense. | Very simple. "In Church Road" is British English; "On Church Road" is American English. |
363,259 | I've been discussing the usage of "in Church Road" over "on Church Road" with my colleagues in a sentence such as "The supermarket is in Church Road". Whilst it is overwhelming clear that "on Church Road" is the favoured option in this discussion, it remains unclear as to whether the use of "in Church Road" is complete... | 2016/12/13 | [
"https://english.stackexchange.com/questions/363259",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/210625/"
] | [british-english](/questions/tagged/british-english "show questions tagged 'british-english'")
In British English, *in* is the preferred preposition. It specifies that the location is *within the bounds or extent of the street,* not actually buried in the tarmac.
>
> I live in Church Road.
>
>
>
*On* is becoming... | Very simple. "In Church Road" is British English; "On Church Road" is American English. |
6,679 | I was trying to find a chat room associated with an answer to a few different questions, but in all instances I kept getting hit with a 'Page Not Found' presumably because I lacked the 20 rep to participate.
I was under the impression that in order to participate in chat I need 20 rep on the relevant site (in this cas... | 2017/01/10 | [
"https://rpg.meta.stackexchange.com/questions/6679",
"https://rpg.meta.stackexchange.com",
"https://rpg.meta.stackexchange.com/users/31402/"
] | You already have enough reputation to participate in chat. That's not what's going on there.
Since forever, chat rooms that aren't active get automatically frozen (read-only), then eventually possibly deleted (inaccessible). [The criteria for deletion](http://chat.stackexchange.com/faq#retention) nearly perfectly matc... | SevenSidedDie's pretty adequately explained why you can't view those chat rooms, which is the core of the issue.
I want to clarify what's going on with the reputation and access, since you're correct about some things and mistaken about others:
* The Chat counts your network reputation as the sum total of your reputa... |
70,290,260 | I want the bot to delete a message if the 'no no word' (anything in `nono`) is in it, but it should delete only if ***only*** that word is sent.
Example: the 'no no word' is "Hate", but if I send "I Hate you", it shouldn't delete the message. It should delete only if I send *only* "Hate" (without the "I" and "you" bef... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70290260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17541665/"
] | Are you sure that you wrote "I Hate you" and not "I hate you" in your message?
I have built a minimal example according to your code and it works fine.
```py
nono = ['Hate']
message = "I hate you"
for word in nono:
m = message.upper()
if word.upper() in m:
print("delete")
else:
print("Not... | Try using a json file, I've personally made a few automod bots and all of them use json.
Here's an example:
```
@commands.Cog.listener()
async def on_message(self, message):
user = message.author
guild_id = message.guild.id
em = discord.Embed(title="Profanity filter", description="Please... |
70,290,260 | I want the bot to delete a message if the 'no no word' (anything in `nono`) is in it, but it should delete only if ***only*** that word is sent.
Example: the 'no no word' is "Hate", but if I send "I Hate you", it shouldn't delete the message. It should delete only if I send *only* "Hate" (without the "I" and "you" bef... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70290260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17541665/"
] | Are you sure that you wrote "I Hate you" and not "I hate you" in your message?
I have built a minimal example according to your code and it works fine.
```py
nono = ['Hate']
message = "I hate you"
for word in nono:
m = message.upper()
if word.upper() in m:
print("delete")
else:
print("Not... | **Update:**
My friend has figured it out. Basically, this is the code from him:
```py
nono ['Hate']
for word in nono:
if message.content.lower().find(word)!=-1:
await message.delete()
await message.author.send("I hate you too dummy!")
```
Kudos to him :D |
70,290,260 | I want the bot to delete a message if the 'no no word' (anything in `nono`) is in it, but it should delete only if ***only*** that word is sent.
Example: the 'no no word' is "Hate", but if I send "I Hate you", it shouldn't delete the message. It should delete only if I send *only* "Hate" (without the "I" and "you" bef... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70290260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17541665/"
] | Are you sure that you wrote "I Hate you" and not "I hate you" in your message?
I have built a minimal example according to your code and it works fine.
```py
nono = ['Hate']
message = "I hate you"
for word in nono:
m = message.upper()
if word.upper() in m:
print("delete")
else:
print("Not... | You most probably are looking for [the `==` operator](https://www.w3schools.com/python/trypython.asp?filename=demo_oper_compare1):
```py
nono = ['Hate']
@client.event
@commands.has_permissions(manage_messages = False)
async def on_message(message):
if message.author.id == client.user.id:
return
if me... |
70,290,260 | I want the bot to delete a message if the 'no no word' (anything in `nono`) is in it, but it should delete only if ***only*** that word is sent.
Example: the 'no no word' is "Hate", but if I send "I Hate you", it shouldn't delete the message. It should delete only if I send *only* "Hate" (without the "I" and "you" bef... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70290260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17541665/"
] | Try using a json file, I've personally made a few automod bots and all of them use json.
Here's an example:
```
@commands.Cog.listener()
async def on_message(self, message):
user = message.author
guild_id = message.guild.id
em = discord.Embed(title="Profanity filter", description="Please... | **Update:**
My friend has figured it out. Basically, this is the code from him:
```py
nono ['Hate']
for word in nono:
if message.content.lower().find(word)!=-1:
await message.delete()
await message.author.send("I hate you too dummy!")
```
Kudos to him :D |
70,290,260 | I want the bot to delete a message if the 'no no word' (anything in `nono`) is in it, but it should delete only if ***only*** that word is sent.
Example: the 'no no word' is "Hate", but if I send "I Hate you", it shouldn't delete the message. It should delete only if I send *only* "Hate" (without the "I" and "you" bef... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70290260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17541665/"
] | Try using a json file, I've personally made a few automod bots and all of them use json.
Here's an example:
```
@commands.Cog.listener()
async def on_message(self, message):
user = message.author
guild_id = message.guild.id
em = discord.Embed(title="Profanity filter", description="Please... | You most probably are looking for [the `==` operator](https://www.w3schools.com/python/trypython.asp?filename=demo_oper_compare1):
```py
nono = ['Hate']
@client.event
@commands.has_permissions(manage_messages = False)
async def on_message(message):
if message.author.id == client.user.id:
return
if me... |
12,907,206 | This is coming from a wordpress site I'm working on, but isn't a WP-specific question.
I have an if/else PHP statement that checks whether the user is looking at my site's home page or not. If they are looking at the home page, I want the code to do nothing. If they AREN'T, I want it to display the page title in a con... | 2012/10/16 | [
"https://Stackoverflow.com/questions/12907206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556006/"
] | You need to move your code around. If you don't want the leading `<div><h1>` be printed on the front page, then move the `if` check before that. Add an `else` where you then print the `<div><h1>`, the big if/else code blob, and the closing `</div>`, etc.
Also read up on [switching in and out of PHPs code and html mode... | Put your echos into a variable instead of printing them, then after your if statements do
echo ($var =='') ? '' : ''.$var.'';
Html tags between the last 2 sets of single quotes |
643,662 | I'm fairly newbie to these concepts, so please try to give a simply answer.
Electric energy is often compared to gravitational energy. This analogy helps to understand the concept of voltage. With gravitation, there is a *potential difference* between two points (given that they're not in the same height), and this po... | 2021/06/06 | [
"https://physics.stackexchange.com/questions/643662",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/299695/"
] | You probably realize this is a very general question and a wall of text can be insufficient to answer it thoroughly. Still, one the most concise definitions of waves is that it's an oscillation which propagates in space.
When you ask "what are these waves made of", I suppose you wonder about a physical quantity which ... | Broadly, a wave is simply a quantity that changes in a periodic way over space and/or time.
In the case of a water wave, the changing quantity is the distance through which the surface is displaced- or, if you like, just the height of the surface.
With a wave on a string, the changing quantity is the displacement of ... |
643,662 | I'm fairly newbie to these concepts, so please try to give a simply answer.
Electric energy is often compared to gravitational energy. This analogy helps to understand the concept of voltage. With gravitation, there is a *potential difference* between two points (given that they're not in the same height), and this po... | 2021/06/06 | [
"https://physics.stackexchange.com/questions/643662",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/299695/"
] | You probably realize this is a very general question and a wall of text can be insufficient to answer it thoroughly. Still, one the most concise definitions of waves is that it's an oscillation which propagates in space.
When you ask "what are these waves made of", I suppose you wonder about a physical quantity which ... | For the layman: The defining characteristic of a wave is that it takes time for an influence to travel from place to place. E.g. Throw a stone in the water, and the influence (ripples) takes time to travel across the pond.
Physics deals with abstract entities where the medium is not always physical, from water waves (... |
643,662 | I'm fairly newbie to these concepts, so please try to give a simply answer.
Electric energy is often compared to gravitational energy. This analogy helps to understand the concept of voltage. With gravitation, there is a *potential difference* between two points (given that they're not in the same height), and this po... | 2021/06/06 | [
"https://physics.stackexchange.com/questions/643662",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/299695/"
] | Ever since the discovery of calculus mathematics, mathematical functions are used in order to model observations and special axioms are introduced in order to connect the pure numbers of mathematics with observable numbers.
Waves in water, the first waves to be observed are defined by their height and frequency in tim... | Broadly, a wave is simply a quantity that changes in a periodic way over space and/or time.
In the case of a water wave, the changing quantity is the distance through which the surface is displaced- or, if you like, just the height of the surface.
With a wave on a string, the changing quantity is the displacement of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.