qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
2,541,201 | What is the set $$ C:= \bigcap\_{n \in \mathbb{N}} \left[0, {1\over n}\right[$$
I guess the result will be that $C$ is an empty set, because the upper limit converges to $0$,
as the limit of ${1\over n}$ is $0$.
$$\left[0, 0\right[ = \emptyset $$
I tried to prove this with the Archimedean property:
Assume $C$ is... | 2017/11/28 | [
"https://math.stackexchange.com/questions/2541201",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | I claim that $$C: = \bigcap\_{n \in \mathbb{N}} \left[0, \frac{1}{n}\right[ = \{0\}$$
**Proof**: Suppose, for the sake of reaching a contradiction, that there exists $\epsilon > 0$ such that $\epsilon \in \left[0, \frac{1}{n}\right[$ for all $n \in \mathbb{N}$. Then, $\epsilon < \frac{1}{n}$ for every $n \in \mathbb{N... | Here is a way to *calculate* the result.$%
\require{begingroup}
\begingroup
\newcommand{\calc}{\begin{align} \quad &}
\newcommand{\op}[1]{\\ #1 \quad & \quad \unicode{x201c}}
\newcommand{\hints}[1]{\mbox{#1} \\ \quad & \quad \phantom{\unicode{x201c}} }
\newcommand{\hint}[1]{\mbox{#1} \unicode{x201d} \\ \quad & }
\newco... |
56,210,956 | I really have two questions:
1. Why is this line okay-
`Result = Application.WorksheetFunction.CountIfs(Range("AF:AF"), "GroupA", Range("AJ:AJ"), "Passing")`
But this isn't?
`Result = Application.WorksheetFunction.CountIfs(Range("L:L"), "11", (Range("AF:AF"), "GroupA", Range("AJ:AJ"), "Passing")`
When I try to ad... | 2019/05/19 | [
"https://Stackoverflow.com/questions/56210956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10018052/"
] | You can do something like this:
```
Result = Application.WorksheetFunction.CountIfs(Range("AF:AF"), "GroupA", _
Range("AJ:AJ"), "Passing", _
Range("L:L"), ">=9", _
Range("L:L... | I wonder if this link may help: <https://stackoverflow.com/a/8726792/11437092> (unless this is already one you've seen, of course).
It seems that you'd be able to use separate COUNTIF functions according to the number of OR arguments you need, and then simply add them together. May not be the most efficient way to do ... |
58,802,772 | ```
TextInputType.numberWithOptions(decimal: true),
```
I'm using the above code as a `keyboardType` in my `TextFormField` but in some devices, the device doesn't display comma or dot. Screenshot is given below:
[](https://i.stack.imgur.com/k5FHS.png)
Thinking o... | 2019/11/11 | [
"https://Stackoverflow.com/questions/58802772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9779791/"
] | This parameter will solve the problem
```
keyboardType: TextInputType.numberWithOptions(decimal: true),
``` | On iOS you have to enable the de (or any other locale than en\_US) locale in the ios build settings even for flutter apps.
1. Open the IOS folder in your flutter project
2. Inside the IOS folder open Runner.xcworkspace folder with xCode.
3. Click on the runner you will see bunch of option, click on info and under the ... |
58,802,772 | ```
TextInputType.numberWithOptions(decimal: true),
```
I'm using the above code as a `keyboardType` in my `TextFormField` but in some devices, the device doesn't display comma or dot. Screenshot is given below:
[](https://i.stack.imgur.com/k5FHS.png)
Thinking o... | 2019/11/11 | [
"https://Stackoverflow.com/questions/58802772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9779791/"
] | This parameter will solve the problem
```
keyboardType: TextInputType.numberWithOptions(decimal: true),
``` | It's a well known *Android* issue in Samsung Keyboards
<https://github.com/flutter/flutter/issues/61175>
### TLDR;
Usually the work-around is to fallback to text keyboard.
I developed a package with this work-around to easy get the keyboard vendor name and then make some crafty `if samsung then TextInputType.tex... |
58,802,772 | ```
TextInputType.numberWithOptions(decimal: true),
```
I'm using the above code as a `keyboardType` in my `TextFormField` but in some devices, the device doesn't display comma or dot. Screenshot is given below:
[](https://i.stack.imgur.com/k5FHS.png)
Thinking o... | 2019/11/11 | [
"https://Stackoverflow.com/questions/58802772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9779791/"
] | It's a well known *Android* issue in Samsung Keyboards
<https://github.com/flutter/flutter/issues/61175>
### TLDR;
Usually the work-around is to fallback to text keyboard.
I developed a package with this work-around to easy get the keyboard vendor name and then make some crafty `if samsung then TextInputType.tex... | On iOS you have to enable the de (or any other locale than en\_US) locale in the ios build settings even for flutter apps.
1. Open the IOS folder in your flutter project
2. Inside the IOS folder open Runner.xcworkspace folder with xCode.
3. Click on the runner you will see bunch of option, click on info and under the ... |
54,237,641 | Is there a way I can make asdf load all files (\*.lisp) in a directory without naming them all in my .asd file? Using wildcards in both directory or filename spec doesn't work. Can someone please help? | 2019/01/17 | [
"https://Stackoverflow.com/questions/54237641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10661741/"
] | See [`DIRECTORY`](http://clhs.lisp.se/Body/f_dir.htm):
```
CL-USER> (directory "*.lisp")
=> ("a.lisp"
"b.lisp"
...)
```
Then, call [`LOAD`](http://clhs.lisp.se/Body/f_load.htm) for each file.
But then, you could also do:
```
CL-USER> (loop for f in * collect `(:file ,(pathname-name f)))
((:file "a") (:... | The asdf repository comes with a asdf/contrib/wild-modules.lisp extension that does what you say. I'd still use package-inferred-system instead. |
54,237,641 | Is there a way I can make asdf load all files (\*.lisp) in a directory without naming them all in my .asd file? Using wildcards in both directory or filename spec doesn't work. Can someone please help? | 2019/01/17 | [
"https://Stackoverflow.com/questions/54237641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10661741/"
] | You could use the “package inferred system” extension of ASDF: <https://common-lisp.net/project/asdf/asdf/The-package_002dinferred_002dsystem-extension.html#The-package_002dinferred_002dsystem-extension>. You will have to adhere to a directory and file naming convention for this, but it is (superficially) a bit closer ... | The asdf repository comes with a asdf/contrib/wild-modules.lisp extension that does what you say. I'd still use package-inferred-system instead. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | As shown in [this post](http://caraulean.com/blog/2012/08/30/visual-studio-2012-dark-theme-tip/), you can condense the code to a single style by using a trigger, since `DesignerProperties.IsInDesignMode` is an [attached property](http://msdn.microsoft.com/en-us/library/ms749011.aspx).
Actually, the code there isn't qu... | Set the background color of the usercontrol to black in the XAML, then set it to transparent in code.
**Edit:**
If you're not comfortable leaving the code this way, then you can revert this change before you release, once you are done with all the designer work, though there is no harm in leaving it in. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | In your XAML, set your background to black. Then in your user control, use the DesignerProperties to set the background at runtime:
**XAML**
```
<UserControl .... Background="Black" .... >
```
**Code Behind**
```
public YourUserControl()
{
InitializeComponent();
if( !System.ComponentModel.DesignerProperties.G... | As shown in [this post](http://caraulean.com/blog/2012/08/30/visual-studio-2012-dark-theme-tip/), you can condense the code to a single style by using a trigger, since `DesignerProperties.IsInDesignMode` is an [attached property](http://msdn.microsoft.com/en-us/library/ms749011.aspx).
Actually, the code there isn't qu... |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | In your XAML, set your background to black. Then in your user control, use the DesignerProperties to set the background at runtime:
**XAML**
```
<UserControl .... Background="Black" .... >
```
**Code Behind**
```
public YourUserControl()
{
InitializeComponent();
if( !System.ComponentModel.DesignerProperties.G... | Set the background color of the usercontrol to black in the XAML, then set it to transparent in code.
**Edit:**
If you're not comfortable leaving the code this way, then you can revert this change before you release, once you are done with all the designer work, though there is no harm in leaving it in. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | Alternatively, as of VS 2013, you can do this in Tools -> Options -> Fonts and Colors, XAML UI Designer.
The editable foreground / background colors there are the colors of the checkerboard background. I just set them both to a darkish grey color that seems to work for both light and dark theme'd background stuff. | Set the background color of the usercontrol to black in the XAML, then set it to transparent in code.
**Edit:**
If you're not comfortable leaving the code this way, then you can revert this change before you release, once you are done with all the designer work, though there is no harm in leaving it in. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | As shown in [this post](http://caraulean.com/blog/2012/08/30/visual-studio-2012-dark-theme-tip/), you can condense the code to a single style by using a trigger, since `DesignerProperties.IsInDesignMode` is an [attached property](http://msdn.microsoft.com/en-us/library/ms749011.aspx).
Actually, the code there isn't qu... | Are you able to use Blend for designing? Blend has an option to switch between light and dark color schemes. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | Are you able to use Blend for designing? Blend has an option to switch between light and dark color schemes. | Set the XAML Designer background color to Gray.
Tools > Options> Fonts and Colors:
* Show settings for: XAML Designer,
* Display items: Artboard Background,
* Item foreground/background: Gray.
[](https://i.stack.imgur.com/NVkck.png)
Now you can see t... |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | In your XAML, set your background to black. Then in your user control, use the DesignerProperties to set the background at runtime:
**XAML**
```
<UserControl .... Background="Black" .... >
```
**Code Behind**
```
public YourUserControl()
{
InitializeComponent();
if( !System.ComponentModel.DesignerProperties.G... | Set the XAML Designer background color to Gray.
Tools > Options> Fonts and Colors:
* Show settings for: XAML Designer,
* Display items: Artboard Background,
* Item foreground/background: Gray.
[](https://i.stack.imgur.com/NVkck.png)
Now you can see t... |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | Alternatively, as of VS 2013, you can do this in Tools -> Options -> Fonts and Colors, XAML UI Designer.
The editable foreground / background colors there are the colors of the checkerboard background. I just set them both to a darkish grey color that seems to work for both light and dark theme'd background stuff. | As shown in [this post](http://caraulean.com/blog/2012/08/30/visual-studio-2012-dark-theme-tip/), you can condense the code to a single style by using a trigger, since `DesignerProperties.IsInDesignMode` is an [attached property](http://msdn.microsoft.com/en-us/library/ms749011.aspx).
Actually, the code there isn't qu... |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | Alternatively, as of VS 2013, you can do this in Tools -> Options -> Fonts and Colors, XAML UI Designer.
The editable foreground / background colors there are the colors of the checkerboard background. I just set them both to a darkish grey color that seems to work for both light and dark theme'd background stuff. | Are you able to use Blend for designing? Blend has an option to switch between light and dark color schemes. |
5,183,801 | I am currently working on a user control that has white text and a transparent background. Unfortunately because the XAML design view within VS2010 has a white background I cannot see anything that I am designing!
I have been through all the settings dialogs I can think of, but have been unable to find a setting that ... | 2011/03/03 | [
"https://Stackoverflow.com/questions/5183801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249933/"
] | Are you able to use Blend for designing? Blend has an option to switch between light and dark color schemes. | Set the background color of the usercontrol to black in the XAML, then set it to transparent in code.
**Edit:**
If you're not comfortable leaving the code this way, then you can revert this change before you release, once you are done with all the designer work, though there is no harm in leaving it in. |
31,245,674 | I'm in the process of updating my old mysql database techniques to prepared pdo statements. I'm all good with while loops `while($row = $result->fetch())` however how would I do the following with PDO prepared statements?
```
$sql = "SELECT * FROM table WHERE id=".$id;
$result = mysql_query($sql) or die(mysql_error())... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31245674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045858/"
] | To properly count rows with PDO you have to do this -
```
$result = $conn->prepare("SELECT * FROM table WHERE id= ?");
$result->execute(array($id));
$rows = $result->fetch(PDO::FETCH_NUM);
echo $rows[0];
```
But you would be better off using `LIMIT` in your query if all you want to do is get a static number of ... | What you could try is:
```
//Get your page number for example 2
$pagenum = 2;
//Calculate the offset
$offset = 7 * $pagenum;
//Create array
$data = array();
$result = $conn->prepare("SELECT * FROM table WHERE id= ? LIMIT 7 OFFSET ?");
$result->bind_param("ii", $id,$offset);
... |
31,245,674 | I'm in the process of updating my old mysql database techniques to prepared pdo statements. I'm all good with while loops `while($row = $result->fetch())` however how would I do the following with PDO prepared statements?
```
$sql = "SELECT * FROM table WHERE id=".$id;
$result = mysql_query($sql) or die(mysql_error())... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31245674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045858/"
] | To properly count rows with PDO you have to do this -
```
$result = $conn->prepare("SELECT * FROM table WHERE id= ?");
$result->execute(array($id));
$rows = $result->fetch(PDO::FETCH_NUM);
echo $rows[0];
```
But you would be better off using `LIMIT` in your query if all you want to do is get a static number of ... | You can try it this way:
```
$result = $conn->prepare("SELECT * FROM table WHERE id= ?");
$result->execute(array($id));
$loop_rows = $result->fetchAll();
$loop_count = count($loop_rows);
for($row=0;$row<7 && $loop_count-->0;$row++)
{
// Get next row
echo $loop_rows[$row]['field'];
}
``` |
31,245,674 | I'm in the process of updating my old mysql database techniques to prepared pdo statements. I'm all good with while loops `while($row = $result->fetch())` however how would I do the following with PDO prepared statements?
```
$sql = "SELECT * FROM table WHERE id=".$id;
$result = mysql_query($sql) or die(mysql_error())... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31245674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045858/"
] | To properly count rows with PDO you have to do this -
```
$result = $conn->prepare("SELECT * FROM table WHERE id= ?");
$result->execute(array($id));
$rows = $result->fetch(PDO::FETCH_NUM);
echo $rows[0];
```
But you would be better off using `LIMIT` in your query if all you want to do is get a static number of ... | As requested by the OP, here's an example of PDO prepared statements using LIMIT and OFFSET for pagination purposes. Please note i prefer to use bindValue() rather than passing parameters to execute(), but this is personal preference.
```
$pagesize = 7; //put this into a configuration file
$pagenumber = 3; // NOTE: ZE... |
31,245,674 | I'm in the process of updating my old mysql database techniques to prepared pdo statements. I'm all good with while loops `while($row = $result->fetch())` however how would I do the following with PDO prepared statements?
```
$sql = "SELECT * FROM table WHERE id=".$id;
$result = mysql_query($sql) or die(mysql_error())... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31245674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045858/"
] | You can try it this way:
```
$result = $conn->prepare("SELECT * FROM table WHERE id= ?");
$result->execute(array($id));
$loop_rows = $result->fetchAll();
$loop_count = count($loop_rows);
for($row=0;$row<7 && $loop_count-->0;$row++)
{
// Get next row
echo $loop_rows[$row]['field'];
}
``` | What you could try is:
```
//Get your page number for example 2
$pagenum = 2;
//Calculate the offset
$offset = 7 * $pagenum;
//Create array
$data = array();
$result = $conn->prepare("SELECT * FROM table WHERE id= ? LIMIT 7 OFFSET ?");
$result->bind_param("ii", $id,$offset);
... |
31,245,674 | I'm in the process of updating my old mysql database techniques to prepared pdo statements. I'm all good with while loops `while($row = $result->fetch())` however how would I do the following with PDO prepared statements?
```
$sql = "SELECT * FROM table WHERE id=".$id;
$result = mysql_query($sql) or die(mysql_error())... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31245674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045858/"
] | As requested by the OP, here's an example of PDO prepared statements using LIMIT and OFFSET for pagination purposes. Please note i prefer to use bindValue() rather than passing parameters to execute(), but this is personal preference.
```
$pagesize = 7; //put this into a configuration file
$pagenumber = 3; // NOTE: ZE... | What you could try is:
```
//Get your page number for example 2
$pagenum = 2;
//Calculate the offset
$offset = 7 * $pagenum;
//Create array
$data = array();
$result = $conn->prepare("SELECT * FROM table WHERE id= ? LIMIT 7 OFFSET ?");
$result->bind_param("ii", $id,$offset);
... |
12,419,217 | In my application I have class that is responsible for all database actions. It is called from main class and uses delegates to call methods after action is complete.
Because it is asynchronous I must use invoke on my GUI, so I've created a simple extensions method:
```
public static void InvokeIfRequired<T>(this T c... | 2012/09/14 | [
"https://Stackoverflow.com/questions/12419217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965722/"
] | This is because ToolStripItem (base for those two causing an error) is a Component and not a Control.
Try calling your extension method on the tool strip that owns them and adjust your delegate
methods. | I'd like to add up to the accepted solution. You can get the control from the component by using the GetCurrentParent method of the ToolStripStatusLabel.
Instead of doing `toolStripStatusLabel1.InvokeIfRequired`, do `toolStripStatusLabel1.GetCurrentParent().InvokeIfRequired` |
12,419,217 | In my application I have class that is responsible for all database actions. It is called from main class and uses delegates to call methods after action is complete.
Because it is asynchronous I must use invoke on my GUI, so I've created a simple extensions method:
```
public static void InvokeIfRequired<T>(this T c... | 2012/09/14 | [
"https://Stackoverflow.com/questions/12419217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965722/"
] | This is because ToolStripItem (base for those two causing an error) is a Component and not a Control.
Try calling your extension method on the tool strip that owns them and adjust your delegate
methods. | **Extension method using** `GetCurrentParent().InvokeRequired`
```
public static void ToolStripStatusInvokeAction<TControlType>(this TControlType control, Action<TControlType> del)
where TControlType : ToolStripStatusLabel
{
if (control.GetCurrentParent().InvokeRequired)
control.GetCurrentP... |
12,419,217 | In my application I have class that is responsible for all database actions. It is called from main class and uses delegates to call methods after action is complete.
Because it is asynchronous I must use invoke on my GUI, so I've created a simple extensions method:
```
public static void InvokeIfRequired<T>(this T c... | 2012/09/14 | [
"https://Stackoverflow.com/questions/12419217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965722/"
] | I'd like to add up to the accepted solution. You can get the control from the component by using the GetCurrentParent method of the ToolStripStatusLabel.
Instead of doing `toolStripStatusLabel1.InvokeIfRequired`, do `toolStripStatusLabel1.GetCurrentParent().InvokeIfRequired` | **Extension method using** `GetCurrentParent().InvokeRequired`
```
public static void ToolStripStatusInvokeAction<TControlType>(this TControlType control, Action<TControlType> del)
where TControlType : ToolStripStatusLabel
{
if (control.GetCurrentParent().InvokeRequired)
control.GetCurrentP... |
63,532,236 | I am having a situation with `strncmp` function in C, it is returning 0 even when the words do not match, in the example below, I am testing it with the letter 'R' and when running the code it returns 0 even when the compared word in the txt document is 'RUN'. Do you happen to know whether
Am I missing something in th... | 2020/08/22 | [
"https://Stackoverflow.com/questions/63532236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9407139/"
] | There are (at least) three ways to do this:
First, if it's on your path, you can simply rename it to `ctdir`.
Second, you can create an alias for it in your startup scripts (like `$HOME/.bashrc`):
```
alias ctdir='initialize_directory.sh'
```
Third, you can create a function to do the work (again, defining it in y... | Agreed with @paxdiablo, the best way is to create an alias.
Following steps will work in Linux:
1. Naming the alias.
Type the following at the command line:
`alias ctdir='initialize_directory.sh'`
2. Edit bashsrc file.
This file is usually present at your home directory.
Add at the alias mentioned in step 1 at the e... |
823,256 | I'm trying to setup a sane development environment after joining a new company that has projects running on 3 different PHP versions, without resorting to VM's (like Vagrant) or containers. I really hate those solutions.
Since i'm pretty much a Linux newbie, i have no idea on how to do this properly. I've setup some b... | 2016/12/29 | [
"https://serverfault.com/questions/823256",
"https://serverfault.com",
"https://serverfault.com/users/133672/"
] | Nowadays we have many kinds of \*brew scripts. You could try `phpbrew` <https://github.com/phpbrew/phpbrew> for different PHP versions. | There will be third party packages for various versions of PHP for the common distros. The advantage is other people use these builds and may be able to assist. On Debian, a fairly popular repository is <https://www.dotdeb.org/>
Switching between versions could get tricky, especially around the web server integration... |
7,053,293 | how to load a php file to just display the contents of the file, not executing it?
I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.
thanks | 2011/08/13 | [
"https://Stackoverflow.com/questions/7053293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820259/"
] | If you want nice colouring, try [highlight\_file()](http://php.net/manual/en/function.highlight-file.php). | A combination of [`fopen`](http://www.php.net/manual/en/function.fopen.php) and [`fpassthru`](http://www.php.net/manual/en/function.fpassthru.php) should do the trick. Don't forget to send appropriate headers first. Alternatively [`readfile`](http://www.php.net/manual/en/function.readfile.php). |
7,053,293 | how to load a php file to just display the contents of the file, not executing it?
I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.
thanks | 2011/08/13 | [
"https://Stackoverflow.com/questions/7053293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820259/"
] | If you're programming in php in order to view a PHP file, simply load the file into a string, then run it through [htmlentities](http://www.php.net/manual/en/function.htmlentities.php) before displaying it. It will escape all the html special characters and cause it to be displayed literally. | A combination of [`fopen`](http://www.php.net/manual/en/function.fopen.php) and [`fpassthru`](http://www.php.net/manual/en/function.fpassthru.php) should do the trick. Don't forget to send appropriate headers first. Alternatively [`readfile`](http://www.php.net/manual/en/function.readfile.php). |
7,053,293 | how to load a php file to just display the contents of the file, not executing it?
I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.
thanks | 2011/08/13 | [
"https://Stackoverflow.com/questions/7053293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820259/"
] | If you want nice colouring, try [highlight\_file()](http://php.net/manual/en/function.highlight-file.php). | If you're programming in php in order to view a PHP file, simply load the file into a string, then run it through [htmlentities](http://www.php.net/manual/en/function.htmlentities.php) before displaying it. It will escape all the html special characters and cause it to be displayed literally. |
7,053,293 | how to load a php file to just display the contents of the file, not executing it?
I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.
thanks | 2011/08/13 | [
"https://Stackoverflow.com/questions/7053293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820259/"
] | If you want nice colouring, try [highlight\_file()](http://php.net/manual/en/function.highlight-file.php). | If its just one large block, you could remove the tags..
otherwise, just rename the file to whatever.php.txt and load it in a browser.. |
7,053,293 | how to load a php file to just display the contents of the file, not executing it?
I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.
thanks | 2011/08/13 | [
"https://Stackoverflow.com/questions/7053293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820259/"
] | If you're programming in php in order to view a PHP file, simply load the file into a string, then run it through [htmlentities](http://www.php.net/manual/en/function.htmlentities.php) before displaying it. It will escape all the html special characters and cause it to be displayed literally. | If its just one large block, you could remove the tags..
otherwise, just rename the file to whatever.php.txt and load it in a browser.. |
31,264,963 | I am creating a Swing based GUI application. I want to run my jar file in ubuntu. And I dont want to install JRE in my system, but I have all jre files in a folder. So if I want to run jar/class file anything, I need to specify this folder path. How to do this? | 2015/07/07 | [
"https://Stackoverflow.com/questions/31264963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5060185/"
] | If you are using Eclipse you create a new runnable JAR file in the Eclipse workbench:
1. From the menu bar's File menu, select Export.
2. Expand the Java node and select Runnable JAR file. Click Next.
3. In the Opens the Runnable JAR export wizard Runnable JAR File Specification page, select a 'Java Application' launc... | Use
`$jar cvf sample.jar classone.class classtwo.class` |
48,702,276 | How can I clear the application context after each test execution, with Junit5 and Spring Boot? I want all beans created in the test to be destroyed after its execution, since I am creating the same beans in multiple tests. I don't want to have one configuration class for all tests, but configuration class per test, as... | 2018/02/09 | [
"https://Stackoverflow.com/questions/48702276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4826329/"
] | You have claimed twice that `@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)` does not work; however, the following shows that it works as documented.
```
import javax.annotation.PreDestroy;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith... | According to the [docs](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/test/annotation/DirtiesContext.html), try `@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)` |
61,205,223 | I have just written this code in which I have a form. You have to write your name, surname and country. You also have to choose your favourite colour. After that, you push a submit button so that you can see the data afterwards. I'm using the GET method with 1 page, but I have to use a second one with the POST method s... | 2020/04/14 | [
"https://Stackoverflow.com/questions/61205223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13045027/"
] | Assuming your objects have a getter for the id `getId()`, then you can make use of the [`Comparator.comparing()`](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#comparing-java.util.function.Function-) helper method, which creates a comparator for the provided lambda:
```
objectList.sort(Comparator... | Something that may look overkilling but it could be more natural to define a new class
```
class IndexedElement implments Comparable<Integer> {
private final int index;
private final YourObject element;
public IndexedElement(int index, YourObject element) {
this.index = index;
this.element =... |
29,728,495 | Is there a Rubier way to do
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
for empty arrays in Ruby, and empty relations in Rails | 2015/04/19 | [
"https://Stackoverflow.com/questions/29728495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972789/"
] | You would use this for arrays that might be empty or even `nil`:
```
Array(arr).map(&:do_something)
```
For relations in Rails it is just the following, because Rails' relations do not return `nil`:
```
relation.map(&:do_something)
``` | It's a good practice to avoid negative logic for a condition determination if possible. So instead of
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
you can write
```
if arr.present?
arr.map{|x| x.do_something}
end
```
Inclusion is always a faster operation than exclusion. |
29,728,495 | Is there a Rubier way to do
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
for empty arrays in Ruby, and empty relations in Rails | 2015/04/19 | [
"https://Stackoverflow.com/questions/29728495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972789/"
] | You would use this for arrays that might be empty or even `nil`:
```
Array(arr).map(&:do_something)
```
For relations in Rails it is just the following, because Rails' relations do not return `nil`:
```
relation.map(&:do_something)
``` | So if you have an array which may have nil values you can just use `Array#compact` which return array without nil values.
```
2.2.0 :013 > arr = [1, nil, "2"]
2.2.0 :014 > arr.compact
=> [1, "2"]
```
If the array is empty `#map` method won't have any side effects so you are safe and you don't have to check if arra... |
29,728,495 | Is there a Rubier way to do
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
for empty arrays in Ruby, and empty relations in Rails | 2015/04/19 | [
"https://Stackoverflow.com/questions/29728495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972789/"
] | You would use this for arrays that might be empty or even `nil`:
```
Array(arr).map(&:do_something)
```
For relations in Rails it is just the following, because Rails' relations do not return `nil`:
```
relation.map(&:do_something)
``` | You can shorten it to one line using `unless`. Also use [Symbol#to\_proc](https://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean) instead of explicit block:
```
arr.map(&:do_something) unless arr.blank?
``` |
29,728,495 | Is there a Rubier way to do
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
for empty arrays in Ruby, and empty relations in Rails | 2015/04/19 | [
"https://Stackoverflow.com/questions/29728495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972789/"
] | You can shorten it to one line using `unless`. Also use [Symbol#to\_proc](https://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean) instead of explicit block:
```
arr.map(&:do_something) unless arr.blank?
``` | It's a good practice to avoid negative logic for a condition determination if possible. So instead of
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
you can write
```
if arr.present?
arr.map{|x| x.do_something}
end
```
Inclusion is always a faster operation than exclusion. |
29,728,495 | Is there a Rubier way to do
```
if !arr.blank?
arr.map{|x| x.do_something}
end
```
for empty arrays in Ruby, and empty relations in Rails | 2015/04/19 | [
"https://Stackoverflow.com/questions/29728495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972789/"
] | You can shorten it to one line using `unless`. Also use [Symbol#to\_proc](https://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean) instead of explicit block:
```
arr.map(&:do_something) unless arr.blank?
``` | So if you have an array which may have nil values you can just use `Array#compact` which return array without nil values.
```
2.2.0 :013 > arr = [1, nil, "2"]
2.2.0 :014 > arr.compact
=> [1, "2"]
```
If the array is empty `#map` method won't have any side effects so you are safe and you don't have to check if arra... |
7,998,403 | I have written a C# tool that will launch an application by running a command in the command prompt for me several times, one after the other. The piece of code doing this for me is as follows:
```
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
```
So I have this in a loop and all is good. However each tim... | 2011/11/03 | [
"https://Stackoverflow.com/questions/7998403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678011/"
] | Yes, you have to use the `ProcessStartInfo` class for doing this:
```
Process.Start(
new ProcessStartInfo("CMD.exe", strCmdText)
{
CreateNoWindow = true
});
``` | Use `ProcessStartInfo` to start the process (`Start` has an overload that takes a `ProcessStartInfo`).
Set the following properties:
```
var psi = new ProcessStartInfo("cmd.exe", strCmdText);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
``` |
7,998,403 | I have written a C# tool that will launch an application by running a command in the command prompt for me several times, one after the other. The piece of code doing this for me is as follows:
```
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
```
So I have this in a loop and all is good. However each tim... | 2011/11/03 | [
"https://Stackoverflow.com/questions/7998403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678011/"
] | Yes, you have to use the `ProcessStartInfo` class for doing this:
```
Process.Start(
new ProcessStartInfo("CMD.exe", strCmdText)
{
CreateNoWindow = true
});
``` | ProcessStartInfo allows you to specify no window.
```
using (var p = new Process())
{
p.StartInfo = new ProcessStartInfo
{
FileName = "CMD.exe",
Arguments = strCmdText,
CreateNoWindow = true,
UseShellExecute = false
};
p.Start();
p.WaitForExit();
p.Close();
}
`... |
11,667,480 | I am trying to test PBE encryption/decryption. I found that PBE generates same key with different salt and iteration count. Of course, the password used is same.
As what I understand, same password and different salt/iteration should get different keys.
Below is my test code:
```
import java.security.Key;
import java.... | 2012/07/26 | [
"https://Stackoverflow.com/questions/11667480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1554249/"
] | You got spectacularly lucky, and your random salts and iteration counts just happened to match. Go directly to Las Vegas. Now. ;)
I googled for PBEWithSHA1andDESede and tracked down this example: <http://cryptofreek.org/2010/06/04/encrypting-and-decrypting-files-with-java> wherein he specifies the key alone with `new ... | If you use `PBKDF2WithHmacSHA1` instead of `PBEWithSHA1andDESede` your assumption works as it supports salt. You just need to add a the `keyLength` parameter to `PBEKeySpec`:
```
String algo = "PBKDF2WithHmacSHA1";
```
...
```
PBEKeySpec decPBESpec = new PBEKeySpec( password, salt, iterationCount, 1... |
69,457,828 | I'm setting up a multi-language dropdown toggle without server side access. It's for a WordPress site with Twig integrated, so the usual WP niceties for handling things like getting the home and path URLs are not available. With those limitations, jQuery seems to be the most workable solution.
Here's what I have so fa... | 2021/10/05 | [
"https://Stackoverflow.com/questions/69457828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7823753/"
] | Simply iterating over an array of `['/de', '/fr', '/es']` looks like it'd do the trick.
```
const langs = ['/de', '/fr', '/es'];
const lang = langs.find(substr => window.location.href.includes(substr));
const suffix = lang ? langDropPathname : langDropPathEN;
$(".langDropEN").attr('href', suffix);
$(".langDropDE").att... | you can match with a regular Expression
```js
const
langDropPathEN = window.location.pathname // path for default site
, langDropPathname = langDropPathEN.slice(3) // cut 2-letter country and slash from path for non-default sites
, LangDrop = { DE: '/de', FR: '/fr', ES: '/es' }
, LangRegEx = new Reg... |
88,967 | >
> Lethargic apprentices nesting dreary offices
>
> Foraging puzzles intermittently generally suffices
>
>
>
What is the one-word answer to the riddle above?
---
**HINT 1:**
>
> Convoluted as it is, the riddle is not meaningless and describes the answer.
>
>
>
**HINT 2:**
>
> What could be anothe... | 2019/09/11 | [
"https://puzzling.stackexchange.com/questions/88967",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/62211/"
] | Here's a guess:
>
> **BOREDOM**
>
>
>
Because:
>
> This satisfies the acrostic "Land of pigs" -> "boar - dom".
>
>
>
> The riddle itself paints a picture of people who are bored at work/school, occasionally solving puzzles to relieve their boredom.
>
>
> | How about:
>
> **GUINEA**
>
>
>
The words of the riddle form:
>
> An acrostic, spelling out **LAND OF PIGS**
>
>
>
I then reason that:
>
> A country (‘land’) whose name might fit this cryptic clue is Guinea, as in ‘Guinea pigs’. Not sure right now how this might relate to the title though…
>
>
> |
27,623,231 | Can I replace the text in the Title of `ghci` window (i.e. *PowerShell.exe* or *cmd.exe* window title)?
 | 2014/12/23 | [
"https://Stackoverflow.com/questions/27623231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1306132/"
] | The same way you execute any shell command - using `:!`.
```
> :!Title NewTitle
``` | Using `System.Process.callCommand` from the `process` package, you can call the `title` executable:
```
> :m System.Process
> callCommand "title A new title for the console window"
``` |
26,266,279 | I'm working to use custom checkbox styles with a checkbox which is dynamically generated by javascript for the Google Identity Toolkit. For example, we add this div:
```
<div id="gitkitWidgetDiv"></div>
```
And the Google Identity Toolkit script generates new html for that div.
I need to add a class to the HTML whi... | 2014/10/08 | [
"https://Stackoverflow.com/questions/26266279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234620/"
] | prepare a SQL file with the `insert`-statements you need and run it in the `BootStrap.groovy`:
```
class BootStrap {
def dataSource
def init = { servletContext ->
Sql sql = new Sql( dataSource )
new File( pathToSql ).eachLine{ sql.executeInsert it }
sql.commit()
sql.close()
}
}
```
is simple... | I would suggest you quite different approach. Create a service called e.g. **BootstrapInitialDataService** with one method called **initData()**. It's a good practice to extract an interface from that class (let's call it **InitialDataService**) so you can easily define different component bean for your development and... |
26,266,279 | I'm working to use custom checkbox styles with a checkbox which is dynamically generated by javascript for the Google Identity Toolkit. For example, we add this div:
```
<div id="gitkitWidgetDiv"></div>
```
And the Google Identity Toolkit script generates new html for that div.
I need to add a class to the HTML whi... | 2014/10/08 | [
"https://Stackoverflow.com/questions/26266279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234620/"
] | prepare a SQL file with the `insert`-statements you need and run it in the `BootStrap.groovy`:
```
class BootStrap {
def dataSource
def init = { servletContext ->
Sql sql = new Sql( dataSource )
new File( pathToSql ).eachLine{ sql.executeInsert it }
sql.commit()
sql.close()
}
}
```
is simple... | You can just add code in BootStrap.groovy under
`{project}/grails-app/init/{project}/BootStrap.groovy`
For example:
```
class BootStrap {
def init = { servletContext ->
// create a driver a save it in db
def user = new User(name: "juan")
driver.save()
}
def destroy = {
}
}
`... |
26,266,279 | I'm working to use custom checkbox styles with a checkbox which is dynamically generated by javascript for the Google Identity Toolkit. For example, we add this div:
```
<div id="gitkitWidgetDiv"></div>
```
And the Google Identity Toolkit script generates new html for that div.
I need to add a class to the HTML whi... | 2014/10/08 | [
"https://Stackoverflow.com/questions/26266279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234620/"
] | I would suggest you quite different approach. Create a service called e.g. **BootstrapInitialDataService** with one method called **initData()**. It's a good practice to extract an interface from that class (let's call it **InitialDataService**) so you can easily define different component bean for your development and... | You can just add code in BootStrap.groovy under
`{project}/grails-app/init/{project}/BootStrap.groovy`
For example:
```
class BootStrap {
def init = { servletContext ->
// create a driver a save it in db
def user = new User(name: "juan")
driver.save()
}
def destroy = {
}
}
`... |
1,063,795 | I am trying to install Tensorflow with GPU support on Ubuntu 16.04 64x for an conda environment with Python 3.6.
I tried installing all the [GPU requirements](https://www.tensorflow.org/install/install_sources#common_installation_problems) and then running `pip install --ignore-installed --upgrade https://storage.goog... | 2018/08/09 | [
"https://askubuntu.com/questions/1063795",
"https://askubuntu.com",
"https://askubuntu.com/users/522473/"
] | Cuda 9.0 can be installed with codes on the following tutorial
<https://www.tensorflow.org/install/gpu>
```
# Add NVIDIA package repository
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
wget http://developer.download.nvidia.com/compute/cuda/repos/... | Fixed! Turns out that the TF distro installed by default does not support CUDA 9.2. I downgraded to CUDA 9.0 and now it is tentatively working. |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | **I would suggest the following:**
>
> 1. Add a height constraint to your collection view.
> 2. Set its priority to 999.
> 3. Set its constant to any value that makes it reasonably visible on the storyboard.
> 4. Change the bottom equal constraint of the collection view to greater or equal.
> 5. Connect the height co... | first of all calculate number of cells than multiply it with height of cell and then return height in this method
```
collectionView.frame = CGRectMake (x,y,w,collectionView.collectionViewLayout.collectionViewContentSize.height); //objective c
//[collectionView reloadData];
collectionView.frame = CGRect(x: ... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | This seemed like the simplest solution for me.
```
class SelfSizingCollectionView: UICollectionView {
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
commonInit()
}
required init?(coder aDecoder: NSC... | If you set the height constraint of the collection view. Just observe the `contentSize` change in the viewDidLoad and update the constraint.
```
self.contentSizeObservation = collectionView.observe(\.contentSize, options: [.initial, .new]) { [weak self] collectionView, change in
guard let `self` = ... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | I ended up, by subclassing the `UICollectionView` and overriding some methods as follows.
* Returning `self.collectionViewLayout.collectionViewContentSize` for `intrinsicContentSize` makes sure, to always have the correct size
* Then just call it whenever it might change (like on `reloadData`)
Code:
```
override fun... | On your `UICollectionView` set your constraints such as `Trailing`, `Leading`, and `Bottom`:
[](https://i.stack.imgur.com/HXJeR.png)
If you look at my height constraint in more detail, as it is purely for storyboard look so I don't get errors, I have... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | 1) Set Fix Height of your CollectionView.
2) Create Outlet of this CollectionView Height Constant.
Like :
>
> IBOutlet NSLayoutConstraint \*constHeight;
>
>
>
3) Add below method in your .m file:
```
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat height = collectionMenu.collec... | 1. Subclass UICollectionView as follows
2. Delete height constraint if any
3. Turn on Intrinsic Size
-
```
class ContentSizedCollectionView: UICollectionView {
override var contentSize:CGSize {
didSet {
invalidateIntrinsicContentSize()
}
}
override var intrinsicContentSize: CG... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | I ended up, by subclassing the `UICollectionView` and overriding some methods as follows.
* Returning `self.collectionViewLayout.collectionViewContentSize` for `intrinsicContentSize` makes sure, to always have the correct size
* Then just call it whenever it might change (like on `reloadData`)
Code:
```
override fun... | Do following.
1. first set height constrain for `UICollectionView`
2. here `calendarBaseViewHeight` is `UICollectionView` height Variable
3. call the function after reload the collection view
```
func resizeCollectionViewSize(){
calendarBaseViewHeight.constant = collectionView.contentSize.height
}
``... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | You have to set height constraint as equal to content size
```
HeightConstraint.constant = collection.contentSize.height
``` | I have a multi-line, multi-selection `UICollectionView` subclass where the cells are of fixed height and left-aligned flowing from left to right. It's embedded in a vertical stack view that's inside a vertical scroll view. See the UI component below the label "Property Types".
[ to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | In Swift 5 and Xcode 10.2.1
My CollectionView name is **myCollectionView**
1. Fix height for your CollectionView
2. Create Outlet for your CollectionViewHeight
```
IBOutlet weak var myCollectionViewHeight: NSLayoutConstraint!
```
3. Use below code
```
override func viewDidLayoutSubviews() {
super.viewDidLayout... | Do following.
1. first set height constrain for `UICollectionView`
2. here `calendarBaseViewHeight` is `UICollectionView` height Variable
3. call the function after reload the collection view
```
func resizeCollectionViewSize(){
calendarBaseViewHeight.constant = collectionView.contentSize.height
}
``... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | 1) Set Fix Height of your CollectionView.
2) Create Outlet of this CollectionView Height Constant.
Like :
>
> IBOutlet NSLayoutConstraint \*constHeight;
>
>
>
3) Add below method in your .m file:
```
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat height = collectionMenu.collec... | I was using a UICollectionView in UITableView cell. For me, the following solution worked.
In parent view of collection view, I updated the height constraint in `layoutSubviews` method like this
```
override func layoutSubviews() {
heightConstraint.constant = myCollectionView.collectionViewLayout.collectionViewCo... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | I have a multi-line, multi-selection `UICollectionView` subclass where the cells are of fixed height and left-aligned flowing from left to right. It's embedded in a vertical stack view that's inside a vertical scroll view. See the UI component below the label "Property Types".
[
private let layout = UICollectionViewFlowLayout()
private lazy v... |
42,437,966 | I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is to use:
```
override func layoutSubviews() {
super.layoutSubviews()
if !__CGSizeEqualToSize(bounds.size, self.in... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42437966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4528594/"
] | **I would suggest the following:**
>
> 1. Add a height constraint to your collection view.
> 2. Set its priority to 999.
> 3. Set its constant to any value that makes it reasonably visible on the storyboard.
> 4. Change the bottom equal constraint of the collection view to greater or equal.
> 5. Connect the height co... | Do following.
1. first set height constrain for `UICollectionView`
2. here `calendarBaseViewHeight` is `UICollectionView` height Variable
3. call the function after reload the collection view
```
func resizeCollectionViewSize(){
calendarBaseViewHeight.constant = collectionView.contentSize.height
}
``... |
27,733,180 | I want to parse duration strings like
*1h30m40s* or *56m12s*
in PHP. I try the following the Regexp
```
^(\d+)h(\d+)m(\d+)s$
```
But it didn't work with strings like *56m12s*.
How can i make the the hours optional? | 2015/01/01 | [
"https://Stackoverflow.com/questions/27733180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4130452/"
] | You can place a [optional](http://www.regular-expressions.info/optional.html) non-capturing group around the given subpattern.
```
^(?:(\d+)h)?(\d+)m(\d+)s$
```
If you are just wanting to validate these strings, you can remove the unnecessary capture groups.
```
^(?:\d+h)?\d+m\d+s$
``` | Use the `?` for zero or one occurrence. No need for parentheses in the other parts of the regex:
```
^(\d+h)?\d+m\d+s$
``` |
15,767,695 | If I have the following...
```
List<string> listA = new List<string>();
listA.Add("a");
listA.Add("b");
listA.Add("c");
listA.Add("d");
List<string> listB = new List<string>();
listB.Add("b");
listB.Add("d");
```
How can I know if listA has everything listB has? | 2013/04/02 | [
"https://Stackoverflow.com/questions/15767695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040634/"
] | you could do it the raw (slow) way to make sure
```
bool contains_all = true;
foreach(String s in listA) {
if(!listB.Contains(s)) {
contains_all = false;
break;
}
}
```
although this does perform an exhaustive search on every element within the array | Try this:
```
bool result = listB.Intersect(listA).Count() == listB.Count;
```
And also this:
```
bool result2 = listB.Select(input => !listA.Contains(input)).Count() > 0;
``` |
15,767,695 | If I have the following...
```
List<string> listA = new List<string>();
listA.Add("a");
listA.Add("b");
listA.Add("c");
listA.Add("d");
List<string> listB = new List<string>();
listB.Add("b");
listB.Add("d");
```
How can I know if listA has everything listB has? | 2013/04/02 | [
"https://Stackoverflow.com/questions/15767695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040634/"
] | Using [`Enumerable.Except`](http://msdn.microsoft.com/en-us/library/bb300779.aspx)
```
bool allBinA = !listB.Except(listA).Any();
```
[**Demo**](http://ideone.com/ZtNcDi) | Try this:
```
bool result = listB.Intersect(listA).Count() == listB.Count;
```
And also this:
```
bool result2 = listB.Select(input => !listA.Contains(input)).Count() > 0;
``` |
15,767,695 | If I have the following...
```
List<string> listA = new List<string>();
listA.Add("a");
listA.Add("b");
listA.Add("c");
listA.Add("d");
List<string> listB = new List<string>();
listB.Add("b");
listB.Add("d");
```
How can I know if listA has everything listB has? | 2013/04/02 | [
"https://Stackoverflow.com/questions/15767695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040634/"
] | Using [`Enumerable.Except`](http://msdn.microsoft.com/en-us/library/bb300779.aspx)
```
bool allBinA = !listB.Except(listA).Any();
```
[**Demo**](http://ideone.com/ZtNcDi) | you could do it the raw (slow) way to make sure
```
bool contains_all = true;
foreach(String s in listA) {
if(!listB.Contains(s)) {
contains_all = false;
break;
}
}
```
although this does perform an exhaustive search on every element within the array |
15,767,695 | If I have the following...
```
List<string> listA = new List<string>();
listA.Add("a");
listA.Add("b");
listA.Add("c");
listA.Add("d");
List<string> listB = new List<string>();
listB.Add("b");
listB.Add("d");
```
How can I know if listA has everything listB has? | 2013/04/02 | [
"https://Stackoverflow.com/questions/15767695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040634/"
] | you could do it the raw (slow) way to make sure
```
bool contains_all = true;
foreach(String s in listA) {
if(!listB.Contains(s)) {
contains_all = false;
break;
}
}
```
although this does perform an exhaustive search on every element within the array | ```
bool result = false;
if (listB.Count>listA.Count) result = listB.Intersect(listA).Count() == listB.Count;
else result = listA.Intersect(listB).Count() == listA.Count;
``` |
15,767,695 | If I have the following...
```
List<string> listA = new List<string>();
listA.Add("a");
listA.Add("b");
listA.Add("c");
listA.Add("d");
List<string> listB = new List<string>();
listB.Add("b");
listB.Add("d");
```
How can I know if listA has everything listB has? | 2013/04/02 | [
"https://Stackoverflow.com/questions/15767695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040634/"
] | Using [`Enumerable.Except`](http://msdn.microsoft.com/en-us/library/bb300779.aspx)
```
bool allBinA = !listB.Except(listA).Any();
```
[**Demo**](http://ideone.com/ZtNcDi) | ```
bool result = false;
if (listB.Count>listA.Count) result = listB.Intersect(listA).Count() == listB.Count;
else result = listA.Intersect(listB).Count() == listA.Count;
``` |
52,101,758 | In this example I'm iterating over all possible variations of a mask, which I store as a list of booleans
```
Nmax = 32
for num in range (2**Nmax):
bool_list = [bool(num & (1<<n)) for n in range(Nmax)]
# other stuff
```
However, the operation to generate `bool_list` is a bit of a bottleneck in the code - the... | 2018/08/30 | [
"https://Stackoverflow.com/questions/52101758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2584425/"
] | You're just taking all combinations of (False, True) `Nmax` times. Hence,
```
from itertools
print(list(itertools.product(*[(False, True)]*Nmax)))
```
will display all the masks.
If you want to use it while iterating,
```
Nmax = 32
masks = itertools.product(*[(False, True)]*Nmax)
for mask in masks:
# Do stuff
... | For one, I think you can precompute the shifts:
```
Nmax = 32
shifts = [(1 << n) for n in range(Nmax)]
for num in range(2**Nmax):
bool_list = [bool(num & shift) for shift in shifts]
``` |
41,641,257 | I want to pass value of a input to a parent component. Currently I'm sending the whole input's `ElementRef`from my child component. Is there an elegant way to doing this? I mean, I need to send only one number, not a whole reference.
**Child Component:**
```
import { Component, ViewChild } from '@angular/core';
@Com... | 2017/01/13 | [
"https://Stackoverflow.com/questions/41641257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4661692/"
] | You can use EventEmitter and Output from angular/core to emit data from the child component to the parent, which the parent component can then handle through event binding. See [child to parent component interaction](https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#child-to-parent) in the Angul... | you can use [EventEmitter](https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#child-to-parent) to do this code is from the link shared so it can be easily reference please check this [link](https://angular.io/docs/ts/latest/cookbook/component-communication.html#) for more detail
>
> **Child Com... |
62,015,904 | I wonder if there is a way to access object properties as keys returned by asyncData()?
```
data() {
return {
bookmark_btn: {
status: null,
loading: false
}
}
}
```
I tried access data object properties like below but didn't work.
```
async asyncData(){
let activity = await a... | 2020/05/26 | [
"https://Stackoverflow.com/questions/62015904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use new fetch method instead of asyncData present in **Nuxt >= 2.12** . this fetch method can have data properties.
```
async fetch() {
let activity = await axios.get('data.json')
this.$set(this.bookmark_btn, 'status', activity.status)
}
```
Check out more in official docs <https://nuxtjs.org/api/pages-fetc... | As mentioned before, because `asyncData` is a server rendered method you can't directly access your components `data`.
Previous solution works but I don't think it's how things are intended to work with Nuxt and it's complicated (using a 3rd party lib Vuex and messing around context object).
According to the [API](ht... |
62,015,904 | I wonder if there is a way to access object properties as keys returned by asyncData()?
```
data() {
return {
bookmark_btn: {
status: null,
loading: false
}
}
}
```
I tried access data object properties like below but didn't work.
```
async asyncData(){
let activity = await a... | 2020/05/26 | [
"https://Stackoverflow.com/questions/62015904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | if you put data in store can you easily git this data to asyncData function
```js
export default {
state: () => ({
posts: [],
selectedPost: {},
page:3
}),
mutations: {
updatePosts(state, posts){
state.posts = posts;
},
updateSelectedPost(state, post){
state.selectedPost = post... | As mentioned before, because `asyncData` is a server rendered method you can't directly access your components `data`.
Previous solution works but I don't think it's how things are intended to work with Nuxt and it's complicated (using a 3rd party lib Vuex and messing around context object).
According to the [API](ht... |
52,488,834 | I have a table in the code to print, which looks like this:

When I tried to print the table, it's print format looks like this:

I need to change the font size of the text in the print view, and also alter the co... | 2018/09/25 | [
"https://Stackoverflow.com/questions/52488834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9186177/"
] | you can add a css tag using document.write and style the table as you want using the "print" media query.
function PrintPage() {
```
var TableToPrint = document.getElementById('thisIDisforprinting2');
newWin = window.open("");
newWin.document.write(TableToPrint.outerHTML);
newWin.document.write('<styl... | It looks like your Web page may use a width that exceeds the width limits for a printed page. You could try printing the page using the horizontal layout. |
30,531,895 | I'm trying to write a version of my C program in Ada. My C function call looks like this:
```c
void convert(const void* in, void* out){
MyType* convertedIn = (MyType*)in;
MyType* convertedOut = (MyType*)out;
//Assignments and operations to translate values across
//Example
convertedOut->meters = c... | 2015/05/29 | [
"https://Stackoverflow.com/questions/30531895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189943/"
] | ```ada
type Example is tagged null record;
procedure Convert (From : in Example'Class;
To : out Example'Class) is
begin
null; -- Implement conversion here
end Convert;
``` | I managed to get what I needed using System.Address and Ada.Unchecked\_Conversion. Below is my code:
```ada
with MyPackage;
type MyTypePtr is access MyType;
procedure Convert (From : in System.Address;
To : out System.Address) is
function ConvertAddressToMyType is new Ada.Unchecked_Conve... |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | Try this:
```
create table tbl1(id int primary key, dt datetime default current_timestamp);
```
Background:
>
> The DEFAULT constraint specifies a
> default value to use when doing an
> INSERT. The value may be NULL, a
> string constant, a number, or a
> constant expression enclosed in
> parentheses. The defa... | ```
... default (datetime(current_timestamp))
```
The expression following `default` must be in parentheses. This form is useful if you want to perform date arithmetic using [SQLite date and time functions or modifiers](http://www.sqlite.org/lang_datefunc.html). |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | Try this:
```
create table tbl1(id int primary key, dt datetime default current_timestamp);
```
Background:
>
> The DEFAULT constraint specifies a
> default value to use when doing an
> INSERT. The value may be NULL, a
> string constant, a number, or a
> constant expression enclosed in
> parentheses. The defa... | `CURRENT_TIMESTAMP` is a literal-value just like `'mystring'`
**column-constraint:**

**literal-value:**
 |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | Try this:
```
create table tbl1(id int primary key, dt datetime default current_timestamp);
```
Background:
>
> The DEFAULT constraint specifies a
> default value to use when doing an
> INSERT. The value may be NULL, a
> string constant, a number, or a
> constant expression enclosed in
> parentheses. The defa... | you can use the following query for using current date value in your table
```
create table tablename (date_field_name Created_on default CURRENT_DATE);
``` |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | ```
... default (datetime(current_timestamp))
```
The expression following `default` must be in parentheses. This form is useful if you want to perform date arithmetic using [SQLite date and time functions or modifiers](http://www.sqlite.org/lang_datefunc.html). | `CURRENT_TIMESTAMP` is a literal-value just like `'mystring'`
**column-constraint:**

**literal-value:**
 |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | ```
... default (datetime(current_timestamp))
```
The expression following `default` must be in parentheses. This form is useful if you want to perform date arithmetic using [SQLite date and time functions or modifiers](http://www.sqlite.org/lang_datefunc.html). | you can use the following query for using current date value in your table
```
create table tablename (date_field_name Created_on default CURRENT_DATE);
``` |
2,614,496 | I have the following table:
```
create table ARDebitDetail(ID_ARDebitDetail int identity,
ID_Hearing int, ID_AdvancedRatePlan int)
```
I am trying to get the latest ID\_AdvancedRatePlan based on a ID\_Hearing. By latest I mean with the largest ID\_ARDebitDetail. I have this query and it works fine... | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | `CURRENT_TIMESTAMP` is a literal-value just like `'mystring'`
**column-constraint:**

**literal-value:**
 | you can use the following query for using current date value in your table
```
create table tablename (date_field_name Created_on default CURRENT_DATE);
``` |
57,756,217 | Is it possible to "fail" the release if there are nugget packages in pre-release versions?
Maybe there is a task already for this in Azure DevOps, or maybe there's a way to do it with Powershell? | 2019/09/02 | [
"https://Stackoverflow.com/questions/57756217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6950766/"
] | You can read the `.csproj` file with PowerShell and check if pre-release exist, if yes make an error:
```
[xml]$csproj = Get-Content path/to/csproj/file # e.g. $(Agent.ReleaseDirectory)/myproject/myproject.csproj
$versions = $csproj.Projects.ItemGroup.PackageReference.Version
$versions.ForEach({
# Pre-releases are... | A solution (if you want to take packets from SLN file) for this can be the following:
```
Get-Content .\SolutionName.sln |
where { $_ -match "Project.+, ""(.+)""," } |
foreach { $matches[1] } |
% { Get-Content $_ -ErrorAction SilentlyContinue |
Find "<PackageReference Include" } |
Sort-Object -Unique |
% { if($_ -matc... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | This code working for me.
```
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Your App Name"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version... | I also add a formatted date to my build. In first place I used some kind of "now" with `new Date()`, but this leads to trouble when starting the build with Android Studio, like in one of the comments above. I decided to use the timestamp of the latest commit. I found some inspiration here: <https://jdpgrailsdev.github.... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | This code working for me.
```
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Your App Name"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version... | This is mine hope to help you
```
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(
(String) file.parent,
(String) file.name.replace(
file.name,
... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | I'm assuming that you want it in the format you specified, so here's one possible solution.
In your gradle file you can define a new function to get the date time string like you desire:
```
import java.text.DateFormat
import java.text.SimpleDateFormat
def getDateTime() {
DateFormat df = new SimpleDateFormat("yy... | I also add a formatted date to my build. In first place I used some kind of "now" with `new Date()`, but this leads to trouble when starting the build with Android Studio, like in one of the comments above. I decided to use the timestamp of the latest commit. I found some inspiration here: <https://jdpgrailsdev.github.... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | I'm assuming that you want it in the format you specified, so here's one possible solution.
In your gradle file you can define a new function to get the date time string like you desire:
```
import java.text.DateFormat
import java.text.SimpleDateFormat
def getDateTime() {
DateFormat df = new SimpleDateFormat("yy... | You can just add the code below inside the `defaultConfig` section located in `android` section.
```
setProperty("archivesBaseName", "yourData-$versionName " + (new Date().format("HH-mm-ss")))
```
Inspired by [enter link description here](https://stackoverflow.com/a/28992851/6940373) |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | This code working for me.
```
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Your App Name"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version... | An alternative solution is to set `$dateTime` property in `defaultConfig` as shown below:
```
defaultConfig {
setProperty("archivesBaseName", "Appname-$dateTime-v$versionName")
}
``` |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | This code working for me.
```
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Your App Name"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version... | You can just add the code below inside the `defaultConfig` section located in `android` section.
```
setProperty("archivesBaseName", "yourData-$versionName " + (new Date().format("HH-mm-ss")))
```
Inspired by [enter link description here](https://stackoverflow.com/a/28992851/6940373) |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | I'm assuming that you want it in the format you specified, so here's one possible solution.
In your gradle file you can define a new function to get the date time string like you desire:
```
import java.text.DateFormat
import java.text.SimpleDateFormat
def getDateTime() {
DateFormat df = new SimpleDateFormat("yy... | This is mine hope to help you
```
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(
(String) file.parent,
(String) file.name.replace(
file.name,
... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | I'm assuming that you want it in the format you specified, so here's one possible solution.
In your gradle file you can define a new function to get the date time string like you desire:
```
import java.text.DateFormat
import java.text.SimpleDateFormat
def getDateTime() {
DateFormat df = new SimpleDateFormat("yy... | This code working for me.
```
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Your App Name"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def version... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | I also add a formatted date to my build. In first place I used some kind of "now" with `new Date()`, but this leads to trouble when starting the build with Android Studio, like in one of the comments above. I decided to use the timestamp of the latest commit. I found some inspiration here: <https://jdpgrailsdev.github.... | This is mine hope to help you
```
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(
(String) file.parent,
(String) file.name.replace(
file.name,
... |
29,006,403 | I want to create a simple header/content/footer layout as was asked hundreds of times already, and I found one that I really like. I have create [a jsFiddle](http://jsfiddle.net/f5Lhsqdt/2/) that showcases the approach. Everything works fine except for the `<footer>` tag.
Basically, I have tried to use a `footerElemen... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29006403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726428/"
] | An alternative solution is to set `$dateTime` property in `defaultConfig` as shown below:
```
defaultConfig {
setProperty("archivesBaseName", "Appname-$dateTime-v$versionName")
}
``` | You can just add the code below inside the `defaultConfig` section located in `android` section.
```
setProperty("archivesBaseName", "yourData-$versionName " + (new Date().format("HH-mm-ss")))
```
Inspired by [enter link description here](https://stackoverflow.com/a/28992851/6940373) |
67,132,971 | How can I define a type that is the subclass of another class (including the static methods on the parent class)?
### Simplified Example
Let's say I have two abstract base classes and two concrete subclasses (one for each):
```js
abstract class BaseEntity {
foo?: string;
static init<T extends BaseEntity>(this: ... | 2021/04/16 | [
"https://Stackoverflow.com/questions/67132971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | Maybe you could try it with a generic type `BaseEntityConstructor` to represent the static part? (See for example this [blog post](https://www.javaer101.com/en/article/15573960.html))
If you define
```
interface BaseEntityConstructor<T extends BaseEntity> {
new (): T;
init(this: new () => T, data: Partial<T>): T... | So I ended up coming up with this:
```
type ConstructorType<T = any> = new (...args: any[]) => T;
type BaseEntityType<T> = ConstructorType<T> & {
[K in keyof typeof BaseEntity]: (typeof BaseEntity)[K]
}
```
Which basically defines a generic constructor function type `ConstructorType<T>` and then defines a combina... |
59,577,562 | I am tring to use a map to get words from a string and map them to a widget.
I have tried this but my problem is the key for the words doe and sister get the same keys so i end up getting only one of them
String theText = "my name is doe from `http.doe.com`, my sister is selly. doe and saqil are not sister friends of ... | 2020/01/03 | [
"https://Stackoverflow.com/questions/59577562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9398610/"
] | You are forcing them to be a single column. Joining the two into a single string means Python no longer regards them as separate.
But try this instead:
```py
import csv
import operator
with open('bad_voice_ports.csv') as readfile, open('bad_voice_portsnew20200103SORTED.csv', 'w') as writefile:
readCSV = csv.read... | So my suggestion is failry simple. As i stated in a previous comment there is good documentation on CSV read and write in python here: <https://realpython.com/python-csv/>
As per an example, to read from a csv the columns you need you can simply do this:
```
>>> file = open('some.csv', mode='r')
>>> csv_reader = csv... |
59,577,562 | I am tring to use a map to get words from a string and map them to a widget.
I have tried this but my problem is the key for the words doe and sister get the same keys so i end up getting only one of them
String theText = "my name is doe from `http.doe.com`, my sister is selly. doe and saqil are not sister friends of ... | 2020/01/03 | [
"https://Stackoverflow.com/questions/59577562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9398610/"
] | You are forcing them to be a single column. Joining the two into a single string means Python no longer regards them as separate.
But try this instead:
```py
import csv
import operator
with open('bad_voice_ports.csv') as readfile, open('bad_voice_portsnew20200103SORTED.csv', 'w') as writefile:
readCSV = csv.read... | You can use `sorted`:
```
import csv
_h, *data = csv.reader(open('filename.csv'))
with open('new_csv.csv', 'w') as f:
write = csv.writer(f)
csv.writerows([_h, *sorted([(i[1], i[4]) for i in data], key=lambda x:x[0])])
``` |
59,577,562 | I am tring to use a map to get words from a string and map them to a widget.
I have tried this but my problem is the key for the words doe and sister get the same keys so i end up getting only one of them
String theText = "my name is doe from `http.doe.com`, my sister is selly. doe and saqil are not sister friends of ... | 2020/01/03 | [
"https://Stackoverflow.com/questions/59577562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9398610/"
] | You are forcing them to be a single column. Joining the two into a single string means Python no longer regards them as separate.
But try this instead:
```py
import csv
import operator
with open('bad_voice_ports.csv') as readfile, open('bad_voice_portsnew20200103SORTED.csv', 'w') as writefile:
readCSV = csv.read... | After the help from @tripleee and @marxmacher my final code is
```
import csv
import operator
from collections import Counter
with open('bad_voice_ports.csv') as csv_file:
readCSV = csv.reader(csv_file, delimiter=',')
sortedlist = sorted(readCSV, key=operator.itemgetter(1))
line_count = 0
rows = []
... |
59,577,562 | I am tring to use a map to get words from a string and map them to a widget.
I have tried this but my problem is the key for the words doe and sister get the same keys so i end up getting only one of them
String theText = "my name is doe from `http.doe.com`, my sister is selly. doe and saqil are not sister friends of ... | 2020/01/03 | [
"https://Stackoverflow.com/questions/59577562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9398610/"
] | So my suggestion is failry simple. As i stated in a previous comment there is good documentation on CSV read and write in python here: <https://realpython.com/python-csv/>
As per an example, to read from a csv the columns you need you can simply do this:
```
>>> file = open('some.csv', mode='r')
>>> csv_reader = csv... | You can use `sorted`:
```
import csv
_h, *data = csv.reader(open('filename.csv'))
with open('new_csv.csv', 'w') as f:
write = csv.writer(f)
csv.writerows([_h, *sorted([(i[1], i[4]) for i in data], key=lambda x:x[0])])
``` |
59,577,562 | I am tring to use a map to get words from a string and map them to a widget.
I have tried this but my problem is the key for the words doe and sister get the same keys so i end up getting only one of them
String theText = "my name is doe from `http.doe.com`, my sister is selly. doe and saqil are not sister friends of ... | 2020/01/03 | [
"https://Stackoverflow.com/questions/59577562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9398610/"
] | After the help from @tripleee and @marxmacher my final code is
```
import csv
import operator
from collections import Counter
with open('bad_voice_ports.csv') as csv_file:
readCSV = csv.reader(csv_file, delimiter=',')
sortedlist = sorted(readCSV, key=operator.itemgetter(1))
line_count = 0
rows = []
... | You can use `sorted`:
```
import csv
_h, *data = csv.reader(open('filename.csv'))
with open('new_csv.csv', 'w') as f:
write = csv.writer(f)
csv.writerows([_h, *sorted([(i[1], i[4]) for i in data], key=lambda x:x[0])])
``` |
40,056 | I'm curious about the process of getting a Xbox 360 dev-kit.
What are the requirements? Do you have to have a track record in game development. Can indie gamers get one. How much does it cost? Is there special hardware? | 2012/10/16 | [
"https://gamedev.stackexchange.com/questions/40056",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/4568/"
] | Basically, [RTFM](http://www.xbox.com/en-US/developers/faq#developer).
So either you work for a *certified Xbox 360 publisher*, and/or you're already in contact with a *Developer Account Manager*, but that would mean that you're already an established developer so you wouldn't be asking this question.
Or you request ... | You need to have money and you need to have a publisher with several published AAA titles.
It is indeed a special piece of hardware - nowadays not so much because of the actual hardware (which is slightly different), but because it gives you more freedom when running games (dev mode, debugging, etc.)
It's pretty poin... |
283,587 | I am working on CSV import to add custom attribute data for Products. I have created a custom attribute as "slide\_link". I am unable to add only SKU and slide\_link in CSV for adding data of attribute in the product.
Please provide a solution for above. | 2019/07/29 | [
"https://magento.stackexchange.com/questions/283587",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/73013/"
] | Please analyse below demo its working to update price and qty using sku ( specific SKU ) via CSV, I hope its helpful to you.. ( its just idea how to work in magento2 )
```
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::cr... | I am not sure why stock info is present in code of previous answer. There are easier, and surely faster, ways to update attributes values (but depending by the attribute type it could need some extra code)
Using **\Magento\Catalog\Model\ResourceModel\Product\Action** & **\Magento\Catalog\Model\Product\Attribute\Reposi... |
42,233,977 | I want to save this data in JSON format without using PHP ,when user give the value and press send ,its data add in JSON so that ,I can use this JSON as Database.
```
<!DOCTYPE html>
<html>
<body>
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last nam... | 2017/02/14 | [
"https://Stackoverflow.com/questions/42233977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4345342/"
] | You can iterate through your form and collect it's values in an array, which you can encode in JSON format.
```
<!DOCTYPE html>
<html>
<body>
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mous... | ```
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
function stringifyForm(formObject)
{
var jsonObject = {};
var inputElements = formObject.getElementsByTagName("inp... |
1,519,002 | Background
----------
I want to obtain the `pid` of a specific Terminal window.
```
ps -A | grep -w Terminal.app | grep -v grep | awk '{print $1}'
```
However, the above grabs the `pid` of the entire application and not of a specific tab or window that is running.
In Linux, one could execute the following:
```
x-... | 2020/01/21 | [
"https://superuser.com/questions/1519002",
"https://superuser.com",
"https://superuser.com/users/684201/"
] | Use `echo $$`. Mac OS is a unixy box and so $$ is an alias for myPid.
As you can see I am first showing all the shells (I use zsh) running at the moment. Below that you can see that `echo $$` shows the PID of the pre-existing shell and not something new.
`~ % ps aux | grep zsh
ram 30724 0.8 0.0 4869828 5888 s003 S 9:... | Invoking your *terminal.sh* script using `./terminal.sh "cd $HOME ; sleep 1000"` you can get the PID of the window opened which is running the `sleep` command using this:
```
ps ax | \
grep 'sleep 1000' | \
grep -v grep | \
grep -v ./terminal.sh | \
awk '{print $1}'
```
If you try `ps ax | grep '... |
22,114,292 | In swing application, I am using `DefaultTableCellRenderer` to flash the table cell when the cell time is equal to system time. I wrote if statement to compare cell time with `hh:mm` , If both time are equal, time cells backgroung will blink on the table rows. It is blinking 60 secs only still if statement is true, But... | 2014/03/01 | [
"https://Stackoverflow.com/questions/22114292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2034750/"
] | The code is indeed rather confusing. For example, it is not clear what the *condition* for the blinking should be. At the moment, it seems like the condition is that a particular cell displays the current time (as obtained from a calendar instance). However, making this decision in the `CellRenderer` is highly dubious.... | Create another column of data to store in the TableModel that contains a Boolean value. The data should only be in the model, but the column should NOT be displayed in the JTable.
Then your logic can set the Boolean value to Boolean.TRUE whenever the times are the same. Once the value is true you never set it false. T... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.