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 |
|---|---|---|---|---|---|
116,277 | *LE: This is not a duplicate of [What can I do to make a coworkers lack of effort more visible](https://workplace.stackexchange.com/questions/23165/what-can-i-do-to-make-a-coworkers-lack-of-effort-more-visible) because: . I think the other question only addresses part of my situation (the subjects of that question are ... | 2018/07/21 | [
"https://workplace.stackexchange.com/questions/116277",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/85674/"
] | Since you are using a versioning system: Fix one bug in his code and check the fix into the versioning system. Then fix another bug and check the fix into the versioning system. And so on. So when you need evidence you point your boss to the versioning system, which contains your name 99 times and his name once.
(In a... | As other recommend, I would ask somebody higher up if I could start CCing him in all your exchanges besides documenting everything in a source code system.
Obviously, if you working for the two, your colleague does not need to do it. However, it seems a bit odd he taking such a relaxed stance of missing so many hours... |
8,395,786 | I'm looking at the OpenGL wiki page, and I was curious about the following line:
>
> For reasons that are ultimately irrelevant to this discussion, you must
> manually load functions via a platform-specific API call. This boilerplate
> work is done with various OpenGL loading libraries; these make this process
> ... | 2011/12/06 | [
"https://Stackoverflow.com/questions/8395786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/906773/"
] | It has nothing to do with history. That's just how it is.
OpenGL implementations, by and large, come from some form of shared library (DLL/SO). However, this is complicated by the fact that you don't *own* the OpenGL "library"; it's part of the system infrastructure of whatever platform your code is running on. So you... | On the Mac, you don't need to load function pointers, you just include a header and link against the OpenGL framework. |
8,395,786 | I'm looking at the OpenGL wiki page, and I was curious about the following line:
>
> For reasons that are ultimately irrelevant to this discussion, you must
> manually load functions via a platform-specific API call. This boilerplate
> work is done with various OpenGL loading libraries; these make this process
> ... | 2011/12/06 | [
"https://Stackoverflow.com/questions/8395786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/906773/"
] | One of the main reasons is extensions: On every platform, OpenGL has always supported platform-specific extensions. These couldn't be part of the official headers, as they were usually added by the vendors in-between spec updates. In addition, those vendor-specific extensions may live in completely weird DLL/SO, for in... | It has nothing to do with history. That's just how it is.
OpenGL implementations, by and large, come from some form of shared library (DLL/SO). However, this is complicated by the fact that you don't *own* the OpenGL "library"; it's part of the system infrastructure of whatever platform your code is running on. So you... |
8,395,786 | I'm looking at the OpenGL wiki page, and I was curious about the following line:
>
> For reasons that are ultimately irrelevant to this discussion, you must
> manually load functions via a platform-specific API call. This boilerplate
> work is done with various OpenGL loading libraries; these make this process
> ... | 2011/12/06 | [
"https://Stackoverflow.com/questions/8395786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/906773/"
] | One of the main reasons is extensions: On every platform, OpenGL has always supported platform-specific extensions. These couldn't be part of the official headers, as they were usually added by the vendors in-between spec updates. In addition, those vendor-specific extensions may live in completely weird DLL/SO, for in... | On the Mac, you don't need to load function pointers, you just include a header and link against the OpenGL framework. |
73,207,456 | I have a custom converter for one of my object :
```
public class FooConverter : JsonConverter<Foo>
{
public override bool CanConvert( Type typeToConvert )
{
return typeof( Foo ).IsAssignableFrom( typeToConvert );
}
public override Foo? Read( ref Utf8JsonReader reader, Type typeToConvert, Json... | 2022/08/02 | [
"https://Stackoverflow.com/questions/73207456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9414420/"
] | The First element of Converters is the default converter,You could try
```
services.AddControllers().AddJsonOptions(x => x.JsonSerializerOptions.Converters.Insert(0, new FooConverter()));
```
Got into the Write Method successfully:
[](https://i.sta... | In your startup you are creating a new JsonSerializerOptions instead of configuring the provided options.
Try:
```
services
.AddControllers()
.AddJsonOptions(o =>
{
o.JsonSerializerOptions.Converters.Add(new FooConverter());
});
``` |
173,651 | I have a group research proposal assessment at my university, and my friend had previously completed the subject, so he gave me his assessment as guidance for how the proposal should look. His group and my group's research proposals are completely different, but the layout design of how the assessment is presented is q... | 2021/08/21 | [
"https://academia.stackexchange.com/questions/173651",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/145092/"
] | I think you are in the clear. As an example, most research papers in my area look the 'same'. This is because everyone uses the same template and tools. | This is completely fine.
Moreover, it is common in academia for this kind of conduct to be *encouraged*. And there is an important distinction.
If you take someone's book and copy the chapter list from there with minor alterations, it is a creative work dealing directly with the subject you both are working on. No bu... |
173,651 | I have a group research proposal assessment at my university, and my friend had previously completed the subject, so he gave me his assessment as guidance for how the proposal should look. His group and my group's research proposals are completely different, but the layout design of how the assessment is presented is q... | 2021/08/21 | [
"https://academia.stackexchange.com/questions/173651",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/145092/"
] | Note that what is plagiarism in the wider world might be different from what a professor considers plagiarism for purposes of assignments. Often the latter are far stricter than the former. So, we can't say here, since it is your professor that will make the determination.
However, in the wider context, you can't plag... | This is completely fine.
Moreover, it is common in academia for this kind of conduct to be *encouraged*. And there is an important distinction.
If you take someone's book and copy the chapter list from there with minor alterations, it is a creative work dealing directly with the subject you both are working on. No bu... |
42,754,508 | I have build couple of functions using jquery cookie plugin, I am having issue with making it work cross pages.
I have set.html page which sets cookies, and show.html which shows pages. Everytime someone views set.html random key value pair is added to the cookie.
When I log the data set.html looks like cookies are ... | 2017/03/12 | [
"https://Stackoverflow.com/questions/42754508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3081922/"
] | I use ng2-file-manager and easy file manager for angular 2
**link:** <https://github.com/jkuri/ng2-file-manager> | Here is an example of angular2 front end and PHP as a backend for [angular2 file manager](https://github.com/bhaskar-bhatt/angular-file-manager)
**Source** : <https://github.com/bhaskar-bhatt/angular-file-manager>
[](https://i.stack.imgur.com/lbpwe.p... |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | You need to pass a compare function to `std::sort`:
```
bool compare_c1 (c1* x, c1* y)
{
return *x < y;
}
std::sort(v.begin(), v.end(), compare_c1);
```
Or if you are using GCC >= 4.5 or Visual Studio 2010 (I'm do not know sure about Intel compiler) you can use lambdas (they are part of the C++0x standard):
```
... | Add a external operator< and keep de original one:
```
bool operator<(c1* a, c1* b) { return *a < *b; }
```
Now sort will work on the vector. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | The most straightforward approach is to define a function
```
bool c1_ptr_less( c1 const *lhs, c1 const *rhs ) {
return lhs->something < rhs->something;
}
std::sort( vec.begin(), vec.end(), & c1_ptr_less );
```
What I would suggest is a generic functor to take care of *all* pointer arrays
```
struct pointer_le... | phimuemue's answer sums it up, I'll just add that, as a workaround, you can create a wrapper class that contains only one member - a pointer to c1, and then overload its operator <. Then you could sort a vector of object of that class. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | To answer your title question, you can't.
Pointers are built-in types, you cannot override operators where all operands are built-in types.
Luckily, there's an overload of `std::sort` that allows you to specify a comparison function (or functor) so the `operator<` isn't used. | `bool operator < (c1 *w)` compares a `c1` to a `c1 *` - Your sort compares a `c1 *` to a `c1 *` |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | The most straightforward approach is to define a function
```
bool c1_ptr_less( c1 const *lhs, c1 const *rhs ) {
return lhs->something < rhs->something;
}
std::sort( vec.begin(), vec.end(), & c1_ptr_less );
```
What I would suggest is a generic functor to take care of *all* pointer arrays
```
struct pointer_le... | Add a external operator< and keep de original one:
```
bool operator<(c1* a, c1* b) { return *a < *b; }
```
Now sort will work on the vector. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | To answer your title question, you can't.
Pointers are built-in types, you cannot override operators where all operands are built-in types.
Luckily, there's an overload of `std::sort` that allows you to specify a comparison function (or functor) so the `operator<` isn't used. | phimuemue's answer sums it up, I'll just add that, as a workaround, you can create a wrapper class that contains only one member - a pointer to c1, and then overload its operator <. Then you could sort a vector of object of that class. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | You need to pass a compare function to `std::sort`:
```
bool compare_c1 (c1* x, c1* y)
{
return *x < y;
}
std::sort(v.begin(), v.end(), compare_c1);
```
Or if you are using GCC >= 4.5 or Visual Studio 2010 (I'm do not know sure about Intel compiler) you can use lambdas (they are part of the C++0x standard):
```
... | phimuemue's answer sums it up, I'll just add that, as a workaround, you can create a wrapper class that contains only one member - a pointer to c1, and then overload its operator <. Then you could sort a vector of object of that class. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | You need to pass a compare function to `std::sort`:
```
bool compare_c1 (c1* x, c1* y)
{
return *x < y;
}
std::sort(v.begin(), v.end(), compare_c1);
```
Or if you are using GCC >= 4.5 or Visual Studio 2010 (I'm do not know sure about Intel compiler) you can use lambdas (they are part of the C++0x standard):
```
... | And in your example, `vector<c1*>` is sorted. Just not to the
criteria you seem to want: by default, `sort` uses
`std::less<T>` as the ordering criteria, and `std::less<ci*>`
compares the pointers (which is what you'd expect). If you
don't want the default criteria, then you have to pass a third
argument to `sort`, a p... |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | The most straightforward approach is to define a function
```
bool c1_ptr_less( c1 const *lhs, c1 const *rhs ) {
return lhs->something < rhs->something;
}
std::sort( vec.begin(), vec.end(), & c1_ptr_less );
```
What I would suggest is a generic functor to take care of *all* pointer arrays
```
struct pointer_le... | To answer your title question, you can't.
Pointers are built-in types, you cannot override operators where all operands are built-in types.
Luckily, there's an overload of `std::sort` that allows you to specify a comparison function (or functor) so the `operator<` isn't used. |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | To answer your title question, you can't.
Pointers are built-in types, you cannot override operators where all operands are built-in types.
Luckily, there's an overload of `std::sort` that allows you to specify a comparison function (or functor) so the `operator<` isn't used. | And in your example, `vector<c1*>` is sorted. Just not to the
criteria you seem to want: by default, `sort` uses
`std::less<T>` as the ordering criteria, and `std::less<ci*>`
compares the pointers (which is what you'd expect). If you
don't want the default criteria, then you have to pass a third
argument to `sort`, a p... |
5,635,909 | i have
```
class c1{
public:
int number;
c1()
{
number=rand()%10;
}
bool operator < (c1 *w)
{
return number < w->number;
}
};
vector<c1*> vec = { ... }
sort(vec.begin(),vec.end())
```
why it dosent sort ?
but if we had
```
bool operator < (c1 w)
{
r... | 2011/04/12 | [
"https://Stackoverflow.com/questions/5635909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/704162/"
] | `bool operator < (c1 *w)` compares a `c1` to a `c1 *` - Your sort compares a `c1 *` to a `c1 *` | And in your example, `vector<c1*>` is sorted. Just not to the
criteria you seem to want: by default, `sort` uses
`std::less<T>` as the ordering criteria, and `std::less<ci*>`
compares the pointers (which is what you'd expect). If you
don't want the default criteria, then you have to pass a third
argument to `sort`, a p... |
10,239,508 | i am making an app that will have a very large dictionary of words i choose (so that the words aren't too complicated) and i want it to randomly choose the words. I dont have a problem with the randomly selecting words, but what would be the best way to store all these words, and how? I feel like using an NSMutable arr... | 2012/04/20 | [
"https://Stackoverflow.com/questions/10239508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159987/"
] | Core data!, is your best option, or to manage your own SQLite
check a [core data tutorial](http://www.raywenderlich.com/934/core-data-tutorial-getting-started)
or a [SQLite on iOS tutorial](http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application) | If all all the application needs to do is access words at random (so no key based queries, or updates), an alternative to core data and SQLite would be to just `fseek()` to a random location in a flat text file of newline delimited words and then read out the next complete word, possibly with `fscanf(dict,"%s\n%s\n",pa... |
23,492,027 | I've been searching everywhere for a definitive answer to what seems to be a really simple task - unfortunately all the solutions I can find (and there are a lot) use mysql\_fetch\_assoc which is deprecated.
All I'm trying to do is to take a two column set of results from a database and echo in JSON format - I've mana... | 2014/05/06 | [
"https://Stackoverflow.com/questions/23492027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1663528/"
] | You need to set the visibility in GetView. This is because a scrolling list view will reassign views in the list view to new rows, and if you set the visibility on a given row it will not be updated when that item moves to a new row. Note that this goes in both directions- if you want to show it you need to explicitly ... | This is how it worked for me
```
public class CustomAdapter extends BaseAdapter {
Context mContext;
ArrayList<ManagePartResponse> partList;
LayoutInflater mInflater;
static ViewHolder vh;
static boolean flag=false;
public CustomAdapter(Context context, ArrayList<ManagePartResponse> itemList) {
mContext = context;... |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | Try this: [FIND\_IN\_SET(str,strlist)](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set) | The problem is that you are searching within several lists.
You need something more like:
```
SELECT * FROM `user` WHERE id_site LIKE '%3%';
```
However, that will also select 33, 333 and 345 so you want some more advanced text parsing. |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | That's not how `IN` works. I can't be bothered to explain why, just [read the docs](http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in)
Try this:
```
SELECT * FROM `user` WHERE FIND_IN_SET(3,`id_site`)
```
Note that this requires your data to be `1,2,3`, `1,3` and `4,5` (ie no spaces). If ... | Try this: [FIND\_IN\_SET(str,strlist)](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set) |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | Try this: [FIND\_IN\_SET(str,strlist)](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set) | The WHERE IN clause is useful to replace many OR conditions.
For exemple
```
SELECT * FROM `user` WHERE id IN (1,2,3,4)
```
is cleaner than
```
SELECT * FROM `user` WHERE id=1 OR id=2 OR id=3 OR id=4
```
You're just trying to use it in a wrong way.
Correct way :
```
WHERE `field` IN (list_item1, list_item2 [, l... |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | That's not how `IN` works. I can't be bothered to explain why, just [read the docs](http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in)
Try this:
```
SELECT * FROM `user` WHERE FIND_IN_SET(3,`id_site`)
```
Note that this requires your data to be `1,2,3`, `1,3` and `4,5` (ie no spaces). If ... | The problem is that you are searching within several lists.
You need something more like:
```
SELECT * FROM `user` WHERE id_site LIKE '%3%';
```
However, that will also select 33, 333 and 345 so you want some more advanced text parsing. |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | **NO!** For relation databases
Your table doesn't comfort [first normal form](http://en.wikipedia.org/wiki/First_normal_form) (*"each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain"*) of a database and you:
* use string field to contain numbers
* s... | The problem is that you are searching within several lists.
You need something more like:
```
SELECT * FROM `user` WHERE id_site LIKE '%3%';
```
However, that will also select 33, 333 and 345 so you want some more advanced text parsing. |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | That's not how `IN` works. I can't be bothered to explain why, just [read the docs](http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in)
Try this:
```
SELECT * FROM `user` WHERE FIND_IN_SET(3,`id_site`)
```
Note that this requires your data to be `1,2,3`, `1,3` and `4,5` (ie no spaces). If ... | The WHERE IN clause is useful to replace many OR conditions.
For exemple
```
SELECT * FROM `user` WHERE id IN (1,2,3,4)
```
is cleaner than
```
SELECT * FROM `user` WHERE id=1 OR id=2 OR id=3 OR id=4
```
You're just trying to use it in a wrong way.
Correct way :
```
WHERE `field` IN (list_item1, list_item2 [, l... |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | That's not how `IN` works. I can't be bothered to explain why, just [read the docs](http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in)
Try this:
```
SELECT * FROM `user` WHERE FIND_IN_SET(3,`id_site`)
```
Note that this requires your data to be `1,2,3`, `1,3` and `4,5` (ie no spaces). If ... | **NO!** For relation databases
Your table doesn't comfort [first normal form](http://en.wikipedia.org/wiki/First_normal_form) (*"each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain"*) of a database and you:
* use string field to contain numbers
* s... |
24,631,949 | I want to execute a query where I can find one ID in a list of ID.
table `user`
```
id_user | name | id_site
-------------------------
1 | james | 1, 2, 3
1 | brad | 1, 3
1 | suko | 4, 5
```
and my query (doesn't work)
```
SELECT * FROM `user` WHERE 3 IN (`id_site`)
```
This query work (... | 2014/07/08 | [
"https://Stackoverflow.com/questions/24631949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442932/"
] | **NO!** For relation databases
Your table doesn't comfort [first normal form](http://en.wikipedia.org/wiki/First_normal_form) (*"each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain"*) of a database and you:
* use string field to contain numbers
* s... | The WHERE IN clause is useful to replace many OR conditions.
For exemple
```
SELECT * FROM `user` WHERE id IN (1,2,3,4)
```
is cleaner than
```
SELECT * FROM `user` WHERE id=1 OR id=2 OR id=3 OR id=4
```
You're just trying to use it in a wrong way.
Correct way :
```
WHERE `field` IN (list_item1, list_item2 [, l... |
3,071,124 | Let $P$ be an invertible matrix with n rows and n columns. Let $L$ be the following vector space: The elements in $L$ are matrices $X$ with n rows and n columns, such that $tr(PX)=0$. Find $dimL$. Here's what I did, please tell me if this is correct: Let $(p\_{i,j})$ be the elements of P. $P$ is invertible and thus $P ... | 2019/01/12 | [
"https://math.stackexchange.com/questions/3071124",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/547001/"
] | [](https://i.stack.imgur.com/gCq7u.png)
Let us first show that $\angle BXC=\angle BYC=90^\circ$.
Notice that triangle $ADE$ is isosceles so $\angle AED=90^\circ-\alpha/2$. It means that $\angle DEC=\angle XEC=90^\circ+\alpha/2$. We also know that $\a... | Let
$$A=(0,\ a)\\
B=(-b,\ 0)\\
C=(b,\ 0)$$
and thus
$$Z=(0,\ 0)$$
then we get
$$\tan(\angle ABC)=\frac ab$$
and thus
$$\tan(\frac 12\ \angle ABC)=\frac{a/b}{1+\sqrt{1+a^2/b^2}}=\frac a{b+\sqrt{a^2+b^2}}$$
So we can deduce the center $M$ of the incircle to be
$$M=(0,\ \frac {ab}{b+\sqrt{a^2+b^2}})$$
Now define lines ... |
71,796,911 | Within my KMM library I use sealed interfaces/classes to represent certain states/errors.
I decided to use sealed interfaces/classes because these states must have different associated objects.
In the Android code, this also works as expected without any problems.
But in the iOS part, I'm not able to detect the speci... | 2022/04/08 | [
"https://Stackoverflow.com/questions/71796911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4210002/"
] | I used a library at <https://github.com/icerockdev/moko-kswift> for the same problem. It gives you autogenerated swift enums with constructors that take your Obj C type generated from the sealed class in Kotlin, and also mapping back to the Obj C type. | I'd recommend not using your generated sealed classes from Swift. You don't get anything helpful from it, because it's awkward and there is no exhaustive `when` statement. It's much easier to use a callback that should execute when you get that sealed class. Here are a couple ways:
### Mutually exclusive Callbacks
``... |
11,429,673 | Hi I had added marquee tag in my application which works well in android simulator but when I install it on device it is not working. On device it doesn't show me marquee. Below is my code for marquee.
```
<marquee behavior="scroll" direction="left">Welcome To Jquery World</marquee>
``` | 2012/07/11 | [
"https://Stackoverflow.com/questions/11429673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455848/"
] | According to the console log the problem is here:
```
window.opener.closeReportWindow();
```
It says:
```
SCRIPT438: Object doesn't support property or method 'closeReportWindow'
```
Try this instead:
```
window.close();
```
Also update your jQuery to version 1.7.2. | **FIX UPDATE**
For some reason datatables didn't want to use the array fetched by window.opener even though it was received ok.
I fixed it by creating a new array and pushing the values into it. Then give the newArray data to datatables.
```
var newArray = [];
var historyArray = window.opener.historyArray;
for (... |
24,249,917 | I'm pretty new at when it comes to Java and I am having an issue with this new Program that I am designing. I believe it might have something to do with the Scanner, but I am not so sure. I apologize if my formatting is off, this is my first post. Any help would be appreciated.
```
package commissioncalculationprogram... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24249917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3745960/"
] | You should use the hasNextXXXX() methods from the Scanner class to make sure that there is an integer ready to be read.
The problem is you are called nextInt() which reads the next integer from the stream that the Scanner object points to, if there is no integer there to read (i.e. if the input is exhausted then you w... | ### input.nextInt() or input.nextDouble() etc...
Scanner throws: NoSuchElementException - if input is exhausted.
Are you sure input has more elements?
I would refactor the code as:
if(input!=null && input.hasNext()){
..
..
}
AND
if(input!=null && input.hasNextLine()){
..
..
} |
24,249,917 | I'm pretty new at when it comes to Java and I am having an issue with this new Program that I am designing. I believe it might have something to do with the Scanner, but I am not so sure. I apologize if my formatting is off, this is my first post. Any help would be appreciated.
```
package commissioncalculationprogram... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24249917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3745960/"
] | You should use the hasNextXXXX() methods from the Scanner class to make sure that there is an integer ready to be read.
The problem is you are called nextInt() which reads the next integer from the stream that the Scanner object points to, if there is no integer there to read (i.e. if the input is exhausted then you w... | I believe it has something to do with your scanner.
The scanner input method uses a buffer to capture and store the data entered.
Nextline will capture all data to the end of the return character, which, empties the buffer.
All the other scanner methods such as Nextint, capture data from the buffer till before the r... |
24,249,917 | I'm pretty new at when it comes to Java and I am having an issue with this new Program that I am designing. I believe it might have something to do with the Scanner, but I am not so sure. I apologize if my formatting is off, this is my first post. Any help would be appreciated.
```
package commissioncalculationprogram... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24249917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3745960/"
] | You should use the hasNextXXXX() methods from the Scanner class to make sure that there is an integer ready to be read.
The problem is you are called nextInt() which reads the next integer from the stream that the Scanner object points to, if there is no integer there to read (i.e. if the input is exhausted then you w... | I'm guessing you're running the app in a way that doesn't bind it to the console, and therefore `System.in` is just reading EOF. For example, you're running it through a (dumber) IDE or you're using an older version of Maven to execute it. Try running directly from the console (your command prompt) and see if it works.... |
17,512,956 | I want to compare two datagridviews, and use the `Except` method on the `IEnumerable` interface, in order to know the difference among them.
One example of my datagridviews:
```
DG1
idProduct Item
1 Item A
1 Item B
2 Item C
2 Item D
DG2
idProduct Item Price I... | 2013/07/07 | [
"https://Stackoverflow.com/questions/17512956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554904/"
] | Font size does not depend on button height. If you set it too small to fit the text, you will get the result you observe
**EDIT**
`wrap_content` would usually do the trick, however Button class sets some layout parameters like margin, background so it takes more space. You may get rid of Button and use i.e. `TextView... | Just Set android:minHeight="xxdp" |
52,827,048 | The following command has been executed:
```
CREATE TABLE film (
film_id NUMBER(5) NOT NULL,
title varchar2(255),
description varchar2(255),
release_year NUMBER(4) DEFAULT NULL,
language_id NUMBER(3) NOT NULL,
original_language_id NUMBER(3) DEFAULT NULL,
rental_duration NUMBER(3) DEFAULT 3 NOT NULL,
re... | 2018/10/16 | [
"https://Stackoverflow.com/questions/52827048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10510401/"
] | You can use instr function for the words `boat` and `in` with such a combination :
```
select film_description
from
(
with t(film_description) as
(
select '... a Teacher in The Canadian Rockies' from dual union all
select 'Boat on the river' from dual union all
select 'on the river in a Boat' from dual union all
... | Maybe the query can look like this:
```
SELECT *
FROM "FILM"
WHERE UPPER("DESCRIPTION") LIKE '%IS%BOAT%'
AND ROWNUM<200;
``` |
37,145,453 | I am looping through a column and count the number of times each row appears in another column. This works once, displaying the correct counts. However in subsequent it only displys zero for all rows. I stepped through the code and the counter values won't update. I appreciate it if somebody take a look.
```
Sub c... | 2016/05/10 | [
"https://Stackoverflow.com/questions/37145453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/633426/"
] | I got it now. The issue may be the `Range("I"&j).Value` with the unspecified worksheet. After I specified it with `CWData`, it works.
LESSON: When working with ranges from different worksheets, make sure to prefix all functions with the correct worksheet name.
```
For i = 2 To 10
'' Start the counters fresh for ... | ```
Sub count_tic_types()
Dim ticCountGraph As Worksheet
Dim CWData As Worksheet
'' Row count for ticCountGraph.
Dim i As Integer
'' Row count for CWData
Dim j As Integer
Dim ticCount As Integer
Dim ticAlert As Integer
Set ticCoun... |
67,602,413 | I just started learning Laravel, I'm newbie. I've got a problem, I'm watching Laravel Course for beginners and learning, was doing exactly the same as in he tutorial, but still ended up with a problem. I hope to find a solution soon. I'll explain it a little bit.
The project is kind of a clone of Instagram. Users can p... | 2021/05/19 | [
"https://Stackoverflow.com/questions/67602413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10457008/"
] | this is a silly mistake of you..you are adding same post twice. once with relationship association and again from post model.
```
auth()->user()->posts()->create($data);
\App\Models\Post::create($data); //this is causing the issue here.
```
with relationship association `auth()->user()->posts()->create($data)`, pos... | Note:: you need to use Post Model and you can directly create data Using Post::create() method.
```
//Import Data
use Illuminate\Http\Request;
use App\Modes\Post;
class PostsController extends Controller
{
public function create()
{
return view('posts.create');
}
public function store(Request... |
39,618,268 | I made a code.
In this code, when i click a map, there will be a marker on clicked point.
**This is my Code**
```
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCre... | 2016/09/21 | [
"https://Stackoverflow.com/questions/39618268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6736285/"
] | Throughout your controller and test you use `User_type.all`, `User_type.build`, `User_type.new`, but your model is named `UserType`. | Your model's class name is `UserType`. `User_type` is not defined anywhere. You either keep the model name as is and fix your test and controller, or rename the model name. The former is the Rails convention, so I'd suggest you go with that (the CamelCased name). |
39,618,268 | I made a code.
In this code, when i click a map, there will be a marker on clicked point.
**This is my Code**
```
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCre... | 2016/09/21 | [
"https://Stackoverflow.com/questions/39618268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6736285/"
] | Throughout your controller and test you use `User_type.all`, `User_type.build`, `User_type.new`, but your model is named `UserType`. | Change your model name to `UserType` as defined in class and from that `UserType` model's table remove `type` column or rename it to something like `user_type` since that is a reserved column name, can be used for single table inheritance only. |
31,124,094 | Actually I'm handling 3 languages in my app so I have:
`values/strings.xml`
`values-it/strings.xml`
`values-de/strings.xml`
When I install the app, it is properly installed in the current language of the device.
But if I change the language of the device, the language of the app doesn't switch. I have to reinstall ... | 2015/06/29 | [
"https://Stackoverflow.com/questions/31124094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492034/"
] | If the file is not fixed length, you are out of luck. Some function will have to read the file. If the file is fixed length, you can open the file, use the function `file.seek(line*linesize)`. Then read the file from there. | If the file to read is big, and you don't want to read the whole file in memory at once:
```
fp = open("file")
for i, line in enumerate(fp):
if i == 25:
# 26th line
elif i == 29:
# 30th line
elif i > 29:
break
fp.close()
```
Note that `i == n-1` for the nth line. |
31,124,094 | Actually I'm handling 3 languages in my app so I have:
`values/strings.xml`
`values-it/strings.xml`
`values-de/strings.xml`
When I install the app, it is properly installed in the current language of the device.
But if I change the language of the device, the language of the app doesn't switch. I have to reinstall ... | 2015/06/29 | [
"https://Stackoverflow.com/questions/31124094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492034/"
] | If the file is not fixed length, you are out of luck. Some function will have to read the file. If the file is fixed length, you can open the file, use the function `file.seek(line*linesize)`. Then read the file from there. | You can use the method `fileObject.seek(offset[, whence])`
```
#offset -- This is the position of the read/write pointer within the file.
#whence -- This is optional and defaults to 0 which means absolute file positioning, other values are 1 which means seek relative to the current position and 2 means seek relative ... |
31,124,094 | Actually I'm handling 3 languages in my app so I have:
`values/strings.xml`
`values-it/strings.xml`
`values-de/strings.xml`
When I install the app, it is properly installed in the current language of the device.
But if I change the language of the device, the language of the app doesn't switch. I have to reinstall ... | 2015/06/29 | [
"https://Stackoverflow.com/questions/31124094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492034/"
] | If the file is not fixed length, you are out of luck. Some function will have to read the file. If the file is fixed length, you can open the file, use the function `file.seek(line*linesize)`. Then read the file from there. | python has no way to skip "lines" in a file. the best way that I know is to employ a generator to yield lines based on certain condition, i.e. `date > 'YYYY-MM-DD'`. At least this way you reduce memory usage & time spent on i/o.
example:
```
# using python 3.4 syntax (parameter type annotation)
from datetime import ... |
31,124,094 | Actually I'm handling 3 languages in my app so I have:
`values/strings.xml`
`values-it/strings.xml`
`values-de/strings.xml`
When I install the app, it is properly installed in the current language of the device.
But if I change the language of the device, the language of the app doesn't switch. I have to reinstall ... | 2015/06/29 | [
"https://Stackoverflow.com/questions/31124094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492034/"
] | If the file is not fixed length, you are out of luck. Some function will have to read the file. If the file is fixed length, you can open the file, use the function `file.seek(line*linesize)`. Then read the file from there. | As others have commented python doesn't support this as it doesn't know where lines start and end (unless they're fixed length). If you're doing this repeatedly I'd recommend either padding out the lines to a constant length (if practical) or failing that reading them into some kind of basic database. You'll take a bit... |
73,076,007 | can anyone tell how to make Responsive UI in Swift UI, which is compatible on all Device , and using figma Text like 24 then it shows iphone 8 and iphone 11 same view | 2022/07/22 | [
"https://Stackoverflow.com/questions/73076007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9830325/"
] | You'll want to minimize the amount of hardcoded sizes or frames in your app as that will make your app less responsive across different phone models and orientations. Here are some links you can check out to learn responsive UI:
<https://www.youtube.com/watch?v=67ZCQ5ihj_I&t=186s>
<https://www.youtube.com/watch?v=ALz... | For images you can do something like this. You can use **GeometryReader** class to make your images responsive. Do not use hardcoded size for images. In this snippet I used 50% width of the screen and for height it will also take 50% of the height.
*Also Be careful using GeometryReader class. The GeometryProxy returns... |
73,076,007 | can anyone tell how to make Responsive UI in Swift UI, which is compatible on all Device , and using figma Text like 24 then it shows iphone 8 and iphone 11 same view | 2022/07/22 | [
"https://Stackoverflow.com/questions/73076007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9830325/"
] | You'll want to minimize the amount of hardcoded sizes or frames in your app as that will make your app less responsive across different phone models and orientations. Here are some links you can check out to learn responsive UI:
<https://www.youtube.com/watch?v=67ZCQ5ihj_I&t=186s>
<https://www.youtube.com/watch?v=ALz... | A better way to do it without wrapping all your views in a geometry reader is to make an extension to get the screen with and height, which is also callable on all pages without having to do the extension on every page like a geometryreader.
```
extension View{
func getScreenBounds() -> CGRect{
return UIScreen.m... |
4,960,790 | I've seen questions and answers about how to specify external .groovy and .properties files for Grails config that are outside of the WAR file using grails.config.locations, but we need external config that isn't on the server on which the container (Tomcat) is running.
(It does have a local FS, but it is not persistie... | 2011/02/10 | [
"https://Stackoverflow.com/questions/4960790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/295027/"
] | Yes. The following works:
Add this in Config.groovy and pass PARAM1 using -D to the JVM to specify the external URL for the config file.
```
grails.config.locations = ["url:" + System.properties["PARAM1"]]
``` | I am not aware of any built in functionality that would allow you to specify URL for grails.config. However, it seems like something that you could implement yourself:
* define your URL(s) that you want to use to d/l the Congif.groovy file that is included in your WAR
* in that same Config.groovy script, write code to... |
70,843,193 | I have a pine script to draw previous day high/open/low as shown below:
```
//@version=4
strategy("Plot Lines", overlay=true)
PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)
plot(PDH, title="High",color=color.red,linewidth=2,trackprice=true... | 2022/01/25 | [
"https://Stackoverflow.com/questions/70843193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15002748/"
] | Great answer by @vitruvius, but I wanted to add a little something.
There's no need to draw lines and remove the old ones. You can just define them once, and move them on the last bar. Also, the values can be requested in one single `security()` call.
```
//@version=5
indicator("Plot Lines", overlay=true)
f_newLin... | You can use the `line()` function instead of `plot()`.
Draw the lines if it is the last bar, and delete the previous ones along the way.
```
//@version=4
study("Plot Lines", overlay=true)
PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)
var... |
70,843,193 | I have a pine script to draw previous day high/open/low as shown below:
```
//@version=4
strategy("Plot Lines", overlay=true)
PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)
plot(PDH, title="High",color=color.red,linewidth=2,trackprice=true... | 2022/01/25 | [
"https://Stackoverflow.com/questions/70843193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15002748/"
] | You can use the `line()` function instead of `plot()`.
Draw the lines if it is the last bar, and delete the previous ones along the way.
```
//@version=4
study("Plot Lines", overlay=true)
PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)
var... | Not exactly what you asked, but it could lead you in the right direction:
```js
//@version=5
indicator("My script", overlay = true)
resolution = 'D'
var float highSecurityValue = na
var float lowSecurityValue = na
var float closeSecurityValue = na
fNoRepainting(timeframe, expression) =>
request.security(sy... |
70,843,193 | I have a pine script to draw previous day high/open/low as shown below:
```
//@version=4
strategy("Plot Lines", overlay=true)
PDH = security(syminfo.tickerid,"D",high)
PDO = security(syminfo.tickerid,"D",open)
PDL = security(syminfo.tickerid,"D",low)
plot(PDH, title="High",color=color.red,linewidth=2,trackprice=true... | 2022/01/25 | [
"https://Stackoverflow.com/questions/70843193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15002748/"
] | Great answer by @vitruvius, but I wanted to add a little something.
There's no need to draw lines and remove the old ones. You can just define them once, and move them on the last bar. Also, the values can be requested in one single `security()` call.
```
//@version=5
indicator("Plot Lines", overlay=true)
f_newLin... | Not exactly what you asked, but it could lead you in the right direction:
```js
//@version=5
indicator("My script", overlay = true)
resolution = 'D'
var float highSecurityValue = na
var float lowSecurityValue = na
var float closeSecurityValue = na
fNoRepainting(timeframe, expression) =>
request.security(sy... |
136,926 | Bit of a strange one.
I have put a script in the miscellaneous scripts section in
**Configuration->General->Design**, but it is not showing when I look at the page source. I have tried putting `<script>code here</script>` and just plain text, such as 12345, but when I refresh the website, it does not show in the page ... | 2016/09/18 | [
"https://magento.stackexchange.com/questions/136926",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/33627/"
] | I couldn't reproduce your error, but I got an other one.
Then I did some minor adjustments to your code and it worked.
First drop the `InstallSchema.php` file. It does nothing so it is useless.
Then make sure that your plugin file is in `Amaj/CorePlugin/Model/Currency/Plugin.php` and it looks like this:
```
<?p... | For the purpose of example, i have added below code and it is working fine.
Check this approach may be this can be helpful.
Your model(result.php) is not in correct place.
\magento\vendor\magento\module-contact\etc\frontend\di.xml
```
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
... |
26,694 | In Genesis 19, Lot defends the angels who came under his roof against the demands of the local men who want a chance to sodomize the three visitors. From the Torah's description, and Rashi's take on it, it would appear that this was a common practice by Sodomites against new-comers. My question is, wouldn't they have a... | 2013/02/28 | [
"https://judaism.stackexchange.com/questions/26694",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2212/"
] | Lot surveyed the whole land and chose Sodom. (Gen 13) He presumably wouldn't have done so if they had such a reputation, let alone stayed if he was actually subject to such treatment.
MORE importantly - Lot arrived in Sodom at a time when he was extremely wealthy (Gen 13). Its very possible that the angels were targe... | Sodom was about "no freeloaders." You try to mooch, we rape you.
Lot came in with money and was accepted. Hence, no rape.
Remember, the Jewish interpretation is that Sodom wasn't about lust. It was about power and cruelty; rape was just a tool in the box. |
26,694 | In Genesis 19, Lot defends the angels who came under his roof against the demands of the local men who want a chance to sodomize the three visitors. From the Torah's description, and Rashi's take on it, it would appear that this was a common practice by Sodomites against new-comers. My question is, wouldn't they have a... | 2013/02/28 | [
"https://judaism.stackexchange.com/questions/26694",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2212/"
] | Lot surveyed the whole land and chose Sodom. (Gen 13) He presumably wouldn't have done so if they had such a reputation, let alone stayed if he was actually subject to such treatment.
MORE importantly - Lot arrived in Sodom at a time when he was extremely wealthy (Gen 13). Its very possible that the angels were targe... | Continuing from @Shalom's point, Lot carried a degree of protekzia by virtue of the fact that he was Avraham's nephew.
It writes in the [Zohar I:108a](https://www.sefaria.org/Zohar.1.108a.6?lang=bi&with=all&lang2=en) and then continues in [108b](https://www.sefaria.org/Zohar.1.108b.1?lang=bi&with=all&lang2=en) that Lo... |
26,694 | In Genesis 19, Lot defends the angels who came under his roof against the demands of the local men who want a chance to sodomize the three visitors. From the Torah's description, and Rashi's take on it, it would appear that this was a common practice by Sodomites against new-comers. My question is, wouldn't they have a... | 2013/02/28 | [
"https://judaism.stackexchange.com/questions/26694",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2212/"
] | Sodom was about "no freeloaders." You try to mooch, we rape you.
Lot came in with money and was accepted. Hence, no rape.
Remember, the Jewish interpretation is that Sodom wasn't about lust. It was about power and cruelty; rape was just a tool in the box. | Continuing from @Shalom's point, Lot carried a degree of protekzia by virtue of the fact that he was Avraham's nephew.
It writes in the [Zohar I:108a](https://www.sefaria.org/Zohar.1.108a.6?lang=bi&with=all&lang2=en) and then continues in [108b](https://www.sefaria.org/Zohar.1.108b.1?lang=bi&with=all&lang2=en) that Lo... |
33,283,988 | I have a class for handling errors, and it is not using the `try-throw-catch` mechanism.
When I am commenting code that uses that class, should I use the the `@throws` tag even though I do not actually throwing anything?
**EDIT (try to make my question more clear):**
My question is if the `@throws` tags means that a... | 2015/10/22 | [
"https://Stackoverflow.com/questions/33283988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1925272/"
] | After reading [the documentation](http://phpdoc.org/docs/latest/references/phpdoc/tags/throws.html), I realize that this is not exactly spelled out.
The documentation on `@throws` suggests that if the `throw` keyword is present at all inside the block of code, then it should be documented for each type of exception th... | Putting annotation @throws marked this method as insecure. The client should be prepared to handle this exception when calling this method. |
455,137 | I'm looking for a HTTP compression proxy. Basically, I need a proxy to compress images and text to be transferred over a slow internet connection when accessing the web. To put it into a diagram
CLIENT ---/fast local network/--- HTTP COMPRESSION PROXY ---/slow internet connection/--- WEB (e.g. Facebook, Wiki, Google)
... | 2012/12/05 | [
"https://serverfault.com/questions/455137",
"https://serverfault.com",
"https://serverfault.com/users/148305/"
] | A quick review of the documentation leads me to believe that squid will accept and cache compressed data from the servers. Compressing images will likely be counter productive. Most image formats are well compressed already and attempts to compress them usually increase the image size by the overhead of the compression... | Do you realize that Image data does not compress very well. It often takes more time in these cases to compress/transmit/uncompress than to simply transmit the image data without compression. |
5,666,456 | I want to convert the data in a wire to an integer. For example:
```
wire [2:0] w = 3'b101;
```
I want a method that converts this to '5' and stores it in an integer. How can I do that in a better way than this:
```
j=1;
for(i=0; i<=2; i=i+1)
begin
a=a+(w[i]*j);
j=j*2;
end
```
Also, how do I convert it bac... | 2011/04/14 | [
"https://Stackoverflow.com/questions/5666456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556167/"
] | Easy! Conversion is automatic in verilog if you assign to an integer. In verilog, all the data types are just collection on bits.
```
integer my_int;
always @( w )
my_int = w;
``` | As Marty said : conversion between bit vectors and integers is automatic.
But there are a number of pitfalls. They are obvious if you keep in mind that an integer is a 32 bit signed value.
* Don't try to assign e.g. a 40 bit value to an integer.
* Default bit vector are unsigned so a 32 bit vector may become negative... |
22,966,594 | I understand that CouchDB hashes the source of each design documents against the name of the index file. Whenever I change the source code, the index needs to be rebuild. CouchDB does this when the document is requested for the first time.
**What I'd expect to happen and want to happen**
Each time I change a design ... | 2014/04/09 | [
"https://Stackoverflow.com/questions/22966594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/909227/"
] | It is a known issue, but just in case: if you have gigabytes of docs, you can forget about reduce functions. Only [build-in ones](https://wiki.apache.org/couchdb/Built-In_Reduce_Functions) will work fast enough. | It is possible to set [os\_process\_limit](http://couchdb.readthedocs.org/en/latest/config/query-servers.html#query_server_config/os_process_limit) to an extra-low value (1 sec, for sample). This way you can detect which doc takes long to be indexed and optimize your map function for performance. |
415,315 | I have this code :
```
for file in "$@"*png; do
echo "$file"
done
```
It works only if you provide a path that ends with / like `/root/`.
What would be the correct way to add / to the path input, in situations like this, without breaking my script?
If you give a path input without / at the end, it just does t... | 2018/01/07 | [
"https://unix.stackexchange.com/questions/415315",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/119404/"
] | ilkkachu pointed out a major flaw in my answer and corrected it in his so please give him the credit he deserves. I've come up with another solution though:
```
#!/bin/bash
for dir in "$@"; do
find "$dir" -type f -name '*png' -exec readlink -f {} \;
done
```
**Example**:
```
$ ll
total 6
-rwxr-xr-x 1 root... | Using `$@` with the glob like that seems somewhat odd. If you expect it to be able to process multiple arguments, well, it won't work. The strings surrounding `$@` are only attached to the first and list item.
```
$ mkdir a b; touch a/a.png b/b.png
$ set -- a b
$ echo x"$@"x
xa bx
$ echo "$@/"*.png
a b/b.png
```
So... |
415,315 | I have this code :
```
for file in "$@"*png; do
echo "$file"
done
```
It works only if you provide a path that ends with / like `/root/`.
What would be the correct way to add / to the path input, in situations like this, without breaking my script?
If you give a path input without / at the end, it just does t... | 2018/01/07 | [
"https://unix.stackexchange.com/questions/415315",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/119404/"
] | ilkkachu pointed out a major flaw in my answer and corrected it in his so please give him the credit he deserves. I've come up with another solution though:
```
#!/bin/bash
for dir in "$@"; do
find "$dir" -type f -name '*png' -exec readlink -f {} \;
done
```
**Example**:
```
$ ll
total 6
-rwxr-xr-x 1 root... | You can use tr too.
Always add / at the end and ...
```
file='/root/test//sample2.png';echo "$file" | tr -s '/'
``` |
415,315 | I have this code :
```
for file in "$@"*png; do
echo "$file"
done
```
It works only if you provide a path that ends with / like `/root/`.
What would be the correct way to add / to the path input, in situations like this, without breaking my script?
If you give a path input without / at the end, it just does t... | 2018/01/07 | [
"https://unix.stackexchange.com/questions/415315",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/119404/"
] | Using `$@` with the glob like that seems somewhat odd. If you expect it to be able to process multiple arguments, well, it won't work. The strings surrounding `$@` are only attached to the first and list item.
```
$ mkdir a b; touch a/a.png b/b.png
$ set -- a b
$ echo x"$@"x
xa bx
$ echo "$@/"*.png
a b/b.png
```
So... | You can use tr too.
Always add / at the end and ...
```
file='/root/test//sample2.png';echo "$file" | tr -s '/'
``` |
26,621,384 | I'm trying to create a python program that can average the speed a car is going. However, their are different roads this speeds are found on (these are represented with numbers 0-9) the file could have any road number and could be any speed.
```
Example1.txt
0 40km
1 30km
0 67km
2 45km
2 23km
```
The... | 2014/10/29 | [
"https://Stackoverflow.com/questions/26621384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4072497/"
] | What you need to do is keep track of all speeds *for each road*, rather than just a list of all speeds and a list of all roads.
One way to do this is with a dictionary: the keys are the roads, and the values are a list or set\* of speeds for that road. You can use `collections.defaultdict(list)` (or `…(set)`) to make ... | [collections.defaultdict](https://docs.python.org/2/library/collections.html#collections.defaultdict) and [collections.Counter](https://docs.python.org/2/library/collections.html#collections.Counter) will be useful:
```
from collections import defaultdict,Counter
d = defaultdict(float)
count = Counter() # get count ... |
659,880 | So, I've been following the *Lectures on the Geometric Anatomy of Theoretical Physics* by
Frederic Schuller on Youtube (I'm about half way in) and now I've been looking at some special relativity (something I haven't really touched in 1-2 years). Let us start with a short naration about what I think I have clarified on... | 2021/08/17 | [
"https://physics.stackexchange.com/questions/659880",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/307740/"
] | The position $x^\mu$ is *not* a four-vector - it is a co-ordinate. $x^\mu=\phi(p)$ where $\phi$ is a chart and $p\in M$ is an event in Minkowski space. Since Minkowski space is *globally* like $\mathbf{R}^n$ we only need the one chart.
Likewise a Lorentz transformation $\Lambda$ corresponds to a change of chart.
$$\La... | In special relativity, the metric in standard $(t, x, y, z)$ coordinates is just the identity matrix, with either the tt component equal to -1, or all of the spatial indices equal to -1.
In this basis, when you compute the lorentz transformation matrices, you will find that the inverse and the transpose are the same t... |
42,315,269 | I am a beginner and I would like to ask you something.
We have an array whose size depends on value input by user in a variable ‘arraysize’. Look at below code and comments please, is it a correct way to achieve this said be behaviour?
```
int * myArray = NULL;
int arraySize;
cout << "Enter array size: ";
cin >> arra... | 2017/02/18 | [
"https://Stackoverflow.com/questions/42315269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7585042/"
] | You want to replace `abc` only at the start of a word and only when it is not followed with another letter. Use
```
replaceAll("\\bapp(?![a-zA-Z])", "code")
```
If you want `abc` to be followed with a word boundary or underscore, the pattern can also be
```
"\\bapp(?=\\b|_)"
``` | Try this:
```
public static void main(String []args){
Assert.assertEquals("code", repl("app"));
Assert.assertEquals("code_abc",repl("app_abc"));
Assert.assertEquals("appabc",repl("appabc"));
Assert.assertEquals("appa_bc",repl("appa_bc"));
Assert.assertEquals("fooapp",repl("fooap... |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In most languages (pretty well everything other than C++), compiling individual compilation units is quite fast.
Binding/linking is often what's slow - the linker has to reference the whole program rather than just a single unit.
C++ suffers as - unless you use the pImpl idiom - it requires the implementation detai... | In the old days you could get dramatic speedups by setting up a RAM drive and compiling there. Don't know if this still holds true, though. |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your main problem today is I/O. Your CPU is many times faster than main memory and memory is about 1000 times faster than accessing the hard disk.
So unless you do extensive optimizations to the source code, the CPU will spend most of the time waiting for data to be read or written.
Try these rules:
1. Design your c... | A simple one: make sure the compiler can natively take advantage of multi-core CPUs. |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your main problem today is I/O. Your CPU is many times faster than main memory and memory is about 1000 times faster than accessing the hard disk.
So unless you do extensive optimizations to the source code, the CPU will spend most of the time waiting for data to be read or written.
Try these rules:
1. Design your c... | In most languages (pretty well everything other than C++), compiling individual compilation units is quite fast.
Binding/linking is often what's slow - the linker has to reference the whole program rather than just a single unit.
C++ suffers as - unless you use the pImpl idiom - it requires the implementation detai... |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here are some performance tricks that we've learned by measuring compilation speed and what affects it:
* Write a two-pass compiler: characters to IR, IR to code. (It's easier to write a *three*-pass compiler that goes characters -> AST -> IR -> code, but it's not as fast.)
* As a corollary, don't have an optimizer; ... | it depends on what language/platform you're programming for. for .NET development, minimise the number of projects that you have in your solution. |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've implemented a compiler myself, and ended up having to look at this once people started batch feeding it hundreds of source files. I was quite suprised what I found out.
It turns out that the most important thing you can optimize is not your grammar. It's not your lexical analyzer or your parser either. Instead, t... | it depends on what language/platform you're programming for. for .NET development, minimise the number of projects that you have in your solution. |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your main problem today is I/O. Your CPU is many times faster than main memory and memory is about 1000 times faster than accessing the hard disk.
So unless you do extensive optimizations to the source code, the CPU will spend most of the time waiting for data to be read or written.
Try these rules:
1. Design your c... | >
> what are ways i could minimize its compile time?
>
>
>
* No compilation (interpreted language)
* Delayed (just in time) compilation
* Incremental compilation
* Precompiled header files |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Eiffel had an idea of different states of frozen, and recompiling didn't necessarily mean that the whole class was recompiled.
How much can you break up the compliable modules, and how much do you care to keep track of them? | it depends on what language/platform you're programming for. for .NET development, minimise the number of projects that you have in your solution. |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Your main problem today is I/O. Your CPU is many times faster than main memory and memory is about 1000 times faster than accessing the hard disk.
So unless you do extensive optimizations to the source code, the CPU will spend most of the time waiting for data to be read or written.
Try these rules:
1. Design your c... | Make a build system that doesn't suck!
There's a huge amount of programs out there with maybe 3 source files that take under a second to compile, but before you get that far you'd have to sit through an automake script that takes about 2 minutes checking things like the size of an `int`. And if you go to compile somet... |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> what are ways i could minimize its compile time?
>
>
>
* No compilation (interpreted language)
* Delayed (just in time) compilation
* Incremental compilation
* Precompiled header files | Make a build system that doesn't suck!
There's a huge amount of programs out there with maybe 3 source files that take under a second to compile, but before you get that far you'd have to sit through an automake script that takes about 2 minutes checking things like the size of an `int`. And if you go to compile somet... |
576,693 | I was thinking more about the programming language i am designing. and i was wondering, what are ways i could minimize its compile time? | 2009/02/23 | [
"https://Stackoverflow.com/questions/576693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've implemented a compiler myself, and ended up having to look at this once people started batch feeding it hundreds of source files. I was quite suprised what I found out.
It turns out that the most important thing you can optimize is not your grammar. It's not your lexical analyzer or your parser either. Instead, t... | I haven't seen much work done for minimizing the compile time. But some ideas do come to mind:
1. Keep the grammar simple. Convoluted grammar will increase your compile time.
2. Try making use of parallelism, either using multicore GPU or CPU.
3. Benchmark a modern compiler and see what are the bottlenecks and what yo... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | `moment.duration(x).format()` has been deprecated.
You can use`moment.utc(4366589).format("HH:mm:ss")` to get the desired response.
```js
console.log(moment.utc(4366589).format("HH:mm:ss"))
```
```html
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/lib... | If you use Angular >2, I made a Pipe inspired by @hai-alaluf answer.
```
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "duration",
})
export class DurationPipe implements PipeTransform {
public transform(value: any, args?: any): any {
// secs to ms
value = value * 1000;
const day... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | ```
var diff = moment(end).unix() - moment(start).unix();
moment.utc(moment.duration(diff).asMilliseconds()).format("HH:mm:ss.SSS");
``` | ```
import * as moment from 'moment'
var sleep = require('sleep-promise');
(async function () {
var t1 = new Date().getTime();
await sleep(1000);
var t2 = new Date().getTime();
var dur = moment.duration(t2-t1);
console.log(`${dur.hours()}h:${dur.minutes()}m:${dur.seconds()}s`);
})();
```
```
0h... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | My solution that does not involve any other library and it works with diff > 24h
```
var momentInSeconds = moment.duration(n,'seconds')
console.log(("0" + Math.floor(momentInSeconds.asHours())).slice(-2) + ':' + ("0" + momentInSeconds.minutes()).slice(-2) + ':' + ("0" + momentInSeconds.seconds()).slice(-2))
``` | ```
import * as moment from 'moment'
var sleep = require('sleep-promise');
(async function () {
var t1 = new Date().getTime();
await sleep(1000);
var t2 = new Date().getTime();
var dur = moment.duration(t2-t1);
console.log(`${dur.hours()}h:${dur.minutes()}m:${dur.seconds()}s`);
})();
```
```
0h... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | if diff is a moment
```
var diff = moment(20111031) - moment(20111010);
var formated1 = moment(diff).format("hh:mm:ss");
console.log("format 1: "+formated1);
``` | To format moment duration to string
```
var duration = moment.duration(86400000); //value in milliseconds
var hours = duration.hours();
var minutes = duration.minutes();
var seconds = duration.seconds();
var milliseconds = duration.milliseconds();
var date = moment().hours(hours).minutes(minutes).seconds(seconds).mil... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | ```
var diff = moment(end).unix() - moment(start).unix();
moment.utc(moment.duration(diff).asMilliseconds()).format("HH:mm:ss.SSS");
``` | Short version (**one-liner**):
```
moment.duration(durationInMs).asHours()|0||"00" + ":" + moment.utc(durationInMs).format("mm:ss")
```
*Extended version:*
```
export const formatDuration = (durationInMs) => {
const hours = Math.floor(moment.duration(durationInMs).asHours()) || "00"
return hours + ":" + mom... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | Use this plugin [Moment Duration Format](https://github.com/jsmreese/moment-duration-format).
Example:
```
moment.duration(123, "minutes").format("h:mm");
``` | Based on [ni-ko-o-kin's answer](https://stackoverflow.com/a/44071876):
```
meassurements = ["years", "months", "weeks", "days", "hours", "minutes", "seconds"];
withPadding = (duration) => {
var step = null;
return meassurements.map((m) => duration[m]()).filter((n,i,a) => {
var nonEmpty = Boolean(n);
... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | Use this plugin [Moment Duration Format](https://github.com/jsmreese/moment-duration-format).
Example:
```
moment.duration(123, "minutes").format("h:mm");
``` | If you're willing to use a different javascript library, [numeral.js](http://numeraljs.com/) can format seconds as follows (example is for 1000 seconds):
```
var string = numeral(1000).format('00:00');
// '00:16:40'
``` |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | Use this line of code:
```
moment.utc(moment.duration(4500, "seconds").asMilliseconds()).format("HH:mm:ss")
``` | How about native javascript?
```
var formatTime = function(integer) {
if(integer < 10) {
return "0" + integer;
} else {
return integer;
}
}
function getDuration(ms) {
var s1 = Math.floor(ms/1000);
var s2 = s1%60;
var m1 = Math.floor(s1/60);
var m2 = m1%60;
var h1 = Mat... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | convert duration to ms and then to moment:
```
moment.utc(duration.as('milliseconds')).format('HH:mm:ss')
``` | ```
import * as moment from 'moment'
var sleep = require('sleep-promise');
(async function () {
var t1 = new Date().getTime();
await sleep(1000);
var t2 = new Date().getTime();
var dur = moment.duration(t2-t1);
console.log(`${dur.hours()}h:${dur.minutes()}m:${dur.seconds()}s`);
})();
```
```
0h... |
13,262,621 | Is there any way I can use the [moment.js](http://momentjs.com/) `format` method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects.
I'd like to be able to do something like:
```
var diff = moment(end).unix() - moment(start).unix();
moment.duration(dif... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13262621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133414/"
] | Short version (**one-liner**):
```
moment.duration(durationInMs).asHours()|0||"00" + ":" + moment.utc(durationInMs).format("mm:ss")
```
*Extended version:*
```
export const formatDuration = (durationInMs) => {
const hours = Math.floor(moment.duration(durationInMs).asHours()) || "00"
return hours + ":" + mom... | If you use Angular >2, I made a Pipe inspired by @hai-alaluf answer.
```
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "duration",
})
export class DurationPipe implements PipeTransform {
public transform(value: any, args?: any): any {
// secs to ms
value = value * 1000;
const day... |
31,542,454 | I have been using an Arduino Uno to connect to IoT Foundation on Bluemix. I've used both the Quickstart and the Registered devices. So far I've found that connecting to either service is intermittent. Currently I cannot connect my device (using IBM internal IP) to the quickstart.
I've set this up and tested in the pa... | 2015/07/21 | [
"https://Stackoverflow.com/questions/31542454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2252757/"
] | Quickstart will not respond to ping, which is why you get a timeout when pinging that hostname.
Using mosquitto (<http://mosquitto.org/>) I use the following as a simple test when debugging issues like this -- are you sure your arduino isn't having networking issues as all seems fine when I connect?
Make a subscript... | We have also had issues with connections and outages when working with Bluemix. Another issue we faced was with the length of messages in the suggested [MQTT library](https://github.com/256dpi/arduino-mqtt/pull/5).
We ended up using ATSD instead of Bluemix for our IOT use cases with Arduino Uno devices and DHT sensors... |
71,662,525 | When I'm trying to build the Next.Js app then the below error is coming with a successful build. This error is showing when I deploy the app in Vercel.
```
error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
```
This is my **.eslintrc.json**
```
{
"exte... | 2022/03/29 | [
"https://Stackoverflow.com/questions/71662525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8546303/"
] | I think, this might have to do with this weird hackfix that is being touted in a bunch of places that tells you to place `next/babel` in your `eslint` config file for some reason (e.g. [here](https://stackoverflow.com/a/68193974)).
It probably was a hackfix for an old bug in older next.js versions. But as of (at least... | Or just replace `"next"` and `"next/core-web-vitals"` to
`"plugin:@next/next/recommended"`
<https://nextjs.org/docs/basic-features/eslint> |
71,662,525 | When I'm trying to build the Next.Js app then the below error is coming with a successful build. This error is showing when I deploy the app in Vercel.
```
error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
```
This is my **.eslintrc.json**
```
{
"exte... | 2022/03/29 | [
"https://Stackoverflow.com/questions/71662525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8546303/"
] | I think, this might have to do with this weird hackfix that is being touted in a bunch of places that tells you to place `next/babel` in your `eslint` config file for some reason (e.g. [here](https://stackoverflow.com/a/68193974)).
It probably was a hackfix for an old bug in older next.js versions. But as of (at least... | my problem has been solved by this code. just copy and paste it into the eslintrc.json file.
```
{
"extends": ["next/babel","next/core-web-vitals"]
}
``` |
71,662,525 | When I'm trying to build the Next.Js app then the below error is coming with a successful build. This error is showing when I deploy the app in Vercel.
```
error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
```
This is my **.eslintrc.json**
```
{
"exte... | 2022/03/29 | [
"https://Stackoverflow.com/questions/71662525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8546303/"
] | my problem has been solved by this code. just copy and paste it into the eslintrc.json file.
```
{
"extends": ["next/babel","next/core-web-vitals"]
}
``` | Or just replace `"next"` and `"next/core-web-vitals"` to
`"plugin:@next/next/recommended"`
<https://nextjs.org/docs/basic-features/eslint> |
61,872,401 | I'm looking to plot the Alpine1 function using Python. The function looks like this:
Alp(x\_1,…,x\_n )= ∑\_(i=1)^n〖|x\_i \* sin(x\_i )+1.01x\_i |〗
[](https://i.stack.imgur.com/fnKr2.png)
So the function sums (`from i=1 to n`) the absulute of `xi*sin(xi) +1.01xi`. Withou... | 2020/05/18 | [
"https://Stackoverflow.com/questions/61872401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13568088/"
] | You can use `np.sum` to take the sum of an array. Numpy's [broadcasting](https://realpython.com/numpy-array-programming/) and vectorization take care that all elements are calculated separately and then summed.
Here is an example:
```
import numpy as np
def alpine1(xis):
return np.sum(np.abs(xis * np.sin(xis) + ... | Summation in Python and other languages in general is usually implemented using a `for` loop.
In the formula above, you are looping over all the elements x1, x2, x3 ... xn.
Now to store such values we use an array or specifically in python a list which is basically a collection of data (where the order matters).
```... |
61,872,401 | I'm looking to plot the Alpine1 function using Python. The function looks like this:
Alp(x\_1,…,x\_n )= ∑\_(i=1)^n〖|x\_i \* sin(x\_i )+1.01x\_i |〗
[](https://i.stack.imgur.com/fnKr2.png)
So the function sums (`from i=1 to n`) the absulute of `xi*sin(xi) +1.01xi`. Withou... | 2020/05/18 | [
"https://Stackoverflow.com/questions/61872401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13568088/"
] | Summation in Python and other languages in general is usually implemented using a `for` loop.
In the formula above, you are looping over all the elements x1, x2, x3 ... xn.
Now to store such values we use an array or specifically in python a list which is basically a collection of data (where the order matters).
```... | Thanks I think I understand a lot better already!
I was wondering another thing actually. Alpine1 is a n-dimensional function, so suppose I want to take the "2D version" the function would directly result in:
```
def Alpine(x1, x2):
return (np.abs(x1 * np.sin(x1) + 1.01 * x1)+ np.abs(x2 * np.sin(x2) + 1.01 * x2))
`... |
61,872,401 | I'm looking to plot the Alpine1 function using Python. The function looks like this:
Alp(x\_1,…,x\_n )= ∑\_(i=1)^n〖|x\_i \* sin(x\_i )+1.01x\_i |〗
[](https://i.stack.imgur.com/fnKr2.png)
So the function sums (`from i=1 to n`) the absulute of `xi*sin(xi) +1.01xi`. Withou... | 2020/05/18 | [
"https://Stackoverflow.com/questions/61872401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13568088/"
] | You can use `np.sum` to take the sum of an array. Numpy's [broadcasting](https://realpython.com/numpy-array-programming/) and vectorization take care that all elements are calculated separately and then summed.
Here is an example:
```
import numpy as np
def alpine1(xis):
return np.sum(np.abs(xis * np.sin(xis) + ... | Thanks I think I understand a lot better already!
I was wondering another thing actually. Alpine1 is a n-dimensional function, so suppose I want to take the "2D version" the function would directly result in:
```
def Alpine(x1, x2):
return (np.abs(x1 * np.sin(x1) + 1.01 * x1)+ np.abs(x2 * np.sin(x2) + 1.01 * x2))
`... |
39,445,369 | When I try adding margin to displace the content that is hidden under the Nav Bar, the bar moves with the body even though it is fixed.
I researched a bit and other answers provide the same response to what I've tried such as [this](https://stackoverflow.com/questions/28250261/html-positioning-overlap-between-navigati... | 2016/09/12 | [
"https://Stackoverflow.com/questions/39445369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3068340/"
] | add padding on `body` `30px` & apply `top:0` on navigation ul
```
body {
background-color: red;
margin: 0;
padding: 30px 0 0;
}
ul {
background-color: green;
list-style-type: none;
margin: 0;
overflow: hidden;
padding: 0;
position: fixed;
top: 0;
width: 100%;
}
```
<https:... | You just need to move your `position:fixed;` from the `<ul>` element to the `<nav>` element and also add `width:100%;`
Then you can add padding to your content to stop it from being overlapped by the nav bar.
I have updated your JSfiddle with the changes here: <https://jsfiddle.net/michaelsherry/823r43gm/2/>
CSS sh... |
39,445,369 | When I try adding margin to displace the content that is hidden under the Nav Bar, the bar moves with the body even though it is fixed.
I researched a bit and other answers provide the same response to what I've tried such as [this](https://stackoverflow.com/questions/28250261/html-positioning-overlap-between-navigati... | 2016/09/12 | [
"https://Stackoverflow.com/questions/39445369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3068340/"
] | add padding on `body` `30px` & apply `top:0` on navigation ul
```
body {
background-color: red;
margin: 0;
padding: 30px 0 0;
}
ul {
background-color: green;
list-style-type: none;
margin: 0;
overflow: hidden;
padding: 0;
position: fixed;
top: 0;
width: 100%;
}
```
<https:... | I would fix the `<nav>`not the `<ul>`, and put a margin on the first block of content.
```
nav{position:fixed; top:0; left:0;}
.tryingtowork { margin-top: 30px;}
```
[Updated JSFiddle here](https://jsfiddle.net/823r43gm/3/) |
39,445,369 | When I try adding margin to displace the content that is hidden under the Nav Bar, the bar moves with the body even though it is fixed.
I researched a bit and other answers provide the same response to what I've tried such as [this](https://stackoverflow.com/questions/28250261/html-positioning-overlap-between-navigati... | 2016/09/12 | [
"https://Stackoverflow.com/questions/39445369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3068340/"
] | add padding on `body` `30px` & apply `top:0` on navigation ul
```
body {
background-color: red;
margin: 0;
padding: 30px 0 0;
}
ul {
background-color: green;
list-style-type: none;
margin: 0;
overflow: hidden;
padding: 0;
position: fixed;
top: 0;
width: 100%;
}
```
<https:... | So I made two changes to your code:
1. Added `top: 0` to the `ul` in the `nav` element.
2. Added some margin to the topmost section- used `calc` to adjust it:
```
.tryingtowork {
/*background-image: url("RBS.png");
background-position:0% 40%;*/
width: 100%;
overflow: hidden;
margin-top: calc(40px + 1.2em);
... |
39,445,369 | When I try adding margin to displace the content that is hidden under the Nav Bar, the bar moves with the body even though it is fixed.
I researched a bit and other answers provide the same response to what I've tried such as [this](https://stackoverflow.com/questions/28250261/html-positioning-overlap-between-navigati... | 2016/09/12 | [
"https://Stackoverflow.com/questions/39445369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3068340/"
] | So I made two changes to your code:
1. Added `top: 0` to the `ul` in the `nav` element.
2. Added some margin to the topmost section- used `calc` to adjust it:
```
.tryingtowork {
/*background-image: url("RBS.png");
background-position:0% 40%;*/
width: 100%;
overflow: hidden;
margin-top: calc(40px + 1.2em);
... | You just need to move your `position:fixed;` from the `<ul>` element to the `<nav>` element and also add `width:100%;`
Then you can add padding to your content to stop it from being overlapped by the nav bar.
I have updated your JSfiddle with the changes here: <https://jsfiddle.net/michaelsherry/823r43gm/2/>
CSS sh... |
39,445,369 | When I try adding margin to displace the content that is hidden under the Nav Bar, the bar moves with the body even though it is fixed.
I researched a bit and other answers provide the same response to what I've tried such as [this](https://stackoverflow.com/questions/28250261/html-positioning-overlap-between-navigati... | 2016/09/12 | [
"https://Stackoverflow.com/questions/39445369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3068340/"
] | So I made two changes to your code:
1. Added `top: 0` to the `ul` in the `nav` element.
2. Added some margin to the topmost section- used `calc` to adjust it:
```
.tryingtowork {
/*background-image: url("RBS.png");
background-position:0% 40%;*/
width: 100%;
overflow: hidden;
margin-top: calc(40px + 1.2em);
... | I would fix the `<nav>`not the `<ul>`, and put a margin on the first block of content.
```
nav{position:fixed; top:0; left:0;}
.tryingtowork { margin-top: 30px;}
```
[Updated JSFiddle here](https://jsfiddle.net/823r43gm/3/) |
51,004,628 | I am refactoring some code in my app and turns out,the below logic it is repeated in many many components.
```
import component1 from '...'
import component2 from '...'
import component3 from '...'
//...many others
export default {
//other data
components: {
component1,
component2,
component3
//... | 2018/06/23 | [
"https://Stackoverflow.com/questions/51004628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9842918/"
] | **Below are 3 ways**.I prefer method 3 by the way.
>
> **Method 1**
>
>
>
**Create a `js` file in my case `dynamic_imports.js`:**
```
export default function (config) {
let registered_components = {}
for (let component of config.components) {
registered_components[component.name] = () => System.i... | You can automatically register such repeated base components globally using the pattern described in the official docs
<https://v2.vuejs.org/v2/guide/components-registration.html#Automatic-Global-Registration-of-Base-Components>
[Chris Fritz](https://twitter.com/chrisvfritz?lang=en) also talks about this pattern in h... |
17,649,168 | I used ado.net entity framework to connect database and have an .edmx file in project.. When I tried to reach objects in code side with object initializer I can see the object names but when I tried to enter a value into textarea in throws this error.Title is a table in database and entries is another tables data but b... | 2013/07/15 | [
"https://Stackoverflow.com/questions/17649168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2054556/"
] | You could use `size_t` or `ptrdiff_t` as the type of an index (your second parameter is more an index inside a float array than an offset).
Your use is an index, not an offset. Notice that the standard [offsetof](http://en.wikipedia.org/wiki/Offsetof) macro is defined to return byte offsets!
In practice, you could ev... | I would say it is not appropriate, since
1. `off_t` is (intended to be) used to represent file sizes
2. `off_t` is a signed type.
I would go for `size_type` (usually a "typedef"ed name for `size_t`), which is the one used by std containers. |
17,649,168 | I used ado.net entity framework to connect database and have an .edmx file in project.. When I tried to reach objects in code side with object initializer I can see the object names but when I tried to enter a value into textarea in throws this error.Title is a table in database and entries is another tables data but b... | 2013/07/15 | [
"https://Stackoverflow.com/questions/17649168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2054556/"
] | You could use `size_t` or `ptrdiff_t` as the type of an index (your second parameter is more an index inside a float array than an offset).
Your use is an index, not an offset. Notice that the standard [offsetof](http://en.wikipedia.org/wiki/Offsetof) macro is defined to return byte offsets!
In practice, you could ev... | Perhaps the answer is to use `ptrdiff_t`? It...
* can be negative;
* alludes to the difference not being in bytes, but in units of arbitrary size depending on the element type.
What do you think? |
17,649,168 | I used ado.net entity framework to connect database and have an .edmx file in project.. When I tried to reach objects in code side with object initializer I can see the object names but when I tried to enter a value into textarea in throws this error.Title is a table in database and entries is another tables data but b... | 2013/07/15 | [
"https://Stackoverflow.com/questions/17649168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2054556/"
] | Is there any good reason why you just don't use `int`? It's the
default type for integral values in C++, and should be used
unless there is a good reason not to.
Of course, one good reason could be that it might overflow. If
the context is such that you could end up with very large
arrays, you might want to use `ptrdi... | I would say it is not appropriate, since
1. `off_t` is (intended to be) used to represent file sizes
2. `off_t` is a signed type.
I would go for `size_type` (usually a "typedef"ed name for `size_t`), which is the one used by std containers. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.