qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
20,651,442 | I have an assignment in which I have to accept an input from the user. I can't use a linked list, only an array, so my plan is:
1. Alloc some memory.
2. If we need to realloc, meaning that I reached the number of cells allocated:
1. Try to realloc. If successful, great.
2. If we couldn't realloc, print input, free ... | 2013/12/18 | [
"https://Stackoverflow.com/questions/20651442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1941081/"
] | The problem is indeed with your condition:
```
if (i==(MAX_CHARS_INPUT-1))
```
This works, but only for the first time you reach this limit. When you `realloc` your buffer gets bigger, but you don't check if you run out of *that* space. So imagine I input 500 characters. When the 199th character is read the buffer i... | There are few things getting wrong in your code, the new code is:
```
#include <stdio.h>
#include <stdlib.h>
#define MAX_CHARS_INPUT 200
#define D_SIZE 2
void printWithMalloc(){
//int charSize=1; you don't need this.
//int *ptr=malloc(MAX_CHARS_INPUT*sizeof(charSize));
char *ptr=malloc(MA... |
14,522,539 | I need to write a command line application, like a shell. So it will include commands etc. The thing is I don't know how to pass parameters to the funcions in a module. For example:
User writes: function1 folder1
Program should now pass the 'folder1' parameter to the function1 function, and run it. But also it has to ... | 2013/01/25 | [
"https://Stackoverflow.com/questions/14522539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2011042/"
] | Take a look at the **optparse** module in python. It's exactly what you would need:
```
http://docs.python.org/2/library/optparse.html
```
Or you can write your own custom opt-parser (minimalistic though)
```
def getopts(argv):
opts = {}
while argv:
if argv[0][0] == '-': # find "-name value" pairs
... | Take a look at [optparse](http://docs.python.org/2/library/optparse.html) . This can help passing and receiving shell style parameters to python scripts.
Update:
Apparently `optparse` is deprecated now and [argparse](http://docs.python.org/2/library/argparse.html#module-argparse) is now preferred option for parsing c... |
34,664,382 | Now I recently saw this question (can't exactly remember where) about how few operations were needed to sort a list of numbers by exclusively reversing sublists.
Here is an example:
**Unsorted Input**: `3, 1, 2, 5, 4`
One of the possible answers is:
1. Reverse index 0 through 3, giving `5, 2, 1, 3, 4`
2. Re... | 2016/01/07 | [
"https://Stackoverflow.com/questions/34664382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535434/"
] | I've found a solution with a smaller number of swaps for your example:
1. reverse indexes 0 to 2: 2 1 3 5 4
2. reverse indexes 0 and 1: 1 2 3 5 4
3. reverse indexes 3 and 4: 1 2 3 4 5
Seems like what @greybeard suggested is the best approach. Maybe even think of a sort of heuristics based on greedy+optimization funct... | My intuitive feeling is that the problem can be reduced to:
1. Regard 2-tuple swaps between array neighbours, based upon their cardinality. This would be an upper bound for the number of subset reverses.
2. Compound these 2-tuple swaps to higher order (3-tuple, 4-tuple etc), reducing the number or reverses further, un... |
3,610,933 | Is it possible to iterate a vector from the end to the beginning?
```
for (vector<my_class>::iterator i = my_vector.end();
i != my_vector.begin(); /* ?! */ ) {
}
```
Or is that only possible with something like that:
```
for (int i = my_vector.size() - 1; i >= 0; --i) {
}
``` | 2010/08/31 | [
"https://Stackoverflow.com/questions/3610933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145359/"
] | Use reverse iterators and loop from `rbegin()` to `rend()` | Here's a super simple implementation that allows use of the for each construct and relies only on C++14 std library:
```
namespace Details {
// simple storage of a begin and end iterator
template<class T>
struct iterator_range
{
T beginning, ending;
iterator_range(T beginning, T ending... |
173,189 | For what value of k, $x^{2} + 2(k-1)x + k+5$ has at least one positive root?
**Approach: Case I :** Only $1$ positive root, this implies $0$ lies between the roots, so $$f(0)<0$$ and $$D > 0$$
**Case II:** Both roots positive. It implies $0$ lies behind both the roots. So, $$f(0)>0$$
$$D≥0$$
Also, abscissa of vertex ... | 2012/07/20 | [
"https://math.stackexchange.com/questions/173189",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/35297/"
] | You only care about the larger of the two roots - the sign of the smaller root is irrelevant. So apply the quadratic formula to get the larger root only, which is
$\frac{-2(k-1)+\sqrt{4(k-1)^2-4(k+5)}}{2} = -k+1+\sqrt{k^2-3k-4}$. You need the part inside the square root to be $\geq 0$, so $k$ must be $\geq 4$ or $\leq... | Suppose $x\_{1}$ is a real root, then we have that:
$$ (x\_{1}+(k-1))^{2} - (k^2-3k-4) = 0 $$
$$(x\_{1}+(k-1))^{2} = (k^2-3k-4)$$
$$(k^2-3k-4) \ge 0$$
It's obviously seen that the positive roots are got only when $k \le -1$.
Q.E.D. |
28,625,104 | If it is default constructor, who will initialize the member variables to zero then how come this will be possible
```
class A
{
public int i;
public int j;
public A()
{
i=12;
}
}
class Program
{
st... | 2015/02/20 | [
"https://Stackoverflow.com/questions/28625104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4476719/"
] | A field initialization happens before a constructor call through the `newobj` command. It is easy to check after decompilation of the executable with the following C# code:
```
using System;
namespace ConsoleApplication1
{
public class A { public int j; }
class Program
{
static void Main(string[] ... | During the instance creation, its variables are made available too.
And since int is not nullable, it initializes with default(int). Which is 0 |
465,792 | I have a bare uBITX 3-30 MHz transceiver board per <http://www.hfsignals.com/index.php/ubitx/>
Looking at the hookup directions and other pictures on the site, the designer's recommendation is to simply hook a BNC jack to the main board through a (short) two-wire jumper (fractions of hookup schematic and pic below).
... | 2019/11/04 | [
"https://electronics.stackexchange.com/questions/465792",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/30711/"
] | Those things detect a voltage difference between ground and the connected wire. Your body makes the connection to ground - that's why you must touch the contact on the end of it.
The neutral wire in your house is connected to ground - the literal ground beneath your feet and the ground (green) wire in your house wirin... | Just to add to JRE's answer:
>
> I am using a single-pole voltage detector to detect if there is a current-flow / potential on the clamps of my ceiling lamp ...
>
>
>
You can't use a *voltage detector* to monitor current. As the name suggests, it measures voltage. It has no idea whether or not current is flowing ... |
2,987 | I understand that Stack Overflow is for technical questions only. Is there another version for other aspects of software—such as marketing software—similar to `serverfault.com` for admin questions? If not, what do you think about the idea? | 2009/07/06 | [
"https://meta.stackexchange.com/questions/2987",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/-1/"
] | You may possibly see sites like this pop up on StackExchange as different communities in and around the web want a home for things. Fishing, Football, all kinds of things would be possible in that world. | I think marketing with relation to Software is in fact valid for Stack Overflow? As would other external factors relating to development. |
18,597,043 | How can I to Upload a file with C# ? I need to upload a file from a dialogWindow. | 2013/09/03 | [
"https://Stackoverflow.com/questions/18597043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476304/"
] | The following code snippet is the simplest form of performing the file uploading.
I have added a few more lines to this code, in order to detect the uploading file type and check the container exeistance.
Note:- you need to add the following NuGet packages first.
1. Microsoft.AspNetCore.StaticFiles
2. Microsoft.Azure... | **Here is the complete method.**
```
[HttpPost]
public ActionResult Index(Doctor doct, HttpPostedFileBase photo)
{
try
{
if (photo != null && photo.ContentLength > 0)
{
// extract only the fielname
var fil... |
86,282 | Chrome will autofill some user/password fields completely. In others, it will wait until you specify a username, at which point it completes the password.
Is it possible to make Chrome complete the username and password by default? | 2009/12/21 | [
"https://superuser.com/questions/86282",
"https://superuser.com",
"https://superuser.com/users/12555/"
] | I think Brendan is right. Chrome seems to look for a field whose name is "username" along with the password field. If the username field is missing, nothing gets filled in. Also, if the username field has some other name, such as "ID", or if the username field is on a separate page from the password field, it probably ... | Looks like chrome is SUPER picky about pulling the username from the form. The field for password reset forms MUST be of `type="text"` and must not have the `disabled` attribute if you want it to also pull the username for the password manager.
[](htt... |
303,911 | There is a similar question [here](https://stackoverflow.com/questions/203495/testing-rest-webservices) but it only covers some of the issues below.
We have a client who requires web services using REST.
We have tons of experience using SOAP and over time have gathered together a really good set of tools for SOAP dev... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9922/"
] | I googled and found this plugin for chrome.
[POSTman REST Client](https://github.com/a85/POSTMan-Chrome-Extension). | In terms of a client testing application, I had a similar problem. I couldn't find a tool that I could use to quickly test data going in and out of the web services I was creating/using. So I created my own tool using C# .NET. It's essentially a client application that you can use for GET, POST, PUT, and DELETE queries... |
9,906,591 | I've built a REST webservice with some webmethods.
But I don't get it to work passing parameters to these methods.
I.E.
```
@GET
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
public String hello(String firstName, String lastName){
return "Hello " + firstname + " " + lastname
}
```
How would I invoke that meth... | 2012/03/28 | [
"https://Stackoverflow.com/questions/9906591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1297996/"
] | If you are using SpringMVC for REST api development you can use
```
@RequestParam("PARAMETER_NAME");
```
In case of jersey you can use
```
@QueryParam("PARAMETER_NAME");
```
Method look like this
```
public String hello(@RequestParam("firstName")String firstName, @RequestParam("lastName")String lastName){
re... | This will help you
```
ClientResponse response = resource.queryParams(formData).post(ClientResponse.class, formData);
```
where formData is
```
MultivaluedMap formData = new MultivaluedMapImpl();
formData.add("Key","Value");
formData.add("Key","Value");
...
...
...
formData.add("Key","Value");
``` |
48,281,774 | how to perform multiple queries in single stored procedure and then use result we get by all queries in our model. I get **Query error: Commands out of sync; you can't run this command now error** when try to use the result of the stored procedure. Here is my code :
\*\*In Model: \*\*
```
/* convert post array ... | 2018/01/16 | [
"https://Stackoverflow.com/questions/48281774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5620456/"
] | I also used sinch service. For Incoming call, i solved this problem .I hope your problem can be solved by trying this:
1.Replace
```
<activity
android:name="IncomingCallScreenActivity"
android:noHistory="true"
android:showOnLockScreen="true"
android:screenOrientation="sensorPortrait">
</activity... | From Android O and above, if your application is in the background, your application is allowed to create and run background services for some minutes, afterwards your application will enter in the idle stage, and all background service will be stopped.
Posible solution is to use [JobScheduler](https://developer.andro... |
5,287,329 | ```
vector<string> v;
v.push_back("A");
v.push_back("B");
v.push_back("C");
v.push_back("D");
for (vector<int>::iterator it = v.begin(); it!=v.end(); ++it) {
//printout
cout << *it << endl;
}
```
**I like to add a comma after each element as follow:**
A,B,C,D
I tried researching on Google, but I only found CS... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5287329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/657189/"
] | Does really nobody know the `std::experimental::ostream_joiner`?. See [here](https://en.cppreference.com/w/cpp/experimental/ostream_joiner). To be used in algorithms, like `std::copy`
Or, if you do not want to use `std::experimental` alternatively, `std::exchange`? See [here](https://en.cppreference.com/w/cpp/utility/... | To avoid the trailing comma, loop until **v.end() - 1**, and output **v.back()** for instance:
```
#include <vector>
#include <iostream>
#include <iterator>
#include <string>
#include <iostream>
template <class Val>
void Out(const std::vector<Val>& v)
{
if (v.size() > 1)
std::copy(v.begin(), v.end() - 1, ... |
2,524,963 | Consider two sequences of positive real numbers $(a\_n)\_{n\in\mathbb{N}}$ and $(b\_n)\_{n\in\mathbb{N}}$ such that $\lim\_{n\to\infty}\frac{a\_n}{b\_n}=+\infty$ and $\lim\_{n\to\infty}a\_n=+\infty$. Prove that $\lim\_{n\to\infty}(a\_n-b\_n)=+\infty$.
The book I'm using to study sequences don't have a solution to this... | 2017/11/17 | [
"https://math.stackexchange.com/questions/2524963",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | **(Big) Hint:** since $\lim\_{n\to\infty}\frac{a\_n}{b\_n} =\infty$, there exists an $N\geq 0$ such that
$$
\frac{a\_n}{b\_n} \geq 2
$$
for all $n\geq N$. Then $a\_n - b\_n \geq \frac{a\_n}{2}$ for all $n\geq N$. | **Hint:** Prove that $\lim \frac{b\_n}{a\_n}=0$. Then try factoring $a\_n$ out of the expression $a\_n-b\_n$ and consider the limit of the resulting product. |
1,668,192 | What would a developer used to working in **Visual Studio** have to give up if they switched to **Monodevelop**? This hypothetical developer most often develops **ASP.NET web applications** with **C#**.
I'm aware that Monodevelop has the basic Visual Studio features like syntax highlighting and support for Visual Stud... | 2009/11/03 | [
"https://Stackoverflow.com/questions/1668192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111495/"
] | Can't speak for the previous versions, but I've been using MonoDevelop 3+ on a MacBook for a commercial project and have found it to be a more pleasant experience than Visual Studio.
It loads faster, compiles faster and all the tools are more easily accessible and more logically laid out (like source control).
The UI... | I tried Monodevelop and found that it's not a "wow" experience, though this doesn't mean it's not a great accomplishment.
I'm used to docking controls and being able to easily drag controls into/out of containers. However, if I want to do this in GTK, I have to delete all the controls and start again! Therefore, I cou... |
74,034,541 | I have a CSV file, around 5k lines, with the following example:
```none
apple,tea,salt,fish
apple,oranges,ketchup
...
salad,oreo,lemon
salad,soda,water
```
I need to extract only first line matching apple or salad and skip other lines where those words occur.
I can do something like this with regex, "apple|salad", ... | 2022/10/11 | [
"https://Stackoverflow.com/questions/74034541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20217051/"
] | You could use the great [Miller](https://miller.readthedocs.io/en/latest/installing-miller/), and run
```
mlr --nidx --fs "," filter '$1=~"(apple|salad)"' then head -n 1 -g 1 input.csv
```
to have
```
apple,tea,salt,fish
salad,oreo,lemon
```
* `--nidx`, to set the format, a generic index format
* `--fs ","`, to ... | In Notepad++ repeatedly do a regular expression replace of `^(\w+,)(.*)\R\1.*$` with `\1\2`. Have "Wrap around" selected.
Explanation:
```
^ Match beginning of line
(\w+,) Match the leading word plus comma, save to capture group 1
(.*) Match the rest of the line, save to capture group 2
\R ... |
46,037,161 | I am struggling to get get anywhere with more advanced filters.
Dates,
As far as I can see `Admin-on-Rest` filter can only be `"where":"field":"value"...}`.
It would be great if filter can included a date range. `{"where":"field" between: "value1" and "value2" ...`
like or regexp
Again, `AOR's` filters are exact. ... | 2017/09/04 | [
"https://Stackoverflow.com/questions/46037161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8239836/"
] | The problem is that you are storing pointers to char, not strings:
```
vector<char *> myvec;
```
instead of
```
vector<string> myvec;
```
So, when you write your input:
```
A bird came down the walk down END
^ ^
```
these two "down" are different words, and they are stored in differents... | Since `vector<char*>` is a vector of pointers and `token` is a pointer as well, you are comparing pointers. The two different pointers point to different values, then they are not equal.
Insert this in your code, and you will see the difference:
```
std::cout << "Memory address: " << token << " value: " << *token << ... |
583,847 | I want to know the difference of time (hh:mm:ss) between two times.
For example:
Job start at 11:30pm at night but ends at 10:37 the next morning. | 2013/04/17 | [
"https://superuser.com/questions/583847",
"https://superuser.com",
"https://superuser.com/users/217634/"
] | I concur with @ndev that the problem is probably corrupted
program associations of the selected file extension type.
But I do not think that his suggested .reg file completely solves the problem.
The article [Restore Default Windows 7 File Extension Type Associations](http://www.sevenforums.com/tutorials/19449-default... | It looks like your installation of Perl damaged your Windows file extension type associations.
Create a new .reg file and paste following code:
```
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.EXE]
@="exefile"
"Content Type"="application/x-msdownload"
[HKEY_CLASSES_ROOT\.EXE\PersistentHandler]
@="{098f2... |
11,136,689 | Using Qt I know that `private slots` means the slot is private when called directly but a `connect()` can still allow a signal to be connected to a slot whether private, public, or I guess, protected.
So, is there a way to make a slot really private, such that only a connection within a class can be done? What I am th... | 2012/06/21 | [
"https://Stackoverflow.com/questions/11136689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/928502/"
] | Just use [timerEvent](http://qt-project.org/doc/qt-4.8/qobject.html#timerEvent) and [startTimer](http://qt-project.org/doc/qt-4.8/qobject.html#startTimer) instead of slot and QTimer::singleShot. | I think it's possible to add one more argument to your slot and corresponding signal like this:
```
...
private slots:
void slot(..., QObject* sender = 0);
...
void YourClass::slot(..., QObject* sender)
{
if (sender != (QObject*)this)
{
/* do nothing or raise an exception or do whatever you want *... |
29,036,008 | I am building an administrative back-end and thus need to hide public user registration. It appears that if you want to use the built-in Illuminate authentication you need to add
`use AuthenticatesAndRegistersUsers` to your controller definition. This trait is defined [here](http://laravel.com/api/5.0/Illuminate/Found... | 2015/03/13 | [
"https://Stackoverflow.com/questions/29036008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/962674/"
] | [This page](http://slick.pl/kb/laravel/overriding-login-and-registration-functionality-in-laravel-5/) talks about overriding the auth controller. Its worth a read, at a basic level it seems you can add the following lines to app\Http\Controllers\Auth\AuthController.php :
```
public function getRegister() {
return ... | You can have your own form of registration. The only thing Laravel does is make it easy to authenticate on a users table because they create the model, build the db schema for users and provide helper methods to authenticate on that model/table.
You don't have to have a view hitting the registration page... But if you... |
21,472,602 | Ok maybe I am being too picky. Apologies in advance if you cannot see it, but in the second pic, the item on the row is pixellated a bit, or as if a word was placed on top of a word. This only happens after I scroll up on the tableview, otherwise, it is similar to the first image.
First pic:
![http://oi61.tinypic.com... | 2014/01/31 | [
"https://Stackoverflow.com/questions/21472602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3255500/"
] | This is happening because you are not reusing cells and hence you are basically adding the label again and again instead of using the already existing one.
Just put the following code inside the if(cell == nil):
```
static NSString *CellIdentifier = @"OrderProductCell";
UITableViewCell *cell = [tableView dequeueReus... | 1. Don't add subviews to cell directly, add it to contentView of cell
2. While reusing the cell you need to remove the existing label first and add new label or use the existing cell instead of adding new one.
Change your code like:
```
static NSString *CellIdentifier = @"OrderProductCell";
UITableViewCell *cell = [... |
17,734,301 | I was curious about something. Let's say I have two tables, one with sales and promo codes, the other with only promo codes and attributes. Promo codes can be turned on and off, but promo attributes can change. Here is the table structure:
```
tblSales tblPromo
sale promo_cd date promo_cd ... | 2013/07/18 | [
"https://Stackoverflow.com/questions/17734301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2565416/"
] | Please see my comments for [this question](https://stackoverflow.com/questions/1652590/smooth-text-animation-marquee-text-effect-using-qt/1662221#1662221).
Basically you have to call `setTransformationMode(Qt::SmoothTransformation)` on the `QGraphicsPixmapItem`s you want anti-aliasing to apply to.
Calling `setRenderH... | The render hints are only applied if it is set bevor the painter is used. Here a snipped:
```
QGraphicsPixmapItem *
drawGraphicsPixmapItem(const QRectF &rect)
{
auto pixmap = new QPixmap(rect.size().toSize());
pixmap->fill("lightGrey");
auto painter = new QPainter(pixmap);
// set render hints bevor dr... |
187,255 | I'm trying to make a select that calculates affiliate payouts.
my approach is pretty simple.
```
SELECT
month(payments.timestmap)
,sum(if(payments.amount>=29.95,4,0)) As Tier4
,sum(if(payments.amount>=24.95<=29.94,3,0)) As Tier3
,sum(if(payments.amount>=19.95<=24.94,2,0)) As Tier2
FROM payments
GROUP BY month(paymen... | 2008/10/09 | [
"https://Stackoverflow.com/questions/187255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] | The second part of the expression evaluates when you use `AND` -
```
SELECT
month(payments.timestmap)
,sum(if(payments.amount>=29.95,4,0)) As Tier4
,sum(if(payments.amount>=24.95 AND payments.amount<=29.94,3,0)) As Tier3
,sum(if(payments.amount>=19.95 AND payments.amount<=24.94,2,0)) As Tier2
FROM payments
GROUP BY ... | What error did your first attempt give you? It should definitely work. However, note that the second form you have is incorrect syntax. It should be `amount >= 24.94 and amount <= 29.94`. |
399,867 | Please could someone suggest a suitable battery for a specific project.
I need to power a 40 W 12 V car headlight bulb for 10 sessions of 3 or 4 h each time, recharging after each use.
I have tested with a 7Ah battery and only got 1 hr and I am interested in the difference between the projected mathematical time and ... | 2018/10/07 | [
"https://electronics.stackexchange.com/questions/399867",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/200564/"
] | You need to break down the question into :
How many ampere hours do you need?
To convert 40Watts to 12 volt and ampere = I = P/U = 40W/12V = 3.33A
And to run the lamp for 4 hours you need a battery with 4h x 3.33A = 13.33A/h
So a battery with 12V and a minimum of 13.33A/h is needed. | So you need 3.3A for 4 hours and recharging in between for 10 cycle, this should do:
<https://www.digikey.ie/product-detail/en/b-b-battery/BP17-12-B1/522-1014-ND/653335> |
19,217,130 | I have an array of strings but the values in array is changing continuously.
Is there any other way of managing the array except removing items and changing index locations?
```
public String[] deviceId=null;
deviceId=new String[deviceCount];
```
in my case deviceCount is changes as new device comes.
so i c... | 2013/10/07 | [
"https://Stackoverflow.com/questions/19217130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1572606/"
] | Use ArrayList in place of String[] ..
And you can also easily cast ArrayList to String[] for your final output as
```
ArrayList<String> mStringList= new ArrayList<String>();
mStringList.add("ann");
mStringList.add("john");
String[] mStringArray = new String[mStringList.size()];
mStringArray = mStringList.toArray(mStr... | **-** In Java arrays are `initialized` at the time of its creation whether its `declared` at class level or at local level.
**-** Once the size is defined of an `array in Java it can't be changed`.
**-** Its better to use Collection like List.
**-** It has the flexibility to add and delete the items in it, and one c... |
72,834,444 | I have a simple variable:
```
float t = 30.2f;
```
How do I add it to a string?
```
char* g = "Temperature is " + h?
```
Any guaranteed way (I don't have Boost for instance, and unsure of what version of c++ I have) I can get this to work on a microcontroller? | 2022/07/01 | [
"https://Stackoverflow.com/questions/72834444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For simple cases, you can just use the `std::string` class and the `std::to_string` function, which have both been part of C++ for a long time.
```cpp
#include <string>
#include <iostream>
int main()
{
float t = 30.2;
std::string r = "Temperature is " + std::to_string(t);
std::cout << r;
}
```
However, `std::... | ```
std::ostringstream oss;
oss << t;
std::string s = "Temperature is " + oss.str();
```
Then you can use either the string or the `c_str()` of it (as *`const`* `char*`).
If, for some reason, you don't have standard library, you can also use `snprintf()` et. al. (printf-variants), but then you need to do the buffer ... |
8,684,045 | I am attempting to store the rank of users based on a score, all it one table, and skipping ranks when there is a tie. For example:
```
ID Score Rank
2 23 1
4 17 2
1 17 2
5 10 4
3 2 5
```
Each time a user's score is updated, The rank for the entire table must also be updated, so afte... | 2011/12/30 | [
"https://Stackoverflow.com/questions/8684045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123510/"
] | I'm sure you have a good reason for this design choice but I think you should leave the rank out of the database all together. Updating the entire table for every change in one user's score can cause very serious performance issues with almost any size table. I suggest you reconsider that choice. I would advice to simp... | i calculated rank and position the following way:
to update AND get the values i needs, i first added them, added an additional 1 and subtracted the original value. that way i do not need any help-columns inside the table;
```
SET @rank=0;
SET @position=0;
SET @last_points=null;
UPDATE tip_invitation
set
rank ... |
48,618,756 | I would like to compare two dates, if the dates match then just record but not insert in database and if they are not same data insert in database.
I need it for attendance system to avoid duplicate entry for same time. | 2018/02/05 | [
"https://Stackoverflow.com/questions/48618756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9315647/"
] | What happens here is you reuse the already filled `qb_info player_info`.
First you insert "Aaron\_Rodgers" and print it
>
> Aaron\_Rodgers,
>
>
>
Next you add "GB" to player\_info
>
> Aaron\_Rodgers, GB
>
>
>
Next you keep "GB" and insert "Alex\_Smith"
>
> Alex\_Smith, GB
>
>
>
Next you keep "Alex\_S... | You want to push a data structure with two members into your vector, you cannot assign player name and their team separately like that, you only should push back your data structure into the vector when you have both values :
```
for(int i = 0; i < players_and_team.size(); i++) {
if(i % 2 == 0) {
player_i... |
815,687 | New to javascript, but I'm sure this is easy. Unfortunately, most of the google results haven't been helpful.
Anyway, I want to set the value of a hidden form element through javascript when a drop down selection changes.
I can use jQuery, if it makes it simpler to get or set the values. | 2009/05/02 | [
"https://Stackoverflow.com/questions/815687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] | If you have HTML like this, for example:
```
<select id='myselect'>
<option value='1'>A</option>
<option value='2'>B</option>
<option value='3'>C</option>
<option value='4'>D</option>
</select>
<input type='hidden' id='myhidden' value=''>
```
All you have to do is [bind a function to the `change` eve... | Plain old Javascript:
```
<script type="text/javascript">
function changeHiddenInput (objDropDown)
{
var objHidden = document.getElementById("hiddenInput");
objHidden.value = objDropDown.value;
}
</script>
<form>
<select id="dropdown" name="dropdown" onchange="changeHiddenInput(this)">
<option v... |
26,617,263 | i'm trying to set up a MySQL server with XAMPP, it's not working and i'm getting this error:
```
2014-10-28 14:14:38 3768 [Note] Plugin 'FEDERATED' is disabled.
2014-10-28 14:14:38 588 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This
option may be removed in future releases, together with t... | 2014/10/28 | [
"https://Stackoverflow.com/questions/26617263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4191444/"
] | These lines:
```
2014-10-28 14:14:38 3768 [ERROR] InnoDB: C:\xampp\mysql\data\ibdata1 can't be opened in read-write mode
2014-10-28 14:14:38 3768 [ERROR] InnoDB: The system tablespace must be writable!
```
.. indicate a problem with permissions.
Check the permissions on C:\xampp\mysql\data\ibdata1 and ensure that... | I solved the problem following the following steps:
1. I moved all files and directories from `C:\xampp\mysql\data\` to another directory.
2. I started MySQL from XAMPP to generate new files.
3. I moved not generated files and directories to `C:\xampp\mysql\data\`.
This method didn't make me lost my configuration and... |
9,086 | **Abstract**: Analyzing the data from [the last replace-the-homework-policy question](https://physics.meta.stackexchange.com/questions/7645/replacing-the-homework-policy-1-what-existing-questions-should-be-on-off-topic) was inconclusive. So back to the drawing board, or really back to [our starting point](https://physi... | 2016/08/27 | [
"https://physics.meta.stackexchange.com/questions/9086",
"https://physics.meta.stackexchange.com",
"https://physics.meta.stackexchange.com/users/124/"
] | Determining how to redefine this policy is a tricky subject. Not only because of the varying and contradictory opinions about it, but also because we seem to be tackling the issue from the middle. Admittedly, in football, that is a sound strategy, but in politics (and that's just what this is), it's often best to start... | Here is my take on the matter. First, let's think about what Stack Exchange Q&A sites are good for and what they are not good for:
* A Q&A site needs Questions, which can be answered in a concise fashion. There may be several good answers, but if a question needs books to be answered or many answers covering different... |
28,715,545 | We have our hosting in `aws`. Recently after moving our blog from `wordpress` to `aws`, we are experiencing noticeable delay in server response time. Mainly while accessing the blog. Below are the logs from the `error_log` file,
```
[Wed Feb 25 06:10:10 2015] [error] (12)Cannot allocate memory: fork: Unable to fork ne... | 2015/02/25 | [
"https://Stackoverflow.com/questions/28715545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4303687/"
] | I've face that problem either while hosting a java app with jenkins, mysql & tomcat on ubuntu on an vm of AWS.
First steps I used to solve the problem with restarting a vm.
AWS doesn't give swap memory on a harddrive by default, so you'd better to make it with your hands. How to do this you can find [here](http://www... | I had same problem to fix it there is 2 options:
1- move from micro instances to small and this was the change that solved the problem (micro instances on amazon tend to have large cpu steal time)
2- tune the mysql database server configuration and my apache configuration to use a lot less memory.
tuning guide for ... |
2,363,013 | This produces an anonymous function, as you would expect (f is a function with three arguments):
```
f(_, _, _)
```
What I don't understand is why this doesn't compile, instead giving a "missing parameter type" error:
```
f(_, _, 27)
```
Instead, I need to specify the types of the underscores explicitly. Shouldn'... | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3905/"
] | If you are thinking about partial application, I thought that this was only possible with **multiple parameter lists** (whereas you only have one):
```
def plus(x: Int)(y: Int) = x + y //x and y in different parameter lists
val plus10 = plus(10) _ //_ indicates partial application
println(plus10(2)) //prints 12
```... | I feel this is one of those border cases arising from all the code conversion, since this involves the creation of an anonymous function which directs the call to the original method. The type is for the argument of the outer anonymous function. In-fact, you can specify any sub-type i.e
```
val f = foo(_: Nothing, 1) ... |
1,063,234 | Given....
```
Public MasterList as IEnumerable(Of MasterItem)
Public Class MasterItem(Of T)
Public SubItems as IEnumerable(Of T)
End Class
```
I would like a single IEnumerable(Of T) which will iterate through all SubItems of all MasterItems in MasterList
I would like to think that there is a Linq facility to... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11356/"
] | Are you looking for SelectMany()?
```
MasterList.SelectMany(master => master.SubItems)
```
Sorry for C#, don't know VB. | You can achieve this by Linq with SelectMany
C# Code
```
masterLists.SelectMany(l => l.SubItems);
```
Best Regards |
60,644,695 | I am allocating memory in the Jetson TX2. It has 8GB of RAM.
I need to specify the maximun GPU memory size available for TensorRT.
>
> max\_workspace\_size\_bytes = (has to be an integer)
>
>
>
I have seen some examples using these "values":
```
1<<20 = 1048576 (decimal)
= 0001 0000 0000 0000 0000
1<<30 =... | 2020/03/11 | [
"https://Stackoverflow.com/questions/60644695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106842/"
] | Perhaps you're having a "Gb vs G**i**b" problem. Usually, 3 Gigas of RAM refers to 3,221,225,472 bytes instead of 3,000,000,000.
The first value is 3 \* (2^10)\*(2^10)\*(2^10), a nice 3 (11) followed by 30 zeros in binary representation, while the second is 3 \* (10^3)\*(10^3)\*(10^3), which is a mess in binary.
This... | ```
3GB = 3,221,225,472
1100 0000 0000 0000 0000 0000 0000 0000
3<<30 = 3GB
``` |
1,736,348 | I'm trying to use bsdiff (or any binary diff implementation you come up with) to compute and apply diff onto random binary data. I would like to use it on data from a database, so it would be better not to have to write those onto disk and pass them to bsdiff.exe.
Is there any wrapper library or way in python to do th... | 2009/11/15 | [
"https://Stackoverflow.com/questions/1736348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138352/"
] | You can use [difflib](http://docs.python.org/library/difflib.html) that is part of Python standard library. You can send any arbitrary data into a `difflib.SequenceMatcher`. | Also, the `SequenceMatcher` class (from the Python standard library) can be helpful.
Check out the other contents of the `difflib` module as well. |
24,844,553 | In our database we have a number of tables which have corresponding Translation tables, with language and region IDs (mapped to other tables) with language 1 being English and the default region of language 1 being UK. All tables which have a translation table have the following default columns (although no interface h... | 2014/07/19 | [
"https://Stackoverflow.com/questions/24844553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2979644/"
] | You definitely don't need to use javascript. This works on the latest version of Chrome, use vendor prefixing for transitions.
<http://jsfiddle.net/pKYu2/16/>
HTML
```
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim... | You can use the `hover` event:
```
$("div").hover(function() {
$("img").show();
}, function() {
$("img").hide();
});
``` |
67,297,792 | I'm trying to get the Python package OSMnx running on my Windows10 machine. I'm still new to python so struggling with the basics.
I've followed the instructions here <https://osmnx.readthedocs.io/en/stable/> and have successfully created a new conda environment for it to run in. The installation seems to have gone ok.... | 2021/04/28 | [
"https://Stackoverflow.com/questions/67297792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15783372/"
] | You'll need to convert the object to an array, then filter on values and get the corresponding keys:
```js
var obj = { 1: NaN,2: NaN,120: NaN,121: NaN,122: NaN,125: NaN,126: NaN,127: NaN,128: NaN,129: NaN,130: NaN,131: NaN,132: NaN,133: NaN,134: NaN,135: NaN,136: NaN,602: NaN,603: true,604: true,605: NaN,607: NaN,608:... | This will be done very much easily with [for-in](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in) loop
```js
var obj = { 1: NaN,2: NaN,120: NaN,121: NaN,122: NaN,125: NaN,126: NaN,127: NaN,128: NaN,129: NaN,130: NaN,131: NaN,132: NaN,133: NaN,134: NaN,135: NaN,136: NaN,602: NaN,60... |
11,128,043 | We need to implement a WCF Webservice using the [ACORD Standard](http://www.acord.org/standards/downloads/Pages/PCSSpecsPublic.aspx).
However, I don't know where to start with this since this standard is HUMONGOUS and very convoluted. A total chaos to my eyes.
I am trying to use WSCF.Blue to extract the classes from ... | 2012/06/20 | [
"https://Stackoverflow.com/questions/11128043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/912875/"
] | I wrote a ACORD to c# class library converter which was then used in several large commercial insurance products. It featured a very nice mapping of all of the ACORD XML into nice concise, extendable C# classes. So I know from whence you come!
Once you dig into it its not so bad, but I maintain the average coder will ... | I would recommend not creating a model for the entire standard. One could just pass XML and not serialize into a model but instead load it into XDocument/XElement and use Linq to query it and update the DOM using Linq to Xml. So, one is not loading the XML to a strongly typed model, but just loading the XML. There is n... |
2,411,315 | I would like to convert my for loop to STL std::for\_each loop.
```
bool CMyclass::SomeMember()
{
int ii;
for(int i=0;i<iR20;i++)
{
ii=indexR[i];
ishell=static_cast<int>(R[ii]/xStep);
theta=atan2(data->pPOS[ii*3+1], data->pPOS[ii*3]);
al... | 2010/03/09 | [
"https://Stackoverflow.com/questions/2411315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/235125/"
] | You need to seperate out the loop body into a seperate function or functor; I've assumed all the undeclared variables are member variables.
```
void CMyclass::LoopFunc(int ii) {
ishell=static_cast<int>(R[ii]/xStep);
theta=atan2(data->pPOS[ii*3+1],
data->pPOS[ii*3]);
al2[ishell] += massp*cos(fm*theta);... | ```
class F {
public:
void operator()(int ii) {
ishell=static_cast<int>(R[ii]/xStep);
theta=atan2(data->pPOS[ii*3+1], data->pPOS[ii*3]);
al2[ishell] += massp*cos(fm*theta);
}
F(int[] r): //and other parameters should also be passed into the constructor
r_(r) ... |
3,513,997 | Hi I'm wanting to set a variable date in the format Y-m-d 20:00:00 of the previous day. can someone help? | 2010/08/18 | [
"https://Stackoverflow.com/questions/3513997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299871/"
] | ```
Dim lastNight As DateTime = DateTime.Today.AddHours(-4)
Dim lastNightString As String = lastNight.ToString("y-M-d HH:mm:ss")
``` | There's probably an easier way but this is how I would probably do it in C#:
DateTime myDate = DateTime.Today.AddHours(20 - DateTime.Today.Hour).AddMinutes(0 - DateTime.Today.Minute).AddSeconds(0 - DateTime.Today.Second).AddMilliseconds(0 - DateTime.Today.Millisecond);
Then for formatting find something along the lin... |
210,794 | The main plan of *Avengers: Endgame* for solving what Thanos did in *Avengers: Infinity War* involves the
>
> Time Heist.
>
>
>
As part of the plan Tony misplaces
>
> the Tesseract
>
>
>
and so he and Cap have to go looking for it elsewhere. They decide to go back to
>
> a SHIELD base in 1970 where bot... | 2019/04/25 | [
"https://scifi.stackexchange.com/questions/210794",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/58193/"
] | Tony remembers (just about) that his dad, Howard Stark, told him that he worked there with Hank Pym in this period.
As Tony says in *Civil War*, his dad mentioned knowing Captain America a lot; and as we see a bit in *Iron Man 2*, he probably tried to tell Tony a lot of useful stuff about his work that Tony largely ig... | In the first Avengers movie, Tony hacks into SHIELD's computers while onboard the helicarrier by placing a device of some sort on the command terminals used by Nick Fury on the bridge.
Later when Tony, Bruce, and Steve are in the lab working on a way to locate the Tesseract, Tony tells Steve that Jarvis is currently h... |
47,268,698 | Neo4j's manual does a very good job at explaining the meaning of the terms Node, Relationship, Label and a few others.
However, the **real** vocabulary of Cypher seems to include quite a few elusive terms, as well.
For instance, clause 3.3.15.1 of the manual says "Lists and paths are key concepts in Cypher". Fine, b... | 2017/11/13 | [
"https://Stackoverflow.com/questions/47268698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7146357/"
] | Alternatively, you can use the fade function provided in Material UI Next.
```
import {fade} from 'material-ui/styles/colorManipulator';
const theme = createMuiTheme({
overrides: {
MuiButton: {
root: {
boxShadow: `0 4px 8px 0 ${fade(defaultTheme.palette.primary[500], 0.18)}`,
}
},
}
})... | For what it's worth, an 8 digit hex code works too
```
const styleSheet = theme => ({
root: {
backgroundColor: '#ffffff80',
},
})
``` |
29,930,711 | Given:
```
a = [1, 2, 3]
b = [4,5]
```
How to get:
```
[1, 2]
[4]
```
In the above example, I know this works:
```
a[:-1]
b[:-1]
```
However, when:
```
c = [1]
c[:-1]
```
The result is an empty list. | 2015/04/28 | [
"https://Stackoverflow.com/questions/29930711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/160863/"
] | You want the following code fragment:
```
c[:1] + c[1:-1]
```
For example:
```
>>> c = [1]
>>> c[:1] + c[1:-1]
[1]
```
With `c[:1]` you get a list consisting of the first element (if it exists, otherwise the empty list), and with `c[1:-1]` you get from the second until the end except the last. If there isn't a se... | Following JuniorCompressor's answer, if the point is just to remove last element (keep first and if exist others also keep them, but remove last == remove last, if first element is also not the last element). Is it?
```
>>> def removelast(l):
... if len(l)>1: del l[len(l)-1]
... return l
>>> a = range(5)
>>> ... |
48,266,942 | I use Angular 5 with one type : "@types/markerclustererplus": "2.1.28". This type installs @types/google-maps.
I added script part in "index.html" file to load map.
In my component, I can use google namespace.
This works fine.
However, when I run tests... it fails!
I got "ReferenceError: google is not defined"
I tri... | 2018/01/15 | [
"https://Stackoverflow.com/questions/48266942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8934461/"
] | Thank you Alexander!
You bring me a real clue!
After your post, I looked deeper into angular google mock.
I finally found this : [GoogleMock](https://github.com/sttts/google-maps-mock/blob/master/google-maps-mock.js).
I then adjusted it and it works.
Thanks ! | ```
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"style... |
937,043 | I am running an Apache instance on Ubuntu and am having this problem: .HTML files with bonafide HTML inside is being served as a text file:
```
> **For eg. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html>
> <body> <h1>Index to Butterthlies
> Catalogs</h1>
```
etc. etc.\*\*
I checked the header in firebug an... | 2009/06/01 | [
"https://Stackoverflow.com/questions/937043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/328915/"
] | You can use an expression in an ORDER BY. Try this:
```
SELECT *
FROM comments
ORDER BY IF(ParentId = 0, Id, ParentId), Id
```
This will first sort by Id, if ParentId = 0, or by ParentId otherwise. The second sort criterion is the Id, to assure that replies are returned in order. | I highly recommend that you restructure your database schema. The main problem is that you are trying to treat comments and replies as the same thing, and they simple aren't the same thing. This is forcing you to make some difficult queries.
Imagine having two tables: [COMMENTS:(id, text)], and replies to comments in... |
26,584,812 | I am creating some elements dynamically with jquery. (say with id `test_element1`, `test_element2` and so on..)
I have the below CSS -
```
div[id^=test_]:before {
content: "";
height: 100%;
width: 100%;
box-shadow: #aaaaaa 0px 0px 10px inset;
position: absolute;
left: 0px;
top: 0px;
z... | 2014/10/27 | [
"https://Stackoverflow.com/questions/26584812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3209879/"
] | There really should be no reason for the pseudo element not showing up. Maybe check your code to see if there is a problem elsewhere. Here is a working example of what you are trying to achieve, maybe you can compare this with your code and find a solution for your specific case. But the ultimate answer is that it shou... | **When you set pseudo element, selector z-index + position need to added.**
```css
div[id^=test_] {
position:relative;
z-index:1;
}
div[id^=test_]:before {
content: "";
height: 100%;
width: 100%;
box-shadow: #aaaaaa 0px 0px 10px inset;
position: absolute;
left: 0px;
top: 0px;
... |
5,289,336 | Here is my problem:
Inside a jQuery dialog I have the following code:
```
<%:Ajax.ActionLink("Yes", "SendClaim", "Claim", new { id = Model.ExpenseId }, new AjaxOptions { UpdateTargetId = "dialog" }, new { @class = "button" })%>
```
When stuff fails in the controller based on roles I return a partial view that repla... | 2011/03/13 | [
"https://Stackoverflow.com/questions/5289336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571216/"
] | I'm a bit of a novice, but I find I have more control with the following approach instead of using `Ajax.ActionLink`. Hopefully it helps and I have understood what you want to do correctly.
Claim Controller:
```
[AcceptVerbs(HttpVerbs.Post)]
public Json Send(int expenseId)
{
// Check user stuff
if(valid)
// do stuff
... | Returned an 'All OK' dialog and had the following javascript when the user clicks the ok button:
```
function redirect() {
document.location = "<%:(String)ViewBag.Redirect %>";
}
$(document).ready(function() {
$(".ui-dialog-titlebar-close").click(function() {
redirect();
});
});
```
Seems unavoidab... |
60,306,131 | I'm trying to return 2 objects using an IIFE. I cant find whats wrong here.
```
var UIController = (function(){
return{
getMinput: function(){
return {
mstaff1: document.querySelector('#mstaff1').value,
mstaff2: document.querySelector('#mstaff2').value,
mpda... | 2020/02/19 | [
"https://Stackoverflow.com/questions/60306131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12791759/"
] | You cannot have two returns from a single run of a function. That's physically impossible.
But you can return an *array* of values.
```
var UIController = (function ... return [ /*whatever porcesing*/ , /*second result */ ]; .. })();
``` | Here you have one object. You can't have the same name for methods inside one object. Also, you need to add ',' after each method or prop.
So do it like this:
```
(function(){
return{
getMinput: function(){
return {
mstaff1: document.querySelector('#mstaff1').value,
ms... |
944,509 | Apple provides the NSArchiver and NSUnachriver for object serialization / deserialization, but this can not handle any custom xml schema. So filling an object structure with the data of any custom xml schema has to be made manually.
Since the iPhone developer community is rapidly growing, a lot of newbie programmer are... | 2009/06/03 | [
"https://Stackoverflow.com/questions/944509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/90745/"
] | The NSKeyedArchiver works precisely because it doesn't try to map onto an XML schema. Many, many XML schemas are badly designed (i.e. they're translating an in-memory object structure to an external representation format). The key problem is that the documents should be designed to make sense from a document perspectiv... | I've been struggling with requirements in this domain and think it would be a great idea. I've had to bully my dot net services to return JSON for easy consumption on an iPhone. A decent serialization library would be superb. |
16,927,526 | Are there any NoSQL DBs that support object inheritance in .NET out of the box? MongoDB has something which is proper for dynamic languages but I'm looking for real inheritance. Actually I think I should work on an ODBMS instead of NoSQL!? Or does MongoDB support strongly-typed inheritance?
I would like to get data us... | 2013/06/04 | [
"https://Stackoverflow.com/questions/16927526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441889/"
] | MongoDB C# driver supports `OfType` and `is` in LINQ queries!
<http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/#csharp-driver-linq-tutorial> | RavenDB has something similar to what you want to do.
<http://ravendb.net/docs/client-api/querying/polymorphism> |
37,947,092 | I am using laravel framework in ubunto system and I want to remove port number from my url
write now I can access my web-project with this url
```
http://localhost:8000
```
and I want this url
```
http://localhost/
```
How can I do this? | 2016/06/21 | [
"https://Stackoverflow.com/questions/37947092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3425009/"
] | If nothing else (e.g. Apache oder Nginx) uses port 80 you COULD start the development webserver like this
```
sudo php artisan serve --port 80
```
You can access the app via <http://localhost/> afterwards
Note that this is ONLY for development and some kind of hack. Install a dedicated webserver (Apache, Nginx) fo... | Do not use php artisan server in your commandline and use full URL path in browsers address bar as follows
```
http://localhost/projectname/public
``` |
4,488,849 | 
Following error occurs in /// this coding "
***Cannot insert the value NULL into column 'boarding', table 'C:\USERS\VBI SERVER\DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\VOLVO\APP\_DATA\ASPNETDB.MDF.dbo.boardingpt'; column does not allow nulls. INSERT fails. The statement h... | 2010/12/20 | [
"https://Stackoverflow.com/questions/4488849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/522211/"
] | You are not providing a value for the `boarding` field, which is a `NOT NULL` field (`Allow Nulls` is not checked).
Being a `NOT NULL` field means you *have* to provide a value for it.
If the field is supposed to be the ID of the rows in the table, you should make it into an `IDENTITY` field.
See [this](http://msdn.... | You are trying to insert NULL value for the column which is set to NOT NULL.
Solution
* Make **boarding** column to ALLOW NULL and remove Primary key (because primary key never can be null)
or
* Set IDENTITY to YES in your table design mode for **boarding** column
Hope this helps
Thanks
Vivek |
620,950 | Is there a way to have Notepad++ generate new file names with the current date?
Like this:
YYYY\_MM\_DD\_new1.txt
or similar.
Currently it just names them: new1, new2, etc.
Date in the file name will work great with autosave, there will be no name conflicts after NPP restart.
All I want is a way to store sessions be... | 2013/07/17 | [
"https://superuser.com/questions/620950",
"https://superuser.com",
"https://superuser.com/users/181907/"
] | I just did this using the Python Script plugin for NPP...
```
notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED])
def my_callback(args):
if notepad.getBufferFilename(args["bufferID"]) == "new 1":
fmt = '%Y%m%d%H%M%S'
d = datetime.datetime.now()
d_string = d.strftime(fmt)
notepad... | I tried using mwoliver's answer and still had trouble running it. I made some changes and now, this will work for any "new #" format instead of just "new 1".
```
notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED])
def my_callback(args):
set1 = set(notepad.getBufferFilename(args["bufferID"]).split(' '))
file... |
45,097 | Trying to figure out the difference between these. I've lost completely as different source/answers interpret it differently. Does anyone have clear understanding about what does undergraduate/graduate/post-graduate student mean in USA?
I've seen this nice timeline in [other question](https://academia.stackexchange.co... | 2015/05/08 | [
"https://academia.stackexchange.com/questions/45097",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/34264/"
] | Part of the confusion may be that these adjectives are used in (at least) two different contexts: to describe *degrees* and to describe *students*.
* An *undergraduate degree* generally means a bachelor's degree (B.S., B.A., etc): a degree requiring about four years of university-level study beyond high school.
* A *g... | I have to say that there is one difference between *graduate* and *post-graduate* -- while both mean "beyond Bachelor's degree", the first refers to *level* and the second to *time*.
If I were asked for a transcript of my graduate studies, I'd have to list several courses taken before receiving my B.S. because these w... |
50,177,797 | There is an object with this form:
```
anObject = {name_1 : [4],
name_2 : [1],
name_3 : [5, 1, 2],
name_4 : [3, 4],
};
```
on the left side it is the name of the property and on the right side it is an array of numerical values (one or more values).
I want to show them someh... | 2018/05/04 | [
"https://Stackoverflow.com/questions/50177797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9099077/"
] | `value` that you pull out is an array, so display it with the second `ng-repeat`. Here is an example:
```js
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.anObject = {
name_1: [4],
name_2: [1],
name_3: [5, 1, 2],
name_4: [3, 4],
};
});
```
```html... | ```html
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="(key, value) in records">{{key}}
<div >{{value.toString()}}</div>
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", fu... |
77,487 | I was starting to install casing on my doors and while positioning the board I realized the door latch is going to contact the casing (1x4 craftsman) before the strike plate. The solutions I've found are extended strike plates or chisel/route the trim. Anything else I'm missing? I see 1x4 used a lot in casing but I cou... | 2015/11/07 | [
"https://diy.stackexchange.com/questions/77487",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/5097/"
] | The issue isn't with the latch, it's with the placement of the trim. The fact that the strike plate is routed into the casing is a dead give-away. With craftsman style trim, you need to leave about a 1/4" reveal of the door jamb - it just doesn't work flushed up to it for this exact reason:
You can get away doing this... | Your latch is typical; you just need a strike plate with an extended tongue. (Admittedly, "tongue" probably isn't the right technical term, but I imagine you've got the picture.) |
3,047,839 | I just started playing with Django today and so far am finding it rather difficult to do simple things. What I'm struggling with right now is filtering a list of status types. The StatusTypes model is:
```
class StatusTypes(models.Model):
status = models.CharField(max_length=50)
type = models.IntegerField()
... | 2010/06/15 | [
"https://Stackoverflow.com/questions/3047839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38/"
] | EDIT:
It turns out that ModelAdmin.formfield\_for\_foreignkey was the right answer in this situation:
<http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey>
PREVIOUS ANSWER:
Take a look at the [list\_filter attribute of ModelAdmin](http://docs.djangoproject... | You can override the `queryset` method of your `MyModelAdmin` class:
```
from django.contrib import admin
class MyModelAdmin(admin.ModelAdmin):
def queryset(self, request):
qs = super(MyModelAdmin, self).queryset(request)
return qs.filter(type=0)
admin.site.register(StatusTypes, MyModelAdmin)
`... |
476,231 | I'm developing a Desktop Search Engine in Visual Basic 9 (VS2008) using Lucene.NET (v2.0).
I use the following code to initialize the IndexWriter
```
Private writer As IndexWriter
writer = New IndexWriter(indexDirectory, New StandardAnalyzer(), False)
writer.SetUseCompoundFile(True)
```
If I select the same docum... | 2009/01/24 | [
"https://Stackoverflow.com/questions/476231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | To update a lucene index you need to delete the old entry and write in the new entry. So you need to use an IndexReader to find the current item, use writer to delete it and then add your new item. The same will be true for multiple entries which I think is what you are trying to do.Just find all the entries, delete th... | There are options,listed below, which can be used as per requirements.
See below code snap. [Source code in C#, please convert it into vb.net]
```
Lucene.Net.Documents.Document doc = ConvertToLuceneDocument(id, data);
Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.Open(new DirectoryInfo(UpdateConfigur... |
17,747,606 | For testing purpose, I would like to create on disk a directory which exceeds the Windows MAX\_PATH limit.
How can I do that?
(I tried Powershell, cmd, windows explorer => it's blocked.)
**Edited:**
The use of ZlpIOHelper from ZetaLongPaths library allows to do that whereas the standard Directory class throws the dre... | 2013/07/19 | [
"https://Stackoverflow.com/questions/17747606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25781/"
] | The easiest solution is to create a directory `c:\A\averylongnamethatgoesonandonandon...`,
and then rename `C:\A` to something much longer. Windows does not check every child of A to see if the name of that child would exceed `MAX_PATH`. | How about something like this:
```
var path = "C:\\";
while (path.Length <= 260)
{
path = Path.Combine(path, "Another Sub Directory");
}
``` |
3,633 | With a normal spring, you compress it using a linear force to store energy and then it decompresses and releases the energy, again in a form of linear force. Is there a mechanical mechanism that stores energy by rotating force and releases energy by rotating force? It doesn't have to be spring operated, but I think it'... | 2015/07/20 | [
"https://engineering.stackexchange.com/questions/3633",
"https://engineering.stackexchange.com",
"https://engineering.stackexchange.com/users/2353/"
] | For "many many rotations", a [pneumatic motor](https://en.wikipedia.org/wiki/Pneumatic_motor) can act as both a compressor and motor. Spinning the motor causes air to be forced through a tube, one-way valve, and storage tank. Opening the valve allows the compressed air in the tank (potential energy) to flow back throug... | A spring loaded piston actuating a rack, and turning a pinion gear. Smaller the pinion gear, relative to the length of the rack... the more rotations achieved in a given stroke. And also the greater the piston pressure required... |
16,842,118 | I would like to know if there is a way to count the number of TCP retransmissions that occurred in a flow, in LINUX. Either on the client side or the server side. | 2013/05/30 | [
"https://Stackoverflow.com/questions/16842118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999975/"
] | You can see TCP retransmissions for a single TCP flow using Wireshark. The "follow TCP stream" filter will allow you to see a single TCP stream. And the `tcp.analysis.retransmission` one will show retransmissions.
For more details, this serverfault question may be useful: <https://serverfault.com/questions/318909/how-... | The Linux kernel provides an interface through the pseudo-filesystem `proc` for counters to track the `TCPSynRetrans`
For example:
```
awk '$1 ~ "Tcp:" { print $13 }' /proc/net/snmp
```
Per documentation:
```
* TCPSynRetrans
This counter is explained by `kernel commit f19c29e3e391`_, I pasted the
explanation belo... |
53,963,007 | I have implemented a generic class as below which might be causing the problem,
```
import { Logger } from '@nestjs/common';
import { PaginationOptionsInterface, Pagination } from './paginate';
import { Repository } from 'typeorm';
export class EntityService<T> {
private repository: Repository<... | 2018/12/28 | [
"https://Stackoverflow.com/questions/53963007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2010052/"
] | I got this resolved by deleting the generated files and recreating it eg: dist folder | Sometimes the error can be caused by existing code outside the SRC folder (eg Typeform migrations, etc) which causes the compilation inside DIST to enter one level of folders (eg dist/migrations, dist/src) which makes the main file not be in the correct location. |
5,580,583 | I am using autotools for my project.
While building Qt there are the generated `moc_*.cpp` and `ui_*.h` files which I want to have them in a gen subdirectory. The directory and the generated files should be created by make and removed my make clean.
Have anyone here done this before? I'll appreciate it really much! | 2011/04/07 | [
"https://Stackoverflow.com/questions/5580583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549746/"
] | The link you posted takes me to a site that says:
>
> Returns a pseudo-random number in the
> range [0,1) — that is, between 0
> (inclusive) and 1 (exclusive). The
> random number generator is seeded from
> the current time, as in Java.
>
>
>
"inclusive" means the value is part of the range, whereas "exclusiv... | between 0 (inclusive) and 1 (**exclusive**) - cannot be 1
Your code is all right |
20,509,158 | I am trying to delay the processing of a method (SubmitQuery() in the example) called from an keyboard event in WinRT until there has been no further events for a time period (500ms in this case).
I only want SubmitQuery() to run when I think the user has finished typing.
Using the code below, I keep getting a System... | 2013/12/11 | [
"https://Stackoverflow.com/questions/20509158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/284169/"
] | If you add `ContinueWith()` with an empty action, ~~the exception isn't thrown.~~ The exception is caught and passed to the `tsk.Exception` property in the `ContinueWith()`. But It saves you from writing a try/catch that uglifies your code.
```
await Task.Delay(500, cancellationToken.Token).ContinueWith(tsk => { });
... | I think it deserves to add a comment about why it works that way.
The doc is actually wrong or written unclear about the TaskCancelledException for `Task.Delay` method. The `Delay` method itself never throws that exception. It transfers the task into cancelled state, and what exactly raises the exception is `await`. I... |
12,406,505 | How do I make a uitableview in interface builder compatible with 4 inch iphone5, and the older iPhone 4/4s?
There are three options in Xcode 4.5:
* Freeform
* Retina 3.5 full screen
* Retina 4 full screen
If I chose Retina 4, then in the 3.5 inch phone it crosses/overflows the screen border
Using code, I can set th... | 2012/09/13 | [
"https://Stackoverflow.com/questions/12406505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/226223/"
] | Choose your xib file and change the `Size` attribute.
 | From what i have understand u want to create a table view which can be applicable to both iPhone 4 and 5. First thing first i havnt tried the Xcode 4.5, but the code
```
CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
theTableView.frame = CGRectmake = (0,0,fullScreenRect.width,fullScreenRect.height);
```
t... |
26,297,935 | Bit of background info - the developer of the system we use has left the company and I've been asked to add a few new features. Needless to say, there's no documentation and to make matters worse I'm an absolute novice so am having to learn as I go along. I'm kind of managing to do most things but have come totally stu... | 2014/10/10 | [
"https://Stackoverflow.com/questions/26297935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4127496/"
] | Well you can use JOIN and add index on country and city in companies table
```
SELECT Name
FROM companies AS c INNER JOIN tagsForCompany AS tc ON c.id = tc.Company
INNER JOIN tags AS t ON t.id = tc.TID
WHERE city = "your_city" AND country = "your_country" AND t.Name REGEXP 'your_tag'
```
Well in this query a table w... | May this query is help you.
```
select * from companies c
left join tagsForCompany tc on c.company_id = tc.company_id
left join tags t on t.tag_id = tc.tag_id
where c.city = "your value" and c.country = "Your value" and tc.name = "your value"
``` |
36,832,656 | The string is `myAgent(9953593875).Amt:Rs.594` and want to extract `9953593875` from it. Here is what I tried:
```
NSRange range = [feDetails rangeOfString:@"."];
NSString *truncatedFeDetails = [feDetails substringWithRange:NSMakeRange(0, range.location)];
NSLog(@"truncatedString-->%@",truncatedFeDetails);
```
Thi... | 2016/04/25 | [
"https://Stackoverflow.com/questions/36832656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5126338/"
] | Or you do like this:
```
NSString *string = @"myAgent(9953593875).Amt:Rs.594.";
NSRange rangeOne = [string rangeOfString:@"("];
NSRange rangeTwo = [string rangeOfString:@")"];
if (rangeOne.location != NSNotFound && rangeTwo.location != NSNotFound) {
NSString *truncatedFeDetails = [string substringWithRange:NSMak... | Try this
```
NSString *str = @"myAgent(9953593875).Amt:Rs.594.";
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"(?<=\\()\\d+(?=\\))"
options:NSRegularExpressionCaseInsensitive
error:nil];
NSStrin... |
58,157,041 | This is my code and file data given bellow. I have file with the name of test. In which I’m trying find a num in first column. If that number is found in any line, I want to delete that row.
```
def deleteline():
n=5
outfile=open('test.txt','r+')
line = outfile.readline()
while line !='':
lines= line.rstrip('\n')... | 2019/09/29 | [
"https://Stackoverflow.com/questions/58157041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3502257/"
] | This should solve your problem:
```
def deleteline():
n = 5
outfile = open('test.txt', 'r')
lines = outfile.readlines()
outfile.close()
outfile = open('test.txt', 'w')
for line in lines:
lineStrip = line.rstrip('\n')
listLine = lineStrip.split(',')
num = int(listLine[0]... | As suggested by Simon in above comment, from [this](https://stackoverflow.com/questions/4710067/using-python-for-deleting-a-specific-line-in-a-file) answer, modify the check condition like this:
```
with open("test.txt", "r") as f:
lines = f.readlines()
with open("test.txt", "w") as f:
for line in lines:
... |
9,317 | I've just made hollandaise sauce following Alton Brown method. I used only about 4 tablespoons and I have about 1 cup left.
Using google I found that I shouldn't put it on the fridge, doesn't freeze well and shouldn't be more than 4 hours without use. That leaves little margin.
Is there anything I can do? | 2010/11/20 | [
"https://cooking.stackexchange.com/questions/9317",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/1546/"
] | Oh, yes, you can. There is a way, when you fold in beaten egg whites (soft peaks) after you made your hollondase, not only would those bulk out the sauce and make it able to be kept on warm for long without curdling, but also that would make it able to keep the sauce in the fridge for several days (so that you could ha... | Properly made hollandaise sauce can be refrigerated fir 2 days , best way is warm up a portion in a glass ball over hot water , add a touch water and whisk gently until warm ...perfect good as new |
26,197 | I have Arch Linux plus LXDE installed in my laptop. I want to know the status of the battery level. I tried to install `batterymon`, but got too many errors that I couldn't decipher.
Is there any other way to monitor the battery level? | 2011/12/06 | [
"https://unix.stackexchange.com/questions/26197",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/13083/"
] | There aren't so many tools that can operate directly on DjVu files, compared with other more common formats such as PDF or JPEG. With image manipulation programs, there's the added hurdle that most of these operate on a single image at a time, but the DjVu file contains multiple pages.
One possibility is to go via pdf... | Taking bot2417's script as base, here my own
```
#!/bin/bash
echo "################################################"
echo Usage: djvusplit2 LASTPAGE FILE.DJVU
echo "################################################"
if [ ! -f $2 ];
then
echo "file $2 not exists!\n"
exit
fi
start=1
mkdir ./tmp
for i in $(... |
77,534 | I've got a virtual machine with an 8 gig hard drive in one file. I want to now split virtual hard drive into 2 gig chunks so I can copy the VM onto a FAT32 drive. Is this possible? | 2009/10/23 | [
"https://serverfault.com/questions/77534",
"https://serverfault.com",
"https://serverfault.com/users/2420/"
] | Probably the only way to do that would be to download the VMware converter and use that to migrate to a new virtual machine which is configured for 2 Gig files.
It would probably be easier to simply convert the destination hard drive to NTFS. | haven't tried splitting virtual disk but I think that won't be complicated. I used to split HDD with partitionguru and I remember this tool supports virtual disks generated by Vmware. Since it's a free tool, you may as well have a try |
1,073,805 | I cant quite get my head around what the ^ is doing in my preg\_match.
```
if (preg_match('~^(\d\d\d\d)(-(\d{1,2})(-(\d{1,2}))?)?$~', trim($date), $dateParts)) {
echo the $dateparts and do some magic with them
} else {
tell me the date is formatted wrong
}
```
As I see it this is looking to see if the $date... | 2009/07/02 | [
"https://Stackoverflow.com/questions/1073805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28241/"
] | There is no need to group *absolutely everything*. This looks nicer and will do the same:
```
preg_match('~^\d{4}(-\d{1,2}(-\d{1,2})?)?$~', trim($date), $dateParts)
```
This also explains why "`1977`" is accepted - the month and day parts are *both* optional (the question mark makes something optional).
To do what ... | `^` and `$` anchor your pattern to the beginning and end respectively of the string passed in. The `?` is a multiplier, matching 0 or 1 of the preceding pattern (in this case, the parenthesised bit).
Your pattern matches a year, or a year and a month, or a year and a month and a date; if you follow the parentheses, yo... |
17,082,477 | I've stored latitude and longitude value into my sqlite table. Eg: **latitude = 16.840064** and **longitude = 96.120286**.My question is how can I check and retrieve data from sqlite database for nearest location based on device current GPS location? | 2013/06/13 | [
"https://Stackoverflow.com/questions/17082477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2555911/"
] | Whlile The answer given already (Harversine formula) is correct, but may be I simpler solution works for you:
I am using this solution to reverse geocode the nearest airfield for the given position (used in a flight logger application of mine):
1. query the database for all rows where the coordinated of the location s... | ```
Location.distanceTo (Location locationFromDb)
```
Looks like you will need to create a Location object out of each of the entries in your database and use the above function |
117,428 | In this context, why does he use "come"?
>
> Oh! Quick. Here they **come**. [Oxford English Daily Conversation Episode 2](https://youtu.be/YXf3NmGRfv4?t=24m24s)
>
>
>
Why doesn't he use "are coming" or "have been coming" ?
>
> They are coming here / Here they are coming.
>
>
>
> They have been coming here ... | 2017/01/28 | [
"https://ell.stackexchange.com/questions/117428",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/47521/"
] | Shakespeare's usage of Hark! followed by present simple:
Mistress, upon my life, I tell you true;
I have not breathed almost since I did see it.
He cries for you, and vows, if he can take you,
To scorch your face and to disfigure you.
[Cry within]
**Hark, hark! I hear him, mistress. fly, be gone**!
Comedy of Erro... | The use of the bare infinitive "come" in
>
> Here they **come**.
>
> There they **go**!
>
>
>
is more of a warning and has the feeling of
>
> Beware! Here they come!
>
>
>
and is used for emphasis. In your example, the reporter is using to as a *call-to-action*, since they want to film a segment. He... |
57,622,311 | I am a spark beginner and trying to solve a question from the Northwind Dataset where I need to list products whose prices are above the average price on a databricks notebook.
I tried this:
```
query6 = sparkDF7.select("ProductName","UnitPrice").agg({'UnitPrice':'mean'}).filter("UnitPrice>avg(UnitPrice)").show()
``... | 2019/08/23 | [
"https://Stackoverflow.com/questions/57622311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11655370/"
] | Try this
```
public static void hideKeyboardFrom(Context context, View view)
{
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
```
For kotlin
```
fun hideKeyboard(context : Context, view : Vi... | 1. First of all you will call hide keyboard method.I have show type of hide keyBoard methods given in below.If you want use your like methods.
```
public void hideKeyboard(View view, Context context) {
try {
if (view != null) {
InputMethodManager imm = (InputMethodMa... |
13,385,714 | The problem is that I have a table product and my update script doesn't work aparently. It allwas return false.
**Product.class**
```
@DatabaseTable(tableName = "Product")
public class Product {
@DatabaseField(index = true, generatedId = true)
private int productId;
@DatabaseField
private String name;
@DatabaseFie... | 2012/11/14 | [
"https://Stackoverflow.com/questions/13385714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1415089/"
] | The solution was
Simply get the Instance of the object Product from the DB then modify to finaly send to the updateProduct method.
for example first I need to create any method first to get an objet by ID
```
// get the Instance calling to the getProductByID
Product p = getHelper().getProductByID(p.getId())
... | Put attention for the object Id(should be the same) and use the natif function update(Product); |
31,968,448 | In the Java Mongo DB driver version 3 the API has changed as compared to the version 2. So a code like this does not compile anymore:
```
BasicDBObject personObj = new BasicDBObject();
collection.insert(personObj)
```
A Collection insert works only with a Mongo Document.
Dealing with the old code I need to ask the... | 2015/08/12 | [
"https://Stackoverflow.com/questions/31968448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417291/"
] | I think the easiest thing to do is just change your code to use a Document as opposed to BasicDBObject.
So change
```
BasicDBObject doc = new BasicDBObject("name", "john")
.append("age", 35)
.append("kids", kids)
.append("info", new BasicDBObject("email", "john@mail.com")
.append("phone", "876-134-667... | ```
@SuppressWarnings("unchecked")
public static Document getDocument(BasicDBObject doc)
{
if(doc == null) return null;
Map<String, Object> originalMap = doc.toMap();
Map<String, Object> resultMap = new HashMap<>(doc.size());
for(Entry<String, Object> entry : originalMap.entrySet())
{
Stri... |
33,319,689 | I used this code to send parameter
>
> {
> "email":"email@domain.com",
> "password":"pass"
> }
>
>
>
```
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("email", "email@domain.com"));
params.add(new BasicNameValuePair("password", "pass"));
```
but w... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33319689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3240583/"
] | *Microdata* is the name of a specific technology, *metadata* is a generic term.
Metadata is, like you explain, data about data. We’d typically want this metadata to be machine-readable/-understandable, so that search engines and other consumers can make use of it.
In the typical sense, metadata is data **about the wh... | Metadata: using data to provide information about data. For instance, if you are collecting data about prices of different commodities and you added a small section at the top of the questionnaire to collect information about the name of the enumerator, time of interview, duration of interview etc., such information is... |
36,281 | I have an idea as to why it might be valid, but I would like confirmation, rebuttals, or maybe just better answers. | 2016/06/28 | [
"https://philosophy.stackexchange.com/questions/36281",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/16858/"
] | An appeal to authority is almost never valid. However, if it is declared as such and accepted by both parties, it is alright to use it. First thing to know is that it is an informal fallacy. So it is wrong or right depending on the way it is used or more precisely what inference does the person using it wants the other... | An appeal to authority is not a valid A PRIORI argument. The only way an appeal to authority would be even useful is if you are unable to evaluate the argument itself (that is, it is either hidden or you are unable to make valid inferences about arguments!). The appeal to authority is an a posteriori inductive inferenc... |
18,981,167 | Hey i have created database. And i am adding a through insert query but there is nothing added into database
here is my code of DBManager.java
```
package com.database;
import java.util.ArrayList;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLExcep... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18981167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2192384/"
] | check your configuration file in MAMP, the password isn't defined
The reinstallation doesnt rewrite conf files | Try resetting your root password via the console. [Instructions can be found here.](http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html)
The instructions cover Windows and \*Nix.
The reason why when you re-installed MAMP/WAMP/LAMP/MySQL etc and it doesn't remove the password is because it saves the con... |
37,046,133 | I have problem very similar to this [PDF Blob - Pop up window not showing content](https://stackoverflow.com/questions/21729451/pdf-blob-pop-up-window-not-showing-contnet), but I am using Angular 2. The response on question was to set responseType to arrayBuffer, but it not works in Angular 2, the error is the reponseT... | 2016/05/05 | [
"https://Stackoverflow.com/questions/37046133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2602241/"
] | I had a lot of problems with downloading and showing content of PDF, I probably wasted a day or two to fix it, so I'll post working example of how to successfully download PDF or open it in new tab:
**myService.ts**
```
downloadPDF(): any {
return this._http.get(url, { responseType: ResponseContentType.Blob }... | **ANGULAR 5**
I had the same problem which I lost few days on that.
Here my answer may help others, which helped to render pdf.
For me even though if i mention as responseType : 'arraybuffer', it was unable to take it.
For that you need to mention as responseType : 'arraybuffer' as 'json'.([Reference](https://git... |
47,758 | Let's say that I bought 500 shares of company ABC while the stock was doing well, and paid $10 per share for a total of $5,000. Then over the next year (while I was overseas, let's say) the company tanked and dropped to $2 per share. Since I had no safeties in place to trigger a sell off, I now own 500 shares worth $10... | 2015/05/04 | [
"https://money.stackexchange.com/questions/47758",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/27605/"
] | Stop trying to make money with your emergency fund. It's purpose is to sit there idly waiting for a bad day. A day when you need that cash (liquid) not in a bank or a line-of-credit.
The few dollars you might make trying to chase interest/investments with your emergency fund aren't worth it if a true emergency came up... | Why can't you have both?
If you do have both credit and an emergency fund, and an emergency occurs, you can draw from the line of credit first. Having debt + cash is a much more stable situation than having neither, because then you have the option to use the cash to pay off the debt, or use the cash to pay other expe... |
1,493,359 | If $x\_n:=\sqrt{n}$, show that $(x\_n)$ satisfies $\lim|x\_{n+1}-x\_n|=0$, but that it is not a Cauchy sequence.
We see that
$$|x\_{n+1}-x\_n|=|\sqrt{n+1}-\sqrt{n}|=|(\sqrt{n+1}-\sqrt{n})\cdot\frac{\sqrt{n+1}+\sqrt{n}}{\sqrt{n+1}+\sqrt{n}}|=\bigl|\frac{1}{\sqrt{n+1}+\sqrt{n}}\bigr|$$
This seems to simplify nicely, bu... | 2015/10/23 | [
"https://math.stackexchange.com/questions/1493359",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/250846/"
] | Take $\epsilon=\frac12$. For any $h\in \mathbb{N}$, choose $n=h$ and $m=4h$. Then $|x\_m-x\_n|=|\sqrt{4h}-\sqrt{h}|=|2\sqrt{h}-\sqrt{h}|=\sqrt{h} \ge 1$ which contradicts the definition of Cauchy sequence for above $\epsilon$. | You have shown that
$$|x\_{n+1}-x\_n|=\frac1{\sqrt{n+1}+\sqrt n}\ ,$$
and this clearly approaches $0$ because $\sqrt{n+1}$ and $\sqrt n$ both approach $\infty$. (There is no need to use the definition with $\epsilon$ etc unless you have been instructed to do so.)
The easy way to show that $x\_n$ is not Cauchy is to no... |
16,610,698 | Recently I downloaded a file using the following link
```
git clone git://github.com/mapserver/mapcache.git
```
Inside the downloaded mapcache folder I can not find a configure file to do "./configure". But the installation help file tell:
>
> Unix compilation instructions
> -----------------------------
>
>
> I... | 2013/05/17 | [
"https://Stackoverflow.com/questions/16610698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1662802/"
] | maintainer speaking ...
mapcache and mapserver are switching to cmake for the next release and the docs for the master branch need updating. You can either use the branch-1-0 branch to continue using autoconf builds, or use cmake with master:
```
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
``` | The help file tells you exactly what you need to do
>
> If you are using a git clone rather than a tarball distribution, you must first run autoconf in the root directory, to create the configure file from configure.in
>
>
>
If you don't already have `autoconf` installed you'll need to install it in the normal wa... |
1,085,801 | How do I get the selected value from a dropdown list using JavaScript?
```html
<form>
<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" selected="selected">test2</option>
<option value="3">test3</option>
</select>
</form>
``` | 2009/07/06 | [
"https://Stackoverflow.com/questions/1085801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127986/"
] | ```
var selectedValue = document.getElementById("ddlViewBy").value;
``` | There are two ways to get this done either using JavaScript or jQuery.
**JavaScript:**
```
var getValue = document.getElementById('ddlViewBy').selectedOptions[0].value;
alert (getValue); // This will output the value selected.
```
**OR**
```
var ddlViewBy = document.getElementById('ddlViewBy');
var value = ddlVi... |
43,096 | Over the past 2 years myself and a colleague have built an online statistical analysis application using a mixture of silverlight, wcf and R. I (a c# programmer) wrote all the silverlight and wcf stuff whilst my colleague (a statistician) came up with the stats algorithms and wrote the R code.
Now we think that this a... | 2011/02/03 | [
"https://softwareengineering.stackexchange.com/questions/43096",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/15431/"
] | To answer JBRWilkinson : yes, there is [www.crossvalidated.com](http://www.crossvalidated.com), a stackexchange site for statistics and well past beta. So that's a first channel to find both programmers and customers.
I agree with Lenny222 : you have to present a very clear case why your application is to be preferred... | Are you looking for more programmers to contribute to the code or are you really wanting people to start making use of using the app/library that you've developed?
Identify your target market and go find some early adopters. Is there a StackExchange community related to statistics? Is MathOverflow suitable? |
545,297 | [](https://i.stack.imgur.com/sxE0z.jpg)
[](https://i.stack.imgur.com/DOKvm.jpg)
I’m trying to simulate a half wave rectifier for a -84dBm 2.4GHz AC signal.
The rectifier doesn’t see... | 2021/01/28 | [
"https://electronics.stackexchange.com/questions/545297",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/275276/"
] | As @BrianDummond pointed out, Vf is way larger than your test voltage, the diode doesn't conduct at all.
Also the capacitance of the diode is maximum 2pF according to the datasheet for the BAS70, which corresponds to 33ohm@2.4GHz. In series with 10pF//50ohm, calculate the output voltage from that and you will probably... | >
> The rectifier doesn’t seem to be giving me the correct waveform - the
> negative half cycle isn’t blocked?
>
>
>
The capacitor is the problem, you have made a nice low pass filter and the cap is filtering. Try 1pf
To pick the right value, you would need to find the equivalent series resistance of the diode, w... |
573,309 | What is the purpose and meaning of a cable wound around and passed through a cylindrical ferrite, that black non-conductive ceramic metal ? | 2021/06/29 | [
"https://electronics.stackexchange.com/questions/573309",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/-1/"
] | I see a 2 pin header for an unshielded cable. These wires will make much better antennas than the trace stub to the test points.
There is what looks like a differential LC filter on the PCB next to it, and the inductors look pretty chunky, so I assume this is not a highspeed signal line.
So for noise immunity, I thin... | Yes, test points can absolutely be noise sources if the test-pointed node is high-impedance. For high-frequency signals they also can be a source of distortion due to the discontinuity they introduce.
First issue, the **antenna**.
As you've drawn them, the test points form small antennas. This makes them prone to pic... |
10,918,526 | I want to call my method getSelectedLayouts in my jsp page, where the method is
```
public Iterable<Layouts> getSelectedLayouts(String Subject){
Session sess=getCurrentSession();
return sess.createCriteria(Layouts.class, Subject).list();
}
```
Inside class LayoutManager. I passed LayoutManager into my jsp... | 2012/06/06 | [
"https://Stackoverflow.com/questions/10918526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428913/"
] | * Maybe something deleted `/tmp/.s.PGSQL.5432` socket - a `/tmp/` cleaning service for example.
* Maybe you'll be able to connect using `:host => 'localhost'` as connection argument for `PG::Connection.new()` — it will avoid problems with locating proper path for Unix socket or file permissions problems.
* If you do no... | I faced same issue and when I checked server.log I can see it was not able to find that var/postgres folder and some of the conf files.
I did this, however I lost my data in that case
```
brew uninstall postgres
brew install postgres
initdb `brew --prefix`/var/postgres/data -E utf8``
```
That worked well for me and... |
52,442,906 | Here am using this two media query ,as I read ,**First MediaQuery** would affect background-color if size of screen size is equal or less then 340px ,where as **2nd MediaQuery** would effect if size of screen is less then or equal to 360px...
```
@media only screen and (max-width: 340px) {
#arf_recaptcha_hr... | 2018/09/21 | [
"https://Stackoverflow.com/questions/52442906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10299728/"
] | Just swipe your media query and check it will work for sure.
```
@media only screen and (max-width: 360px) {
iframe {
background-color: red;
}
}
@media only screen and (max-width: 340px) {
iframe {
background-color: blue;
}
}
``` | It's about precedence(CSS Specificity). Last one always applies if you are applying using same selector. As It reads code/file from top to bottom.
```
#idid{
height: 50px;
width: 50px;
background-color: red;
}
@media only screen and (max-width: 360px) {
#idid {
background-color: black;
... |
20,035,920 | I am trying to select a single row at random from a table. I am curious as to why the two statements below don't work:
```
select LastName from DataGeneratorNameLast where id = (ABS(CHECKSUM(NewId())) % 3)+1
select LastName from DataGeneratorNameLast where id = cast(Ceiling(RAND(convert(varbinary, newid())) *4) as in... | 2013/11/17 | [
"https://Stackoverflow.com/questions/20035920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1334903/"
] | The `newid()` gets evaluated for every row it is compared against, generating a different number. To do what you want, you should generate the random value into a variable before the select and then reference the variable.
```
Declare @randId int = (abs(checksum(newid())) % 3) + 1;
select LastName from DataGeneratorN... | I've Had a similar issue and fixed it by making the ID a PRIMARY KEY.
NEWID() is computed per-row. Without a primary key, there is no access pattern other than a table scan, and the filter is checked for each row, so a different value is computed for each row, and you get however many rows match.
With the key, a seek... |
47,950 | I have a photo with a resolution of $1024 \times 768$ which means $786432$ pixels in total. Let's suppose it's a 24-bit color RGB image (so 1 pixel = 3 bytes = 24 bits) and I want to hide information by only modifying the last bit of a color value. What is the maximum number of bytes that I can hide in this photo? | 2017/06/03 | [
"https://crypto.stackexchange.com/questions/47950",
"https://crypto.stackexchange.com",
"https://crypto.stackexchange.com/users/48055/"
] | This is one of those answers that - depends.
The amount of data that can be hidden inside an image depends on the image. This is one of the concepts that most steganographers miss. We have to go to the definition of steganography. Hiding a secret message with emphasis on the hiding part. That means that a message may ... | If you are using an uncompressed format. And using all the lsbs in all color channels. You get 3 bits per pixel. So786432\*3/8 bytes for the entire photo. |
517,935 | Hope someone can help me. I am using c# and I am somewhat new to it.
I am loading a text file into my app and splitting the data on "," I am reading part of string into a `<list>` when the data is read there is a lot of duplicates that vary depending on the txt file that I load. Can someone tell me how to check the and... | 2009/02/05 | [
"https://Stackoverflow.com/questions/517935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A simple/dirty example follows:
```
public List<string> RemoveDuplicates(List<string> listWithDups)
{
cleanList = new List<string>();
foreach (string s in listWithDups)
{
if (!cleanList.Contains(s))
cleanList.Add(s);
}
return cleanList;
}
```
As a warning: String.Split on very large str... | [Here's](http://www.kirupa.com/net/removingDuplicates.htm) an article with some examples and explanations in C#. Basically, you just keep track of the uniques, and check each element.
Alex |
6,014,438 | I want to display a dialog box on a button click. Here is my code, but it is not working.
```
AlertDialog.Builder builder = new AlertDialog.Builder(
getApplicationContext());
builder.setCancelable(true);
builder.setTitle("Title");
builder.setInve... | 2011/05/16 | [
"https://Stackoverflow.com/questions/6014438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/746921/"
] | try this,
instead of passing getApplicationContext() pass this;
```
AlertDialog.Builder builder = new AlertDialog.Builder(this);
``` | This is a very old post however I have made a class that I think it can help to keep the code clean
<https://github.com/houmanka/DialogMaker>
You dont need to worry about the OnClickListener all have been taking care of. Just override the methods and you are done. Also I put the support for Standard and Neutral too.
... |
23,966,209 | Please spare me if this is a newbie question, I'm coming from Java and the concept of pointers just seems foreign to me.
```
SKView * skView = (SKView *)self.view;
skView.showsFPS = YES;
skView.showsNodeCount = YES;
```
So... the code is telling me that skView is a *pointer* but you can access the object that the po... | 2014/05/31 | [
"https://Stackoverflow.com/questions/23966209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3693386/"
] | You are confused by [dot syntax](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW10).
You wrote this:
```
skView.showFPS = YES;
```
You think `skView.showFPS` means “access the field `showF... | For regular C, you're sort-of correct.
If you were to do something like this:
```
struct my_struct {
int a;
int b;
};
struct my_struct my_object = {1, 2};
struct my_struct * my_ptr = &my_object;
```
then you can access the members by dereferencing the pointer:
```
int n = (*my_ptr).a;
```
or without de... |
125,252 | I have recently joined a new company in Estonia which is active in software development, and i have worked there for 1.5 month. I am in a trial period currently (which is 4 month).
I regret about my decision to join this company. The supervisor does not communicate clearly, and then criticizes with bad tone. As a resu... | 2018/12/24 | [
"https://workplace.stackexchange.com/questions/125252",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/94396/"
] | It's still within probation, so it simply wasn't a good fit.
An interview process doesn't always work out perfectly - your new employer will be aware of that.
I would suggest to prepare questions to ask your future manager during the next interview to avoid this happening again. This also shows you've learned from ... | There is a reason you are changing your job. That's the justification.
Build up a list of the things that you shouldn't have had to endure, and then rewrite them again and again until you have the most polite (and forgiving) delivery of the incidents. Admit your shortcomings where they were applicable, and your realiz... |
6,311,126 | I understand what the warning says. This is exactly how scoping rules work. I appreciate that some people want a nanny. I don't. How can I disable this warning? | 2011/06/10 | [
"https://Stackoverflow.com/questions/6311126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/271594/"
] | ```
NSString *foo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow-ivar"
- (void)myFunctionWithShadow_ivarWarningsIgnored {
NSString *foo = @"...";
NSLog(@"This shouldn't get a warning %@", foo);
}
#pragma clang diagnostic pop
- (void)myFunctionWithShadow_ivarWarningsNotIgnored {
... | Update for Xcode 8.3 - Bug in compiler yields "Declaration shadows a local variable" in some instances when it intentional... and the nanny panics.
For example in Objective C:
Given
```
typedef BOOL ( ^BoolBoolBlock ) ( BOOL );
```
And the nature of Apple Blocks will make any variable declared in the immediate out... |
47,183,879 | I have a Custom `UIView` with an XIB. This custom `UIView` has a `UICollectionView` which is connected to an `IBOutlet`. In the view setup, the `UICollectionView` is initialised properly and is not nil.
However in the `cellForItemAtIndexPath` method, I get this error:-
>
> Terminating app due to uncaught exception '... | 2017/11/08 | [
"https://Stackoverflow.com/questions/47183879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2585955/"
] | Maybe a sync issue. Happens sometimes:
1. Try cut outlets loose and reconnect them.
2. Make sure Collection Reusable View identifier is defined in xib file:
[](https://i.stack.imgur.com/OCmjL.png)
3. Make sure collection-view cell's custom class is define in x... | In our case, the problem was making the wrong connection in Storyboard. Click on the custom class in Storyboard -- not the File Owner -- then connect the IB outlet to the variable in the custom class. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.