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 |
|---|---|---|---|---|---|
40,493 | The title really says it all, but when I use the @ character to ignore escapes in a string literal @"Like This\", the \" is interpreted as a quote character belonging to the string rather than the terminating quote. | 2010/02/25 | [
"https://meta.stackexchange.com/questions/40493",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/135806/"
] | That's an issue with [google-code-prettify](http://code.google.com/p/google-code-prettify/), which Stack Overflow uses, and is not something the Stack Overflow team are likely to remedy.
That said, google-code-prettify is open-source - so feel free to go fix it! | Testing
```
string test1 = @"Like This\";
string test2 = "Like This\\";
``` |
4,619,481 | I'd like to return to college, which I had to leave due to money constraints, but now I'm preparing myself for real analysis. In my exercise book, there is a problem for showing an inequality:
$\forall x,x\_1,...,x\_n \in \mathbb{R}; n \in \mathbb{N}: |x+x\_1+...+x\_n| \geq |x|-(|x\_1|+...+|x\_n|)$
I have spent yeste... | 2023/01/16 | [
"https://math.stackexchange.com/questions/4619481",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1139309/"
] | **Hint**. If $y = x\_1+x\_2+\dots+x\_n$, we have
$$|x+y| \geqslant |x| - |y|$$
$$|x\_1|+|x\_2|+\dots+|x\_n| \geqslant |y|$$
both by triangle inequality. | You go by induction. First prove that for $x,x\_1$ it holds $|x+x\_1| \geq |x|- |x\_1|$, and this is simply the triangle inequality (or reversed triangle inequality if you like). Then consider $x, x\_1, \dots,x\_n, x\_{n+1}$ assuming you have the thesis for $n$ numbers instead of $n+1$.
Consider $x, x\_1, \dots, x\_{n... |
67,176,650 | I am attempting to filter rows in a BigQuery table with a repeated string field.
I want to filter based on rows that have at least one value from one predefined list, but does not contain any values from a second predefined list.
This is my query:
```sql
SELECT em.asin, em.category
FROM
`my_proj.amaz... | 2021/04/20 | [
"https://Stackoverflow.com/questions/67176650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3623641/"
] | you can filter rows with `Online`, remove it by `replace` and filter out this rows in [`Series.isin`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.isin.html) (solution not working per groups):
```
vals = df.loc[df['name'].str.contains(' Online'), 'name'].str.replace(' Online','')
df = df[~d... | One possible way to solve it is to create a temporary column that checks if 'online' exists in any of the values in `name` per `code`, then filter out those rows:
```
(df.assign(online = df['name'].str.contains('Online'),
checker = lambda df: df.groupby('code').online.transform('sum'))
.loc[lambda df: ~... |
5,760,419 | I'm building dynamic filters which I pass by GET to a queryset filter:
```
for k, v in request.GET.iteritems():
kwargs[str(k)] = str(v)
students = models.Student.objects.filter( **kwargs )
```
and it's working for almost all the queries I'm throwing at it. However, I have a related model with a manytomany relati... | 2011/04/22 | [
"https://Stackoverflow.com/questions/5760419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335084/"
] | Maybe I don't understand the question. But I see:
```
list(MyMod.objects.exclude(foo__isnull=False)
) == list(MyMod.objects.filter(foo__isnull=True))
``` | I think `models.Student.objects.filter(groups__isnull=True)` should do what you want. As skyl pointed out, this is the same as `models.Student.objects.exclude(groups__isnull=False)`.
What's the problem with this solution? Could it be in your data? As a sanity check you could try
```
from django.db.models import Coun... |
5,760,419 | I'm building dynamic filters which I pass by GET to a queryset filter:
```
for k, v in request.GET.iteritems():
kwargs[str(k)] = str(v)
students = models.Student.objects.filter( **kwargs )
```
and it's working for almost all the queries I'm throwing at it. However, I have a related model with a manytomany relati... | 2011/04/22 | [
"https://Stackoverflow.com/questions/5760419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335084/"
] | Maybe I don't understand the question. But I see:
```
list(MyMod.objects.exclude(foo__isnull=False)
) == list(MyMod.objects.filter(foo__isnull=True))
``` | ```
students = models.Student.objects.filter(groups=None)
```
Here is an example from some code i have lying around:
```
# add collaborator with no organizations
>>> john = Collaborator(first_name='John', last_name='Doe')
>>> john.save()
>>> john.organizations.all()
[]
# add another collabor... |
30,697,666 | I have two tables players and scores.
On the player table I have two fields, name and id (PK)
On the scores I have several fields [id\_score(PK),winner and looser are foreign key to the id of the player]
id tournament and id match.
```
Players
id_players | name
------------+-----------
41 | Antonia
... | 2015/06/07 | [
"https://Stackoverflow.com/questions/30697666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1876345/"
] | The ordering works as it should. The problem is you are asking it to order by `s.winner` which refers to the ID of the winning player. If you want to order them based on most wins, you need to use `ORDER BY wins DESC`, maybe with a secondary order clause for ties. Then the rows would start with the player with maximum ... | Sometimes, it is easier to use subqueries:
```
select p.*,
(select count(*)
from scores s
where p.id_players in (s.winner, s.loser)
) as GamesPlayed,
(select count(*)
from scores s
where p.id_players in (s.winner)
) as GamesWon
from players p
order by GamesWo... |
35,171,310 | This question was asked in similar ways multiple times, for example at [stackoverflow](https://stackoverflow.com/questions/33544120/memory-violation-sigsegv-and-cant-find-linker-symbol-for-virtual-table) or [forum.qt.io](http://forum.qt.io/topic/4457/can-t-find-linker-symbol-for-virtual-table/12) or [qtcentre.org](http... | 2016/02/03 | [
"https://Stackoverflow.com/questions/35171310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104425/"
] | You can save the index to a session variable and then read it back on post back like this:
To save:
```
Session["index"] = index.ToString();
```
Read it on page load like this:
```
Index = Session["index"];
```
You will need the session variable to maintain state per user session. If you want to maintain state f... | Hi add the following code in your page\_load event.
```
if(!Page.IsPostBack)
{
multiview.ActiveViewIndex=0;
}
``` |
35,171,310 | This question was asked in similar ways multiple times, for example at [stackoverflow](https://stackoverflow.com/questions/33544120/memory-violation-sigsegv-and-cant-find-linker-symbol-for-virtual-table) or [forum.qt.io](http://forum.qt.io/topic/4457/can-t-find-linker-symbol-for-virtual-table/12) or [qtcentre.org](http... | 2016/02/03 | [
"https://Stackoverflow.com/questions/35171310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104425/"
] | You can save the index to a session variable and then read it back on post back like this:
To save:
```
Session["index"] = index.ToString();
```
Read it on page load like this:
```
Index = Session["index"];
```
You will need the session variable to maintain state per user session. If you want to maintain state f... | i think you are setting the multiview's active index to zero on every post back like follows
```
protected void Page_Load(object sender, EventArgs e)
{
multiview.ActiveViewIndex=0;
}
```
this will cause the multiview to set active index as 0 on every post back.To avoid this you have to set it as follows
```
pr... |
43,802,591 | I'm not sure if I may ask questions like this here, but I'll try.
I have multiple files. The file name has the following pattern:
`Lorem_Ipsum1054.html`
The `Lorem_Ipsum` isn't fixed in length. Using [Better Rename 10](https://itunes.apple.com/app/better-rename-10/id1063663640?mt=12) I want to change the file name a... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43802591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use the following steps:
1. Use `File.ReadAllLines()` to get a `string[]`, where each element represents one line of the file.
2. For each line, use `string.Split()` and chop your line into individual words. Use both space and parentheses as your delimiters. This will give you an array of words. Call it `arr`.
3. Now ... | You have to use Regex, you may have a look [here](https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx) as a starting point. so for example to get the first word you may use this
```
string data = "Example 2323 Second This is a Phrase 2017-01-01 2019-01-03";
string firstword = new Regex(@"\b[A-Za-z]+\... |
43,802,591 | I'm not sure if I may ask questions like this here, but I'll try.
I have multiple files. The file name has the following pattern:
`Lorem_Ipsum1054.html`
The `Lorem_Ipsum` isn't fixed in length. Using [Better Rename 10](https://itunes.apple.com/app/better-rename-10/id1063663640?mt=12) I want to change the file name a... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43802591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You need a loop and `string`- and `TryParse`-methods:
```
var list = new List<ClassName>();
foreach (string line in File.ReadLines(path).Where(l => !string.IsNullOrEmpty(l)))
{
string[] fields = line.Trim().Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length < 5) continue;
var ... | You have to use Regex, you may have a look [here](https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx) as a starting point. so for example to get the first word you may use this
```
string data = "Example 2323 Second This is a Phrase 2017-01-01 2019-01-03";
string firstword = new Regex(@"\b[A-Za-z]+\... |
43,802,591 | I'm not sure if I may ask questions like this here, but I'll try.
I have multiple files. The file name has the following pattern:
`Lorem_Ipsum1054.html`
The `Lorem_Ipsum` isn't fixed in length. Using [Better Rename 10](https://itunes.apple.com/app/better-rename-10/id1063663640?mt=12) I want to change the file name a... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43802591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The following regular expression seems to cover what I imagine you would need - at least a good start.
```
^(?<firstWord>[\w\s]*)\s+(?<secondWord>\d+)\s+(?<thirdWord>[\w\s_-]+)\s+(?<date>\d{4}-\d{2}-\d{2})\s+(?<time>\d{2}:\d{2}:\d{2})$
```
This captures 5 named groups
* `firstWord` is any alphanumeric or whitespace... | You have to use Regex, you may have a look [here](https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx) as a starting point. so for example to get the first word you may use this
```
string data = "Example 2323 Second This is a Phrase 2017-01-01 2019-01-03";
string firstword = new Regex(@"\b[A-Za-z]+\... |
43,802,591 | I'm not sure if I may ask questions like this here, but I'll try.
I have multiple files. The file name has the following pattern:
`Lorem_Ipsum1054.html`
The `Lorem_Ipsum` isn't fixed in length. Using [Better Rename 10](https://itunes.apple.com/app/better-rename-10/id1063663640?mt=12) I want to change the file name a... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43802591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use the following steps:
1. Use `File.ReadAllLines()` to get a `string[]`, where each element represents one line of the file.
2. For each line, use `string.Split()` and chop your line into individual words. Use both space and parentheses as your delimiters. This will give you an array of words. Call it `arr`.
3. Now ... | You need a loop and `string`- and `TryParse`-methods:
```
var list = new List<ClassName>();
foreach (string line in File.ReadLines(path).Where(l => !string.IsNullOrEmpty(l)))
{
string[] fields = line.Trim().Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length < 5) continue;
var ... |
43,802,591 | I'm not sure if I may ask questions like this here, but I'll try.
I have multiple files. The file name has the following pattern:
`Lorem_Ipsum1054.html`
The `Lorem_Ipsum` isn't fixed in length. Using [Better Rename 10](https://itunes.apple.com/app/better-rename-10/id1063663640?mt=12) I want to change the file name a... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43802591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use the following steps:
1. Use `File.ReadAllLines()` to get a `string[]`, where each element represents one line of the file.
2. For each line, use `string.Split()` and chop your line into individual words. Use both space and parentheses as your delimiters. This will give you an array of words. Call it `arr`.
3. Now ... | The following regular expression seems to cover what I imagine you would need - at least a good start.
```
^(?<firstWord>[\w\s]*)\s+(?<secondWord>\d+)\s+(?<thirdWord>[\w\s_-]+)\s+(?<date>\d{4}-\d{2}-\d{2})\s+(?<time>\d{2}:\d{2}:\d{2})$
```
This captures 5 named groups
* `firstWord` is any alphanumeric or whitespace... |
9,516 | It seems to be common on the web to provide users with some visual element on the page to either print or bookmark a page. This is all well and good (and probably doesn't hurt for the most part), but I question its effectiveness at causing the intended behavior.
Is there any evidence to suggest that this causes an inc... | 2011/02/21 | [
"https://webmasters.stackexchange.com/questions/9516",
"https://webmasters.stackexchange.com",
"https://webmasters.stackexchange.com/users/639/"
] | I don't think you're going to find any actual hard data on this as there is no way to tell if anyone uses these links without actually looking over their shoulder (or installing spyware on all of your users' computers).
I don't know if they increase in bookmarking or printing but I don't think that matters. What it b... | Of course they are used. The user may intend to print the page anyway, but you have made it easier for him.
If you intend to implement it make sure to track everything.
Use GA for event tracking to track the clicks on "Add to Favorites" or "print this".
Use GA to track the links by adding tags to your links, then view... |
55,685,115 | I have a list of UI Buttons and Vector2 for positions. I am using random.range to place buttons randomly every time i load them. But it never shows all 5 buttons at different positions. instead overlapping some of them. Can anyone please help me with this?
```
[SerializeField] List<Button> answersButtons = new List<Bu... | 2019/04/15 | [
"https://Stackoverflow.com/questions/55685115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10760576/"
] | You are setting the `window.onclick` property twice, so you are overwriting the first one. That's why when you open the first menu and then the second, the first one stays open - because the first `window.onclick` doesn't exist anymore.
My advise is to refactor the code, so that you have only one `window.onclick` hand... | * Avoid **[on-event attribute](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers)**
>
> `<button` ~~onclick="namedFunction()"~~ `></button>`
>
>
>
* use on-event property or `.addEventListener()`
>
> `document.querySelector("button").onclick = namedFunction`
> `document.querySelector("butt... |
7,332,951 | I need to prepare ASP.NET site with form, fill form in code behind and then submit form to external site.
For example: user open www.myshop.com/pay.aspx, he does not have to fill anything because I fill form values in code behind and then user is automatically redirected to external site www.onlinepayments.com (with f... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7332951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159057/"
] | please take a look at this [post](http://www.silverlighthack.com/post/2010/10/08/Windows-Phone-7-RTM-Charting-using-the-Silverlight-Control-Toolkit.aspx). windows phone mango uses Siverlight 3, so you should still be able to use the charts from the silverlight toolkit. | Have a look at [Silverlight toolkit examples.](http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html) You can try port it to WP7 <http://silverlight.codeplex.com/> |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | You can use `**/*`
```
shopt -s globstar
du -hs **/* | sort -hr
shopt -u globstar
``` | Wildcards are nice, but they'll also list FILES and not just directories. The below will return the sizes of all directories and only the directories:
`find . -type d -exec du -sh {} \; | sort -hr` |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | You can use `**/*`
```
shopt -s globstar
du -hs **/* | sort -hr
shopt -u globstar
``` | The `maxdepth` feature should solve your issue, but for some strange reason, it seems not to work:
```
find ./ -maxdepth 1 -type d -exec du -k {} \;
```
Maybe somebody can explain why the `maxdepth` is not taken into account? |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | The simplest is:
```
du -h --max-depth=1 parent
```
This will show all sizes of the children of `parent` If you also want the grandchildren, you can do
```
du -h --max-depth=2 parent
```
If you want the whole family
```
du -h parent
```
All these will just summarize the total directory size of each subdirector... | You can use `**/*`
```
shopt -s globstar
du -hs **/* | sort -hr
shopt -u globstar
``` |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | The simplest is:
```
du -h --max-depth=1 parent
```
This will show all sizes of the children of `parent` If you also want the grandchildren, you can do
```
du -h --max-depth=2 parent
```
If you want the whole family
```
du -h parent
```
All these will just summarize the total directory size of each subdirector... | Wildcards are nice, but they'll also list FILES and not just directories. The below will return the sizes of all directories and only the directories:
`find . -type d -exec du -sh {} \; | sort -hr` |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | If sorting you will likely want a consistent output instead of having some in GB, some in MB, some in KB.... And if I read the OP correctly, it isn't getting the directory tree, and that's a *problem*, right?
It isn't listing subdirs because of the -s. Take that out (again, sorry if I'm misreading.)
```
du -b | sort ... | Wildcards are nice, but they'll also list FILES and not just directories. The below will return the sizes of all directories and only the directories:
`find . -type d -exec du -sh {} \; | sort -hr` |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | The simplest is:
```
du -h --max-depth=1 parent
```
This will show all sizes of the children of `parent` If you also want the grandchildren, you can do
```
du -h --max-depth=2 parent
```
If you want the whole family
```
du -h parent
```
All these will just summarize the total directory size of each subdirector... | The `maxdepth` feature should solve your issue, but for some strange reason, it seems not to work:
```
find ./ -maxdepth 1 -type d -exec du -k {} \;
```
Maybe somebody can explain why the `maxdepth` is not taken into account? |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | If sorting you will likely want a consistent output instead of having some in GB, some in MB, some in KB.... And if I read the OP correctly, it isn't getting the directory tree, and that's a *problem*, right?
It isn't listing subdirs because of the -s. Take that out (again, sorry if I'm misreading.)
```
du -b | sort ... | The `maxdepth` feature should solve your issue, but for some strange reason, it seems not to work:
```
find ./ -maxdepth 1 -type d -exec du -k {} \;
```
Maybe somebody can explain why the `maxdepth` is not taken into account? |
54,041,428 | From the shell, I need to list the size of all child directories. I am currently using:
```
du -hs * | sort -hr
```
However, this only gets one level down and does not traverse the directory tree. | 2019/01/04 | [
"https://Stackoverflow.com/questions/54041428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6152965/"
] | The simplest is:
```
du -h --max-depth=1 parent
```
This will show all sizes of the children of `parent` If you also want the grandchildren, you can do
```
du -h --max-depth=2 parent
```
If you want the whole family
```
du -h parent
```
All these will just summarize the total directory size of each subdirector... | If sorting you will likely want a consistent output instead of having some in GB, some in MB, some in KB.... And if I read the OP correctly, it isn't getting the directory tree, and that's a *problem*, right?
It isn't listing subdirs because of the -s. Take that out (again, sorry if I'm misreading.)
```
du -b | sort ... |
41,616,949 | In Win32 Console Application (Visual C++) I have a array of objects and each object contains some other objects and variables, ex. (Owner and Equipment are structs, TimeInfo is class):
```
class Order
{
public:
Order();
~Order();
Owner owner;
Equipment equipment;
char *problem;
TimeInfo timeinf... | 2017/01/12 | [
"https://Stackoverflow.com/questions/41616949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6315663/"
] | As people have already pointed out, you should avoid using malloc in this situation. If you want to allocate 100 instances of Order, you could try something like this:
```
Order* items = new Order[100];
```
In this case the default constructor of Order is called for every instance.
When you want to free up the memo... | I would use a destructor to manage freeing memory allocated in the OrderManager class.
You should be using C++ new and delete to allocate/deallocate memory and also should be using containers to store collections of an object.
Refer to this link for a list of options on how you can initialize the vector:
<https://sta... |
464,328 | I want to save the result of `find` into the file with an Ansible play.
```
- name: Find / -name "postgresql"
find:
paths: /var/log
patterns: 'postgresql'
```
The result of above will be saved into a file.
Simply, the command is `find / -name "postgresql" > text.txt` in shell.
How do I make that command in... | 2018/08/23 | [
"https://unix.stackexchange.com/questions/464328",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/273477/"
] | An Ansible way of doing this with the [find module](https://docs.ansible.com/ansible/latest/modules/find_module.html#find-return-a-list-of-files-based-on-specific-criteria) could be (I am using `/var/log/secure` as an example since I don't run postgres):
```
---
- hosts: all
tasks:
- name: "Find file /var/log/se... | You should use the [Ansible shell module](https://docs.ansible.com/ansible/2.5/modules/shell_module.html) in this case.
Here's an example:
```
- name: Find / -name "postgresql"
shell: find / -name "postgresql" > /tmp/text.txt
``` |
40,981,795 | Using the wizard, I created a DbContext from an existing database and only selected one table to be pulled in. However now I need to add additional tables from that database to the Entity Model.
What is the easiest way to add more tables from an existing database to a context that I have already created and to also ge... | 2016/12/05 | [
"https://Stackoverflow.com/questions/40981795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3447158/"
] | Easiest way is:
1) Open your .edmx database
2) Right click and choose "Update model from database..."
3) check the tables you want and click finish
4) EF will create all your entity classes for you | I think **EntityFramework Reverse Poco Generator** is what you're searching for.
It's an extension for VS which allows to populate a TT file, then creating POCO entities for you.
It is downloadable here: [EntityFramework Reverse Poco Generator](https://marketplace.visualstudio.com/items?itemName=SimonHughes.EntityFram... |
40,981,795 | Using the wizard, I created a DbContext from an existing database and only selected one table to be pulled in. However now I need to add additional tables from that database to the Entity Model.
What is the easiest way to add more tables from an existing database to a context that I have already created and to also ge... | 2016/12/05 | [
"https://Stackoverflow.com/questions/40981795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3447158/"
] | If you want to add the tables manually to your DbContext, you can do so by adding properties of type DbSet to the DbContext. For ex:
```
public DbSet<CarColor> CarColors { get; set; }
``` | I think **EntityFramework Reverse Poco Generator** is what you're searching for.
It's an extension for VS which allows to populate a TT file, then creating POCO entities for you.
It is downloadable here: [EntityFramework Reverse Poco Generator](https://marketplace.visualstudio.com/items?itemName=SimonHughes.EntityFram... |
2,480,974 | I am new to Haskell and this mixture of Infix and Prefix notation is confusing me.
What is the difference between an operator like '+' and a function like head? How do I write an operator 'c' which does this 1 c 1 = 2?
I found this definition a ! b = True. How does Haskell know that I am defining ! and not a function ... | 2010/03/19 | [
"https://Stackoverflow.com/questions/2480974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82368/"
] | In Haskell, to create an operator you must use the following "operator symbols":
! # $ % \* + . / < = > ? \ ^ | : - ~
So, for example
```
($$$) a b = a+b
```
Defines an operator $$$ which can be used in the expression 1 $$$ 1 to yield a value of 2.
Conceptually, there is no difference between an operator and a fu... | Haskell knows you aren't defining a function called `a` because the `!` wouldn't be valid in a function argument list. In order to use the `!` not as an operator but just as a normal identifier, you need to enclose it in parentheses. If you wrote instead `a (!) b = True`, then it would define the function `a :: t -> t1... |
2,480,974 | I am new to Haskell and this mixture of Infix and Prefix notation is confusing me.
What is the difference between an operator like '+' and a function like head? How do I write an operator 'c' which does this 1 c 1 = 2?
I found this definition a ! b = True. How does Haskell know that I am defining ! and not a function ... | 2010/03/19 | [
"https://Stackoverflow.com/questions/2480974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82368/"
] | In Haskell, to create an operator you must use the following "operator symbols":
! # $ % \* + . / < = > ? \ ^ | : - ~
So, for example
```
($$$) a b = a+b
```
Defines an operator $$$ which can be used in the expression 1 $$$ 1 to yield a value of 2.
Conceptually, there is no difference between an operator and a fu... | Really, the only difference is syntax. Function names begin with a lower-case letter, followed by a series of alpha-numeric characters. Operators are some unique sequence of the typical operator characters (+ - / \* < > etc.).
Functions can be used as operators (in-fix) by enclosing the function name in ` characters. ... |
23,801,935 | I'm opening the default mail client with a pre filled form (to, subject, body).
Everything works fine except for one thing. I can't figure out out to add a linebreak to the body text. I tried to encode the `<br>` Tag but it didn't work. The result was that in the body only showed the first line while the second line w... | 2014/05/22 | [
"https://Stackoverflow.com/questions/23801935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1065366/"
] | Try `%0D%0A` (as carrage return linefeed) | If the format is HTML newline characters will be ignored and you'd need to insert HTML breaks `<br />`.
```
StringBuilder body = new StringBuilder();
body.append("First Line<br />");
body.append("Second Line<br />");
String mailToString = "mailto:" + address + "?subject=" + subject + "&body=" + body.toString();
``` |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | You don't have to detect it manually to achieve that effect. One Mach-O executable file can contain both binaries for 32 bit and 64 bit intel machines, and the kernel runs the most appropriate ones automatically. If you're using XCode, there's a setting in the project inspector where you can set the architectures (ppc,... | The standard way of checking the os version (and hence whether its snow leopard, a 64-bit os) is detailed [here](http://www.cocoadev.com/index.pl?DeterminingOSVersion). |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | There is a super-easy way. Compile two versions of the executable, one for 32-bit and one for 64-bit and combine them with lipo. That way, the right version will always get executed.
```
gcc -lobjc somefile.m -o somefile -m32 -march=i686
gcc -lobjc somefile.m -o somefile2 -m64 -march=x86_64
lipo -create -arch i686 so... | To programmatically get a string with the CPU architecture name:
```
#include <sys/types.h>
#include <sys/sysctl.h>
// Determine the machine name, e.g. "x86_64".
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); // Get size of data to be returned.
char *name = malloc(size);
sysctlbyname("hw.machine", nam... |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | If you are on Snow Leopard use NSRunningApplication's executableArchitecture.
Otherwise, I would do the following:
```
-(BOOL) is64Bit
{
#if __LP64__
return YES;
#else
return NO;
#endif
}
``` | The standard way of checking the os version (and hence whether its snow leopard, a 64-bit os) is detailed [here](http://www.cocoadev.com/index.pl?DeterminingOSVersion). |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | Use `[[NSRunningApplication currentApplication] executableArchitecture]` which returns one of the following constants:
* `NSBundleExecutableArchitectureI386`
* `NSBundleExecutableArchitectureX86_64`
* `NSBundleExecutableArchitecturePPC`
* `NSBundleExecutableArchitecturePPC64`
For example:
```
switch ([[NSRunningAppl... | The standard way of checking the os version (and hence whether its snow leopard, a 64-bit os) is detailed [here](http://www.cocoadev.com/index.pl?DeterminingOSVersion). |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | You don't have to detect it manually to achieve that effect. One Mach-O executable file can contain both binaries for 32 bit and 64 bit intel machines, and the kernel runs the most appropriate ones automatically. If you're using XCode, there's a setting in the project inspector where you can set the architectures (ppc,... | To programmatically get a string with the CPU architecture name:
```
#include <sys/types.h>
#include <sys/sysctl.h>
// Determine the machine name, e.g. "x86_64".
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); // Get size of data to be returned.
char *name = malloc(size);
sysctlbyname("hw.machine", nam... |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | If you are on Snow Leopard use NSRunningApplication's executableArchitecture.
Otherwise, I would do the following:
```
-(BOOL) is64Bit
{
#if __LP64__
return YES;
#else
return NO;
#endif
}
``` | To programmatically get a string with the CPU architecture name:
```
#include <sys/types.h>
#include <sys/sysctl.h>
// Determine the machine name, e.g. "x86_64".
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); // Get size of data to be returned.
char *name = malloc(size);
sysctlbyname("hw.machine", nam... |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | There is a super-easy way. Compile two versions of the executable, one for 32-bit and one for 64-bit and combine them with lipo. That way, the right version will always get executed.
```
gcc -lobjc somefile.m -o somefile -m32 -march=i686
gcc -lobjc somefile.m -o somefile2 -m64 -march=x86_64
lipo -create -arch i686 so... | Usually, you shouldn't need to be able to check at runtime whether you're on 64 or 32 bits. If your host application (that's what I'd call the app that launches the 64 or 32 bit tools) is a fat binary, the compile-time check is enough. Since it will get compiled twice (once for the 32-bit part of the fat binary, once f... |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | There is a super-easy way. Compile two versions of the executable, one for 32-bit and one for 64-bit and combine them with lipo. That way, the right version will always get executed.
```
gcc -lobjc somefile.m -o somefile -m32 -march=i686
gcc -lobjc somefile.m -o somefile2 -m64 -march=x86_64
lipo -create -arch i686 so... | Use `[[NSRunningApplication currentApplication] executableArchitecture]` which returns one of the following constants:
* `NSBundleExecutableArchitectureI386`
* `NSBundleExecutableArchitectureX86_64`
* `NSBundleExecutableArchitecturePPC`
* `NSBundleExecutableArchitecturePPC64`
For example:
```
switch ([[NSRunningAppl... |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | Usually, you shouldn't need to be able to check at runtime whether you're on 64 or 32 bits. If your host application (that's what I'd call the app that launches the 64 or 32 bit tools) is a fat binary, the compile-time check is enough. Since it will get compiled twice (once for the 32-bit part of the fat binary, once f... | The standard way of checking the os version (and hence whether its snow leopard, a 64-bit os) is detailed [here](http://www.cocoadev.com/index.pl?DeterminingOSVersion). |
1,988,996 | I'm currently wring a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application which needs to execute some (console) applications which are optimized for 32 and 64 bit. Because of this I would like to detect what CPU architecture the application is running on so I can start the correct console application.
So... | 2010/01/01 | [
"https://Stackoverflow.com/questions/1988996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241978/"
] | Use `[[NSRunningApplication currentApplication] executableArchitecture]` which returns one of the following constants:
* `NSBundleExecutableArchitectureI386`
* `NSBundleExecutableArchitectureX86_64`
* `NSBundleExecutableArchitecturePPC`
* `NSBundleExecutableArchitecturePPC64`
For example:
```
switch ([[NSRunningAppl... | You don't have to detect it manually to achieve that effect. One Mach-O executable file can contain both binaries for 32 bit and 64 bit intel machines, and the kernel runs the most appropriate ones automatically. If you're using XCode, there's a setting in the project inspector where you can set the architectures (ppc,... |
23,185,649 | I am stuck on making a regular expression that matches numbers from 01 to 56, with a space between them but not a space a the end. Strings samples look like these ones:
```
"33 44 51 52 53 54"
"01 05 09 14 25 36"
```
To achieve that, i am using the following expression (and testing it at <http://regexpal.com/>):
``... | 2014/04/20 | [
"https://Stackoverflow.com/questions/23185649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883256/"
] | It's easier than you think. But this still matches everything from 00 to 59. So I have not answered the 2nd question.
```
([0-5][0-9] +){5}[0-5][0-9]
``` | Separate matches for numbers starting with 5 and 0:
```
^((0[1-9]|[1-4][0-9]|5[0-6])( +|$)){6}(?<! )$
```
`(?<! )` a negative look behind to check the last space
***Explanations***:
```
^ # Start of string
( # 1st optional capturing group
( #2nd optional capturing group
0[1-9] ... |
23,185,649 | I am stuck on making a regular expression that matches numbers from 01 to 56, with a space between them but not a space a the end. Strings samples look like these ones:
```
"33 44 51 52 53 54"
"01 05 09 14 25 36"
```
To achieve that, i am using the following expression (and testing it at <http://regexpal.com/>):
``... | 2014/04/20 | [
"https://Stackoverflow.com/questions/23185649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883256/"
] | Try this:
```
^((0[1-9]|[1-4][0-9]|5[0-6]) ){5}(0[1-9]|[1-4][0-9]|5[0-6])$
```
This will match any number from 01 to 56, where each number is followed either by a space, repeated 5 times, followed by another number from 01 to 56. The start (`^`) and end (`$`) anchors ensure that no other characters are allowed befor... | It's easier than you think. But this still matches everything from 00 to 59. So I have not answered the 2nd question.
```
([0-5][0-9] +){5}[0-5][0-9]
``` |
23,185,649 | I am stuck on making a regular expression that matches numbers from 01 to 56, with a space between them but not a space a the end. Strings samples look like these ones:
```
"33 44 51 52 53 54"
"01 05 09 14 25 36"
```
To achieve that, i am using the following expression (and testing it at <http://regexpal.com/>):
``... | 2014/04/20 | [
"https://Stackoverflow.com/questions/23185649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883256/"
] | Try this:
```
^((0[1-9]|[1-4][0-9]|5[0-6]) ){5}(0[1-9]|[1-4][0-9]|5[0-6])$
```
This will match any number from 01 to 56, where each number is followed either by a space, repeated 5 times, followed by another number from 01 to 56. The start (`^`) and end (`$`) anchors ensure that no other characters are allowed befor... | Separate matches for numbers starting with 5 and 0:
```
^((0[1-9]|[1-4][0-9]|5[0-6])( +|$)){6}(?<! )$
```
`(?<! )` a negative look behind to check the last space
***Explanations***:
```
^ # Start of string
( # 1st optional capturing group
( #2nd optional capturing group
0[1-9] ... |
30,067,935 | I've embed a bootstrap datepicker from <http://www.malot.fr/bootstrap-datetimepicker/demo.php>
I want only the date and month and year to be displayed. But in this plugin I've date,month,year, and time. How do I remove only the time selection from this datepicker? | 2015/05/06 | [
"https://Stackoverflow.com/questions/30067935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4548891/"
] | Use [DatePicker](https://bootstrap-datepicker.readthedocs.org/en/latest/) instead of DateTimePicker. | I use a different datetime picker, and have had great success with it. [Bootstrap 3 Date/Time Picker](https://github.com/Eonasdan/bootstrap-datetimepicker). It uses [Moment.js](http://momentjs.com/) and allows for all sorts of date/time formatting options. It is also more accessible, and allows for scrolling through th... |
42,090,369 | I need a macro to split my data from one Excel file to few others. It looks like this:
```
UserList.xls
User Role Location
DDAVIS XX WW
DDAVIS XS WW
GROBERT XW WP
SJOBS XX AA
SJOBS XS AA
SJOBS XW AA
```
I need, to copy data like this:
```
WW_DDAVIS.xls
... | 2017/02/07 | [
"https://Stackoverflow.com/questions/42090369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7528685/"
] | In Python `|` and `&` are bitwise operators, they do bit calculations.
On the other hand `and` and `or` are logical (boolean) operators. | | is a bitwise operators and in python script do bit calculations
Use this
```
i = 200
j = 201
if i == 200 or j == 201:
print "Hi"
else:
print "No"
``` |
42,090,369 | I need a macro to split my data from one Excel file to few others. It looks like this:
```
UserList.xls
User Role Location
DDAVIS XX WW
DDAVIS XS WW
GROBERT XW WP
SJOBS XX AA
SJOBS XS AA
SJOBS XW AA
```
I need, to copy data like this:
```
WW_DDAVIS.xls
... | 2017/02/07 | [
"https://Stackoverflow.com/questions/42090369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7528685/"
] | The problem here is actually one of **operator precedence**, not specifically of using a bitwise `|` rather than the logical `or`; `True | True` and `True or True` give the same result.
Per the [Python docs](https://docs.python.org/2/reference/expressions.html#operator-precedence) the comparison `==` has lower preced... | In Python `|` and `&` are bitwise operators, they do bit calculations.
On the other hand `and` and `or` are logical (boolean) operators. |
42,090,369 | I need a macro to split my data from one Excel file to few others. It looks like this:
```
UserList.xls
User Role Location
DDAVIS XX WW
DDAVIS XS WW
GROBERT XW WP
SJOBS XX AA
SJOBS XS AA
SJOBS XW AA
```
I need, to copy data like this:
```
WW_DDAVIS.xls
... | 2017/02/07 | [
"https://Stackoverflow.com/questions/42090369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7528685/"
] | The problem here is actually one of **operator precedence**, not specifically of using a bitwise `|` rather than the logical `or`; `True | True` and `True or True` give the same result.
Per the [Python docs](https://docs.python.org/2/reference/expressions.html#operator-precedence) the comparison `==` has lower preced... | | is a bitwise operators and in python script do bit calculations
Use this
```
i = 200
j = 201
if i == 200 or j == 201:
print "Hi"
else:
print "No"
``` |
30,532,236 | If I want to refer to a range within the active workbook in Excel VBA, I can say "With Range("Myrange")". I don't need a sheet name.
Sometimes I want to refer to a range in another workbook. "With MyWorkbook.Range("Myrange")" doesn't work because I have to specify the sheet that the range is in.
Is there any way of r... | 2015/05/29 | [
"https://Stackoverflow.com/questions/30532236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3674157/"
] | If you create a named range and scope it to the Workbook you can use the following to get a named range in any workbook. You obviously get an error if the name can't be found.
```
wb.Names("Myrange").RefersToRange
``` | Yes, create a Named Range (ex: `MyRangeName`) within your workbook. Then in your code use `Range("MyRangeName")` and it will refer to those cells on that sheet no matter what workbook you're looking at. |
14,211,843 | I am uploading a file in JSF. I am using Tomahawk's `<t:inputFileUpload>` for this, but the same question is applicable on e.g. PrimeFaces `<p:fileUpload>` and JSF 2.2 `<h:inputFile>`.
I have the below backing bean code:
```
private UploadedFile uploadedFile; // +getter+setter
public String save() throws IOException... | 2013/01/08 | [
"https://Stackoverflow.com/questions/14211843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1473193/"
] | The `getInputStream()` method of the uploaded file represents the file content.
```
InputStream input = uploadedFile.getInputStream();
```
You need to copy it to a file. You should first prepare a folder on the local disk file system where the uploaded files should be stored. For example, `/path/to/uploads` (on Wind... | PrimeFaces uses two file upload decoder for uploading content of p:fileupload
1. NativeFileUploadDecoder
2. CommonsFileUploadDecoder
NativeFileUploadDecoder is the default upload decoder and it requires servlet container 3.0. So if your servlet container is less than 3 then it will not work with you.
Also some appl... |
40,942,592 | I have request for updating page. When adding new page request is like:
```
'title'=>'required|max:70|unique:pages',
```
but when I'm updating page title must be unique but need to check all other titles except one already entered.
I searched Google for all possible solutions but nothing works.
I tried:
```
'titl... | 2016/12/02 | [
"https://Stackoverflow.com/questions/40942592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5092259/"
] | You have a bug here:
```
public function rules()
{ This space is causing trouble
|
return [
'title'=>'required|max:70|unique:pages, title,'.$this->id,
...
]
```
Should be
```
public function rules()
{ ... | ```
SQLSTATE[42S22]: Column not found: 1054 Unknown column ' title'
```
It seems that it's searching for a column named " title", it may be stupid but double check that the column name is sent without a space at the beggining. |
66,373,644 | I know are many ways to get what I searching, actually I found the solution here on the forum, but the problem is that I don't really know why is not working, this is my try:
```
select * From ModeloBI.CORP.T_LOGI_RN_Planeacion_Entregas
Where ModeloBI.CORP.T_LOGI_RN_Planeacion_Entregas.Fecha_de_modificacion >= datead... | 2021/02/25 | [
"https://Stackoverflow.com/questions/66373644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14963549/"
] | First of all, your css are looking for elements inside the class `.item`. Your HTML doesn't have that class. Second, if you want to style only the first element inside a class you need to use the pseudo-class "first-child".
```css
#GerenciarEpsOvas .infos > * {
padding: 1px;
color: red;
}
#GerenciarEpsOvas .i... | I think you want to select everything that is a child of GerenciarEpsOvas, .item or .infos. To achieve that (selecting multiple) separate them with commas.
I set the passing to 100px to make it more obvious:
```css
#GerenciarEpsOvas, .item, .infos > * {
padding: 100px;
}
#GerenciarEpsOvas, .item, .infos, .name {
... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | ```
<?php
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$cur = 0;
$rowNum = 1;
foreach($data as $value){
if($cur == 0)
{
echo '<ul class="row' . $rowNum . '">';
}
echo ' <li>' . $value . '</li>';
if($cur == 4)
{
echo '</ul>';
... | You can do this by counting how many you did already. This can be achieved by either get a variable and increment it inside the `foreach()` or directly use a `for()`.
```
$amount = count($data);
$no_of_ul = 1;
for ($i=0; $i<$amount; $i++) {
if ($i % 5 == 0) {
if ($i > 0) {
echo '</ul>';
... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | Keep it simple. The [`array_chunk()`](http://php.net/array_chunk) function sounds exactly what you are looking for.
In this example there will be 3 items in each list.
```
$lists = array_chunk($data, 3);
$number = 1;
foreach ($lists as $items) {
echo '<ul class="row', $number++, '">';
foreach ($items as $ite... | You can do this by counting how many you did already. This can be achieved by either get a variable and increment it inside the `foreach()` or directly use a `for()`.
```
$amount = count($data);
$no_of_ul = 1;
for ($i=0; $i<$amount; $i++) {
if ($i % 5 == 0) {
if ($i > 0) {
echo '</ul>';
... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | ```
<?php
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$cur = 0;
$rowNum = 1;
foreach($data as $value){
if($cur == 0)
{
echo '<ul class="row' . $rowNum . '">';
}
echo ' <li>' . $value . '</li>';
if($cur == 4)
{
echo '</ul>';
... | Does it helps ?
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$count = 1 ;
$len = sizeof($data);
$row = 1;
foreach($data as $value){
if($count == 1 ){
echo '<ul class="row'.$row.'">';
$row++;
}
echo '<li>' . $value . '</li>';
if($count !=1 && $c... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | ```
<?php
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$cur = 0;
$rowNum = 1;
foreach($data as $value){
if($cur == 0)
{
echo '<ul class="row' . $rowNum . '">';
}
echo ' <li>' . $value . '</li>';
if($cur == 4)
{
echo '</ul>';
... | Keep it simple. The [`array_chunk()`](http://php.net/array_chunk) function sounds exactly what you are looking for.
In this example there will be 3 items in each list.
```
$lists = array_chunk($data, 3);
$number = 1;
foreach ($lists as $items) {
echo '<ul class="row', $number++, '">';
foreach ($items as $ite... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | ```
<?php
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$cur = 0;
$rowNum = 1;
foreach($data as $value){
if($cur == 0)
{
echo '<ul class="row' . $rowNum . '">';
}
echo ' <li>' . $value . '</li>';
if($cur == 4)
{
echo '</ul>';
... | I know this is a bit of an older post but I thought I would contribute. I have a wp project where I had to display lot of title / permalink lists throughout the site.
Sverri M. Olsen's answer really made the job much quicker, easier to read, and universal...
```
function display_title_link_lists($args, $chunk_size) ... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | Keep it simple. The [`array_chunk()`](http://php.net/array_chunk) function sounds exactly what you are looking for.
In this example there will be 3 items in each list.
```
$lists = array_chunk($data, 3);
$number = 1;
foreach ($lists as $items) {
echo '<ul class="row', $number++, '">';
foreach ($items as $ite... | Does it helps ?
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
$count = 1 ;
$len = sizeof($data);
$row = 1;
foreach($data as $value){
if($count == 1 ){
echo '<ul class="row'.$row.'">';
$row++;
}
echo '<li>' . $value . '</li>';
if($count !=1 && $c... |
22,261,631 | Im looking to create a 2 or more ul class with li content from a foreach loop if the values count more than 5.
```
$data = array('Barcelona','Jujuy','Cordoba','Mendoza','Galicia','Madrid','Estonia','New York');
echo '<ul class="row1">';
foreach($data as $value){
echo '<li>' . $value . '</li>';
}
echo '</ul>'
``... | 2014/03/07 | [
"https://Stackoverflow.com/questions/22261631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091123/"
] | Keep it simple. The [`array_chunk()`](http://php.net/array_chunk) function sounds exactly what you are looking for.
In this example there will be 3 items in each list.
```
$lists = array_chunk($data, 3);
$number = 1;
foreach ($lists as $items) {
echo '<ul class="row', $number++, '">';
foreach ($items as $ite... | I know this is a bit of an older post but I thought I would contribute. I have a wp project where I had to display lot of title / permalink lists throughout the site.
Sverri M. Olsen's answer really made the job much quicker, easier to read, and universal...
```
function display_title_link_lists($args, $chunk_size) ... |
166,100 | When reading the Harry Potter series, I couldn't help but notice: Harry destroyed Tom Riddle's diary with a basilisk fang, and later in the series we find out that its poison can be conveniently used to destroy Horcruxes, and the diary was conveniently one of those Horcruxes.
With example above, I came up with a **pos... | 2017/07/31 | [
"https://scifi.stackexchange.com/questions/166100",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/85535/"
] | I'm sure someone can answer this better, but until then...
J. K. Rowling took 5 years to develop the world of Harry Potter. I'm not sure if it's confirmed, but it is certainly implied that in this time she planned out the majority of what was going to happen.
However, Rowling also confirmed that much of 'the Half-Bloo... | If you study the writing process, and it is a process, it is iterative. Meaning that you once you "finish" the process, you go back and make adjustments.
The first iteration that is commonly used is to write an out line, first of the general and overarching plot lines for the whole series, then for the book you are c... |
74,677,722 | So here is the context.
I created an script in python, YOLOv4, OpenCV, CUDA and CUDNN, for object detection and object tracking to count the objects in a video. I intend to use it in real time, but what real time really means? The video I'm using is 1min long and 60FPS originally, but the video after processing is 30F... | 2022/12/04 | [
"https://Stackoverflow.com/questions/74677722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9633446/"
] | First, learn what "real-time" means. Wikipedia: <https://en.wikipedia.org/wiki/Real-time_computing>
Understand the terms **"hard" and "soft"** real-time. Understand which aspects of your environment are soft and which require hard real-time.
Understand the **response times** that your environment requires. Understand... | Real-time refers to the fact that a system is able to process and respond to data as it is received, without any significant delay. In the context of your object detection and tracking script, real-time would mean that the system is able to process and respond to new frames of the video as they are received, without a ... |
52,900,947 | Is it possible to have VSCode always have a particular folder ("Directory A") open, so the files inside can be searched using Ctrl + P?
It seems the standard behaviour is that my current "added folder" (i.e. "Directory A") get removed whenever I open a file from a different location ("Directory B").
Closing VSCode an... | 2018/10/19 | [
"https://Stackoverflow.com/questions/52900947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1863415/"
] | Add Directory A to your workspace using `File > Add Folder to Workspace...`
Then rather than opening Directory B when you launch VSCode, open the .vscode-workspace file for the workspace that contains both directories.
If there are multiple files in your workspace which match the filename you're searching for using C... | The solution, at least on linux, is to create a script with the following content (let's call the script `code-standard-path` ):
```sh
#!/bin/bash
code /path/to/standardDir-or-standardworkspace "$1"
```
Then from `caja` right click on a file : `open with` -> `other application`.
Then select the command `code-standar... |
52,900,947 | Is it possible to have VSCode always have a particular folder ("Directory A") open, so the files inside can be searched using Ctrl + P?
It seems the standard behaviour is that my current "added folder" (i.e. "Directory A") get removed whenever I open a file from a different location ("Directory B").
Closing VSCode an... | 2018/10/19 | [
"https://Stackoverflow.com/questions/52900947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1863415/"
] | Add Directory A to your workspace using `File > Add Folder to Workspace...`
Then rather than opening Directory B when you launch VSCode, open the .vscode-workspace file for the workspace that contains both directories.
If there are multiple files in your workspace which match the filename you're searching for using C... | Had the same issue. But there is an easy fix:
On the menu bar go to file **File > Preferences > Settings > Window** and **under Restore Windows select** the option **preserve**.
This will ALWAYS reopen the last session, no matter if you start VS from shell, desktop shortcut or by opening a file. |
45,033,474 | I was playing with this example timer and then wanted to see if I could capture/pass data into the timer so I started with a simple message. If I remove the message to timer it ticks accordingly. I started logging other lifecycle methods but I am curious if this is JS thing which I don't think it is versus something in... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45033474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/112665/"
] | All you need to do is to change this bit in your code:
```
this.interval = setInterval(() => this.tick('hi'), 1000);
```
Alternatively, you can also send in `this` to the callback:
```
this.interval = setInterval(function(t) {t.tick('hi')}, 1000, this);
```
See the updated fiddle, [**here**](http://jsfiddle.net/4... | Change code to:
```
componentDidMount: function() {
this.interval = setInterval(()=>this.tick('hi'), 1000);
}
``` |
22,826,357 | I'm trying to build a Java Bittorent client. From what I understand after peers handshake with one another they may start sending messages to each other, often sending messages sporadically.
Using a DataInputStream connection I can read messages, but if I call a read and nothing is on the stream the peers holds. Is t... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22826357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1308453/"
] | you shall add `$(document).ready()` before use JQuery, here is the [doc](http://api.jquery.com/ready/)
this is my code modified from yours, it works
```
$(document).ready(function () {
$('#submitForm').click(function () {
var userEmail = "email";
var userName = "userName";
... | Your `contentType: "application/json; charset=utf-8"` is expecting `json`, but in C# you are returning string in the function. You should return `json`
Here change your code behind function as follows:
```
[WebMethod]
public static String sendForm(string name, string email, string subject, string message)
{
var m... |
66,520,763 | I tried some of the solutions posted earlier in similar questions but none of them seem to work for me. My code is in **Python 3.8** and I am using the **latest version of VSCode**. Thanks. | 2021/03/07 | [
"https://Stackoverflow.com/questions/66520763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15166885/"
] | When running python code in VS Code, it executes the running command in the VS Code internal terminal ( `TERMINAL` ) by default. It is a terminal that allows user interaction, but "`OUTPUT`" is an output terminal, which cannot receive user input.
For how to make the output display in "`OUTPUT`" in VS Code:
Please use... | Make sure you've the code runner extension installed. If yes then,[enter image description here](https://i.stack.imgur.com/Y2jvo.png)
Go to settings ,
1.search Terminal
2. scroll to the last line
3. uncheck code run in terminal |
66,520,763 | I tried some of the solutions posted earlier in similar questions but none of them seem to work for me. My code is in **Python 3.8** and I am using the **latest version of VSCode**. Thanks. | 2021/03/07 | [
"https://Stackoverflow.com/questions/66520763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15166885/"
] | When running python code in VS Code, it executes the running command in the VS Code internal terminal ( `TERMINAL` ) by default. It is a terminal that allows user interaction, but "`OUTPUT`" is an output terminal, which cannot receive user input.
For how to make the output display in "`OUTPUT`" in VS Code:
Please use... | Install "Code Runner" extension.
* VS Code -> Extensions (Ctrl+Shift+X) in the most left panel -> text box "Search Extensions in Marketplace" -> Code Runner -> Install
Setting up Code Runner
* VS Code -> File -> Preferences -> Settings (Ctrl+,) -> text box "Search settings" -> Code Runner -> ensure that checkbox for... |
66,520,763 | I tried some of the solutions posted earlier in similar questions but none of them seem to work for me. My code is in **Python 3.8** and I am using the **latest version of VSCode**. Thanks. | 2021/03/07 | [
"https://Stackoverflow.com/questions/66520763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15166885/"
] | Make sure you've the code runner extension installed. If yes then,[enter image description here](https://i.stack.imgur.com/Y2jvo.png)
Go to settings ,
1.search Terminal
2. scroll to the last line
3. uncheck code run in terminal | Install "Code Runner" extension.
* VS Code -> Extensions (Ctrl+Shift+X) in the most left panel -> text box "Search Extensions in Marketplace" -> Code Runner -> Install
Setting up Code Runner
* VS Code -> File -> Preferences -> Settings (Ctrl+,) -> text box "Search settings" -> Code Runner -> ensure that checkbox for... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | Given all access to the filesystem from non-Linux systems will be through an abstraction layer, pick whatever you want! I'd suggest your distro's default (ext3 probably). Media storage has no special needs in terms of speed or reliability, so you'll just add unnecessary complexity picking an exotic filesystem. In terms... | Samba should be capable of communicating with your windows boxen and myth frontends, but it does not care what filesystem it's data is stored on as long as it can be read by the kernel.
I would pick what ever is the default for distro that you are installing.
Ext3 can definately accomodate files > 4GB. If you are goin... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | Samba should be capable of communicating with your windows boxen and myth frontends, but it does not care what filesystem it's data is stored on as long as it can be read by the kernel.
I would pick what ever is the default for distro that you are installing.
Ext3 can definately accomodate files > 4GB. If you are goin... | For a filesystem that will have mostly large files, I would recommend using XFS. It has great performance for large file sizes and is very mature. JFS is worth mentioning, as well and has similar performance to XFS and is just as mature.
However, depending on your distro, it might do you well to put the filesystem on... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | Given all access to the filesystem from non-Linux systems will be through an abstraction layer, pick whatever you want! I'd suggest your distro's default (ext3 probably). Media storage has no special needs in terms of speed or reliability, so you'll just add unnecessary complexity picking an exotic filesystem. In terms... | For a filesystem that will have mostly large files, I would recommend using XFS. It has great performance for large file sizes and is very mature. JFS is worth mentioning, as well and has similar performance to XFS and is just as mature.
However, depending on your distro, it might do you well to put the filesystem on... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | Given all access to the filesystem from non-Linux systems will be through an abstraction layer, pick whatever you want! I'd suggest your distro's default (ext3 probably). Media storage has no special needs in terms of speed or reliability, so you'll just add unnecessary complexity picking an exotic filesystem. In terms... | I use XFS on my MythTV server, and it works very well. I've also shared out certain directories by way of Samba so my Windows workstations can get access to it. I have a script that transcodes shows into a format usable on my iriver clix2, which dumps to a directory I map to from my Windows laptop and transfer to the m... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | Given all access to the filesystem from non-Linux systems will be through an abstraction layer, pick whatever you want! I'd suggest your distro's default (ext3 probably). Media storage has no special needs in terms of speed or reliability, so you'll just add unnecessary complexity picking an exotic filesystem. In terms... | XFS is best for storing video because it's very stable and has excellent large file support. It's not even exotic anymore.
Sharing (with another computer) is unrelated to the filesystem.
Basically, if you're sharing with windows - choose Samba because it's easiest.
While Samba works fine, if XBMC is your focus you m... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | I use XFS on my MythTV server, and it works very well. I've also shared out certain directories by way of Samba so my Windows workstations can get access to it. I have a script that transcodes shows into a format usable on my iriver clix2, which dumps to a directory I map to from my Windows laptop and transfer to the m... | For a filesystem that will have mostly large files, I would recommend using XFS. It has great performance for large file sizes and is very mature. JFS is worth mentioning, as well and has similar performance to XFS and is just as mature.
However, depending on your distro, it might do you well to put the filesystem on... |
14,235 | I need some advice on what file system to use for my new 1TB media server hosted on my Linux box. I have a few requirements:
1. Needs to be shareable to a different Windows machine (not dual booting, totally different box). I see that there might at least be options to do this with ext3, and as I think this will be a ... | 2009/05/29 | [
"https://serverfault.com/questions/14235",
"https://serverfault.com",
"https://serverfault.com/users/145754/"
] | XFS is best for storing video because it's very stable and has excellent large file support. It's not even exotic anymore.
Sharing (with another computer) is unrelated to the filesystem.
Basically, if you're sharing with windows - choose Samba because it's easiest.
While Samba works fine, if XBMC is your focus you m... | For a filesystem that will have mostly large files, I would recommend using XFS. It has great performance for large file sizes and is very mature. JFS is worth mentioning, as well and has similar performance to XFS and is just as mature.
However, depending on your distro, it might do you well to put the filesystem on... |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | ```
int money ;
bool pass = int.TryParse(Console.ReadLine(), out money);
if(pass)
moneys.Add(money);
``` | Implement a [`try-catch`](http://msdn.microsoft.com/en-us/library/0yd65esw%28v=vs.90%29.aspx) block or use [`Int32.TryParse`](http://msdn.microsoft.com/en-us/library/f02979c7.aspx). |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | ```
int money ;
bool pass = int.TryParse(Console.ReadLine(), out money);
if(pass)
moneys.Add(money);
``` | To handle the exception after it is thrown, use a try/catch block.
```
try
{
//input
}
catch(Exception ex)
{
//try again
}
```
You can also handle it beforehand by using TryParse, and checking if int is null. |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | You should use [TryParse](http://msdn.microsoft.com/en-us/library/f02979c7.aspx) method. it will not throw an exception if input is not valid. do this
```
int money;
if(int.TryParse(Console.ReadLine(), out money))
moneys.Add(money);
``` | ```
int money ;
bool pass = int.TryParse(Console.ReadLine(), out money);
if(pass)
moneys.Add(money);
``` |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | ```
int money ;
bool pass = int.TryParse(Console.ReadLine(), out money);
if(pass)
moneys.Add(money);
``` | `int.Parse` is ment to throw an exception when it fails to parse the string. You have 2 choices:
1) Use Try/Catch to handle the exception
```
try {
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
} catch {
//Did not parse, do something
}
```
This option allows more flexibility in dealing w... |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | You should use [TryParse](http://msdn.microsoft.com/en-us/library/f02979c7.aspx) method. it will not throw an exception if input is not valid. do this
```
int money;
if(int.TryParse(Console.ReadLine(), out money))
moneys.Add(money);
``` | Implement a [`try-catch`](http://msdn.microsoft.com/en-us/library/0yd65esw%28v=vs.90%29.aspx) block or use [`Int32.TryParse`](http://msdn.microsoft.com/en-us/library/f02979c7.aspx). |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | You should use [TryParse](http://msdn.microsoft.com/en-us/library/f02979c7.aspx) method. it will not throw an exception if input is not valid. do this
```
int money;
if(int.TryParse(Console.ReadLine(), out money))
moneys.Add(money);
``` | To handle the exception after it is thrown, use a try/catch block.
```
try
{
//input
}
catch(Exception ex)
{
//try again
}
```
You can also handle it beforehand by using TryParse, and checking if int is null. |
18,105,399 | I have the following code:
```
List<int> moneys = new List<int>();
Console.WriteLine("Please enter the cost of your choice");
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
```
From this if you enter text then the program stops working and an Unhandled exception message app... | 2013/08/07 | [
"https://Stackoverflow.com/questions/18105399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657462/"
] | You should use [TryParse](http://msdn.microsoft.com/en-us/library/f02979c7.aspx) method. it will not throw an exception if input is not valid. do this
```
int money;
if(int.TryParse(Console.ReadLine(), out money))
moneys.Add(money);
``` | `int.Parse` is ment to throw an exception when it fails to parse the string. You have 2 choices:
1) Use Try/Catch to handle the exception
```
try {
int money = int.Parse(Console.ReadLine());
moneys.Add(money);
} catch {
//Did not parse, do something
}
```
This option allows more flexibility in dealing w... |
1,053,531 | Xubuntu 18.04, `4.15.0-24-generic`, ThinkPad T430. Uses Intel HD iGPU graphics (nvidia dGPU disabled in BIOS).
Recently started having this issue with a slow boot, where the boot process hangs on a black screen for an indefinite period of time before finally displaying the normal login splash screen.
Process looks li... | 2018/07/09 | [
"https://askubuntu.com/questions/1053531",
"https://askubuntu.com",
"https://askubuntu.com/users/601020/"
] | The Eclipse snap package from the default Ubuntu repositories is perfect for Java programming because it is bundled with a Java development environment. To install it open the terminal and type:
```
sudo snap install eclipse --classic
```
This command will install the latest Photon Release 4.8 version of Eclipse I... | Though I always prefer packages from the Ubuntu distro, I make an exception for Eclipse because it (a) is trivial to install, (b) must be installed as user (no root required or recommended), and (c) it manages its own updates and plugins very well - including rollbacks, etc.
The instructions below work for all Eclipse... |
4,982,884 | I am using a line like this:
```
Array stringArray = Array.CreateInstance(typeof(String), 2, 2);
```
to consume a method that returns a 2D System.Array with my **stringArray** variable. However stringArray = MyClassInstance.Work(...,... ...); is not filled with the return array of that function.
How should I define... | 2011/02/13 | [
"https://Stackoverflow.com/questions/4982884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/516512/"
] | `Array.CreateInstance` returns an `Array`, without its dimension and length specified(but anyway it's an `System.Array` which is the base class of all arrays in C#). In most circumstances a return array from a method is more like:
```
public string[] MyMethod()
{
}
public int[,] Another(int something)
{
}
string[] th... | On your 2D-Array:
-----------------
```
Array.CreateInstance(typeof(String), 2, 2);
```
This returns a `string[,]` cast to `Array`. It's identical to `(Array)(new string[2,2])`. So you can cast it to `string[,]` if you want.
But why do you want to use that anyways? Can't you just use a `string[,]` instead? Don't yo... |
18,148,079 | Is there any way to redirect (push or perform segue etc.) to initial view controller aka rootViewController from `appdelegate` class? I am using `stroryboard` btw.
Any answers are appreciated.
**UP.** I am not using navigation controller. | 2013/08/09 | [
"https://Stackoverflow.com/questions/18148079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679671/"
] | ```
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
window.rootViewController = [storyboard instantiateInitialViewController];
``` | I suggest nesting all your navigation stack under a `UINavigationController`, then it would be as easy as invoking the `popToRootViewControllerAnimated:` method. |
18,148,079 | Is there any way to redirect (push or perform segue etc.) to initial view controller aka rootViewController from `appdelegate` class? I am using `stroryboard` btw.
Any answers are appreciated.
**UP.** I am not using navigation controller. | 2013/08/09 | [
"https://Stackoverflow.com/questions/18148079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679671/"
] | ```
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
window.rootViewController = [storyboard instantiateInitialViewController];
``` | UINavigationController popToRootViewController methods takes you there, if you're using UINav controller.
Other way you can try out: self.window.rootViewController is a reference that might useful. |
18,148,079 | Is there any way to redirect (push or perform segue etc.) to initial view controller aka rootViewController from `appdelegate` class? I am using `stroryboard` btw.
Any answers are appreciated.
**UP.** I am not using navigation controller. | 2013/08/09 | [
"https://Stackoverflow.com/questions/18148079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679671/"
] | ```
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
window.rootViewController = [storyboard instantiateInitialViewController];
``` | By Using Swift 4.2
```
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let window: UIWindow? = (UIApplication.shared.delegate?.window)!
window?.rootViewController = mainStoryboard.instantiateInitialViewController()
```
Working Perfect... |
36,805,071 | I tried the following code in Python 3.5.1:
```
>>> f = {x: (lambda y: x) for x in range(10)}
>>> f[5](3)
9
```
It's obvious that this should return `5`. I don't understand where the other value comes from, and I wasn't able to find anything.
It seems like it's something related to reference - it always returns th... | 2016/04/23 | [
"https://Stackoverflow.com/questions/36805071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5305568/"
] | **Python scoping is lexical**. A closure will refer to the name and scope of the variable, not the actual object/value of the variable.
What happens is that each lambda is capturing the variable `x` *not* the value of `x`.
At the end of the loop the variable `x` is bound to 9, therefore **every lambda will refer to t... | The following should work:
```
def make_func(x):
return lambda y: x
f = {x: make_func(x) for x in range(10)}
```
The `x` in your code ends up referring to the last `x` value, which is `9`, but in mine it refers to the `x` in the function scope. |
58,905,569 | I want to find the largest and second-largest number in the array. I can find the largest but second largest becomes same as largest and don't know why
```
int main()
{
int number[10];
cout<<"enter 10 numbers\n";
for (int i =0;i<=9;++i){
cin>>number[i];
}
int larger2=number[0],larger=numb... | 2019/11/17 | [
"https://Stackoverflow.com/questions/58905569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would modify your second evaluating loop to this:
As you have not correctly assigned larger2 in at least one iteration, so you should not use it for comparisons. (ie Do not do this `larger>larger2`)
```
for(int b=0;b<=9;++b){
if( number[b]>larger2 && larger>number[b]){
larger2=number[b];
}
}
``` | Have a look at this (this works only if there are at least 2 element in the array, otherwise `number[1]` will produce a segmentation fault):
```cpp
int main()
{
int number[10];
cout<<"enter 10 numbers\n";
for (int i =0;i<=9;++i){
cin>>number[i];
}
int larger2=min(number[0],number[1]) ,larg... |
23,713,488 | I have a program running 2 threads. The first is waiting for user input (using a scanf), the second is listening for some data over an udp socket. I would like to emulate user input to handle a specific notification with the first thread everytime I recive a specific udp packet. I know I can share variables between thr... | 2014/05/17 | [
"https://Stackoverflow.com/questions/23713488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3574984/"
] | You can use
>
> System.Diagnostics.Process.Start()
>
>
>
<http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx>
followed by
>
> Process.WaitForExit
>
>
>
to run the Visual C++ compiler (CL.EXE). The documentation for CL.EXE is here: <http://msdn.microsoft.com/en-us/library/610ec... | I assume you only want to treat single source file programs using only standard libraries. I also assume that you are working on Windows (asp.net). As soon as you have program source text, you can save it to a file. Then you start `cl` as an external program with your source as parameter to compile it. And finally you ... |
35,390 | I would like to write a function that pretty-prints the current source code block into a PDF. I know I can use ps-print-region-with-faces, but it would require that I first select the source code block.
Is there a function in org to do this selection?
thank you in advance
Edit:
the answer is org-babel-mark-block (... | 2017/09/09 | [
"https://emacs.stackexchange.com/questions/35390",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/13769/"
] | Unlike `org-mark-element`, the function `org-babel-mark-block` only selects the contents of a block. | `org-mark-element` should be able to do the right thing. It's bound to `M-h` by default. |
253,471 | Something I have been puzzled about is this: how exactly does a computer regulate and tell time? For example: if I were to write a program that did this:
Do 2+2 then wait 5 seconds
How does the processor know what "5 seconds" is? How is time measured in computer systems? Is there a specific chip for that sole purpose... | 2011/03/05 | [
"https://superuser.com/questions/253471",
"https://superuser.com",
"https://superuser.com/users/70272/"
] | IIRC, there's a small crystal the vibrates at a specific frequency when an electric current is passed through it. Each movement is counted and a specific number of them trigger a clock cycle. | >
> HPET uses a 10 MHz clock
>
>
>
HPET uses **at leaast** a 10 Mhz clock. It can be more precise than 10 Mhz but never less.
<http://en.wikipedia.org/wiki/High_Precision_Event_Timer#Comparison_to_predecessors> |
253,471 | Something I have been puzzled about is this: how exactly does a computer regulate and tell time? For example: if I were to write a program that did this:
Do 2+2 then wait 5 seconds
How does the processor know what "5 seconds" is? How is time measured in computer systems? Is there a specific chip for that sole purpose... | 2011/03/05 | [
"https://superuser.com/questions/253471",
"https://superuser.com",
"https://superuser.com/users/70272/"
] | While Joel's answer is correct, in reality, it's a bit more complicated.
First thing which needs to be taken into consideration (and I'm going to focus only on PCs here) is that there are several clocks in a computer and each has its own use.
Most popular and easiest to understand is the [real-time clock](http://en.w... | >
> HPET uses a 10 MHz clock
>
>
>
HPET uses **at leaast** a 10 Mhz clock. It can be more precise than 10 Mhz but never less.
<http://en.wikipedia.org/wiki/High_Precision_Event_Timer#Comparison_to_predecessors> |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | I would suggest going to the Dell website and downloading all the drivers. Missing drivers can cause problems like that, especially [CPU](http://en.wikipedia.org/wiki/Central_processing_unit) and chipset drivers. The other possibility (as long as you didn't install 64-bit on a 32-bit system), is either the computer isn... | Firstly I think the active 100% is a false alarm because the actual re/write speeds are 0. See this post: [Extremely high disk activity without any real usage](https://superuser.com/questions/470334/extremely-high-disk-activity-without-any-real-usage)
Now you mentioned several failed installation attempts, this could ... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | Okay, so I bought a Samsung 840 pro Series 128 (de factor 120)GB and set it in - the laptop works perfectly now. So the hard drive must have been the cause. In case it had not been, I would have plugged the SSD into my desktop anyway.
Thanks for all your ideas. | I would suggest going to the Dell website and downloading all the drivers. Missing drivers can cause problems like that, especially [CPU](http://en.wikipedia.org/wiki/Central_processing_unit) and chipset drivers. The other possibility (as long as you didn't install 64-bit on a 32-bit system), is either the computer isn... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | I would suggest going to the Dell website and downloading all the drivers. Missing drivers can cause problems like that, especially [CPU](http://en.wikipedia.org/wiki/Central_processing_unit) and chipset drivers. The other possibility (as long as you didn't install 64-bit on a 32-bit system), is either the computer isn... | Not sure if this helps you but I had such a hard time finding a fix for my problem, I wanted to post here:
I had a very similar problem and I believe fixed it today. Now it might not be applicable to you but this is how I fixed my Windows 8 Pro 100% HDD activity.
I installed my Win 8 on a SSD, but in the BIOS on the ... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | I would suggest going to the Dell website and downloading all the drivers. Missing drivers can cause problems like that, especially [CPU](http://en.wikipedia.org/wiki/Central_processing_unit) and chipset drivers. The other possibility (as long as you didn't install 64-bit on a 32-bit system), is either the computer isn... | First of all, if you have a legal copy, the first place where you should ask it's at microsoft and/or you laptop/HDD vendor [Toshiba or Dell] support. (that's one of the advantages of having a legal license. Use it. **You paid for it**. Make those geeks work for you). If there's any driver incompatibility with your HDD... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | Okay, so I bought a Samsung 840 pro Series 128 (de factor 120)GB and set it in - the laptop works perfectly now. So the hard drive must have been the cause. In case it had not been, I would have plugged the SSD into my desktop anyway.
Thanks for all your ideas. | Firstly I think the active 100% is a false alarm because the actual re/write speeds are 0. See this post: [Extremely high disk activity without any real usage](https://superuser.com/questions/470334/extremely-high-disk-activity-without-any-real-usage)
Now you mentioned several failed installation attempts, this could ... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | Okay, so I bought a Samsung 840 pro Series 128 (de factor 120)GB and set it in - the laptop works perfectly now. So the hard drive must have been the cause. In case it had not been, I would have plugged the SSD into my desktop anyway.
Thanks for all your ideas. | Not sure if this helps you but I had such a hard time finding a fix for my problem, I wanted to post here:
I had a very similar problem and I believe fixed it today. Now it might not be applicable to you but this is how I fixed my Windows 8 Pro 100% HDD activity.
I installed my Win 8 on a SSD, but in the BIOS on the ... |
537,992 | Yesterday, I have downloaded and installed Windows 8 Professional, after downloading it (legally) and burning it to a DVD, on my 3-year-old [Dell Studio 1555](https://en.wikipedia.org/wiki/Dell_Studio#Studio_15) (Intel Core Duo 2x2.4 GHz, 4 GB RAM, [Toshiba MK2555GSX](http://rads.stackoverflow.com/amzn/click/B001UUG9E0... | 2013/01/18 | [
"https://superuser.com/questions/537992",
"https://superuser.com",
"https://superuser.com/users/160047/"
] | Okay, so I bought a Samsung 840 pro Series 128 (de factor 120)GB and set it in - the laptop works perfectly now. So the hard drive must have been the cause. In case it had not been, I would have plugged the SSD into my desktop anyway.
Thanks for all your ideas. | First of all, if you have a legal copy, the first place where you should ask it's at microsoft and/or you laptop/HDD vendor [Toshiba or Dell] support. (that's one of the advantages of having a legal license. Use it. **You paid for it**. Make those geeks work for you). If there's any driver incompatibility with your HDD... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.