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 |
|---|---|---|---|---|---|
21,807,142 | I am trying to install <https://www.npmjs.org/package/sails-mongo> and it is getting 0.9.6 instead of 0.9.7 (as the latest). I have latest **node.js (0.10.25 64-bit)** and **mongodb (2.4.9 64-bit)** on Windows 7.
`C:\my_project\backend>npm install sails-mongo`
Anyways, I got fatal error:
```
npm http GET https://reg... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21807142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149367/"
] | kerberos needs python.
Install [python for Windows](http://www.python.org/download/) and add to the environment variables. | Did you check if you are using correct software version ?
If you are using 64bit OS, you have to install 64bit version Node.js(x64) |
44,739,431 | I have a class which gets a object from the external system. I want to validate my parameters are correct. It seems my object is not null even though I sent a wrong value to the service.Basically I want to check `mySalesOrderHeader` contains a valid order number or not.
For example, `if (mySalesOrderHeader != null) { ... | 2017/06/24 | [
"https://Stackoverflow.com/questions/44739431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1145058/"
] | Use [Null-Conditional](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators) operator (C#6 feature). It tests for null before performing a member access Like this:
```
if (string.IsNullOrEmpty(mySalesOrderHeader?.OrderNumber))
{
}
``` | If the variable mySalesOrderHeader is null, you cannot access its properties otherwise exception will be thrown.
So, you should check mySalesOrderHeader first.
```
if (string.IsNullOrEmpty(mySalesOrderHeader != null ? mySalesOrderHeader.OrderNumber : null))
{
...
}
``` |
19,432,252 | For the life of me I can't figure out the proper code to access the comment lines in my XML file. Do I use `findnodes`, `find`, `getElementByTagName` (doubt it).
Am I even making the correct assumption that these comment lines are accessible? I would hope so, as I know I can add a comment.
The type number for a comme... | 2013/10/17 | [
"https://Stackoverflow.com/questions/19432252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2880337/"
] | * If all you need to do is produce a copy of the XML with comment nodes removed, then the first parameter of `toStringC14N` is a flag that says whether you want comments in the output. Omitting all parameters implicitly sets the first to a false value, so
```
$doc->toStringC14N
```
will reproduce the XML trimmed of ... | I know it's not `XML::LibXML` but here you have another way to remove comments easily with `XML::Twig` module:
```
#!/usr/bin/env perl
use warnings;
use strict;
use XML::Twig;
my $twig = XML::Twig->new(
pretty_print => 'indented',
comments => 'drop'
)->parsefile( shift )->print;
```
Run it like:
```
perl ... |
8,941,178 | I'm using opengl, using the GLUT and GLEW libraries to create a plugin for a certain application.
This plugin doesn't start with a simple int main(argc, argv). So i can't pass these values to glutInit().
I tried something like this:
```
glutInit(0, NULL); <--- Crash
GLenum err = glewInit();
```
But i crashed when ... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8941178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/874381/"
] | You might have to call `glutInit` with a valid `argv` parameter, even if you don't have any:
```
char *my_argv[] = { "myprogram", NULL };
int my_argc = 1;
glutInit(&my_argc, my_argv);
```
Edit
----
It might also be that the first parameter is a pointer to an `int`, and it can't be NULL? Then it might be enough to... | I propose this as a de-facto standard for initializing glut applications.
```
static inline void glutInstall()
{
char *glut_argv[] = {
"",
(char *)0
};
int glut_argc = 0;
glutInit(&my_argc, my_argv);
}
```
This function can be modified on per-application basis to provide glut wi... |
29,744,264 | With the same record as below, I use many ways to filter to get it, I don't know why there are some way work and some way are NOT work. Is there anything I should concern
```
//not work:
filtered: {
query: {"match_all": {}},
filter: {"term" : { "name": "Road to Rio 2016"}
... | 2015/04/20 | [
"https://Stackoverflow.com/questions/29744264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2805523/"
] | If you want to use term filters on string make sure to change index as not\_analyzed. But in this case full-text search won't work on this field. To make sure, both filters and full-text search to work change this field as multi-field.
For example in the case of name, change the mapping to
```
"name":{
"typ... | For me it helped to set the field type to `keyword` instead of `string`. |
7,733,039 | I have an MVC3 project using the Entity Framework model in which I've marked up a class like this:
```
public partial class Product
{
public bool IsShipped
{
get { /* do stuff */ }
}
}
```
and which I want to use in a LINQ expression:
```
db.Products.Where(x => x.IsShipped).Select(...);
```
ho... | 2011/10/11 | [
"https://Stackoverflow.com/questions/7733039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/709223/"
] | The only way to make this "DRY" (avoid repeating the logic inside of `IsShipped` in the `Where` clause again) and to avoid loading all data into memory before you apply the filter is to extract the content of `IsShipped` into an expression. You can then use this expression as parameter to `Where` and in `IsShipped` as ... | >
> there's functionality there that I don't want to build into the LINQ query itself... what's a good way to handle this?
>
>
>
I assume you mean you want to perform queries that don't have anything to do with the DB. But your code doesn't match your intention. Look at this line:
```
db.Products.Where(x => x.IsS... |
12,991,267 | I am able to get the device id and save it to my database, and when something happens, I try to send the push notification but it does not get delivered to the phone. Here is what I do in my PHP:
```
$url = 'https://android.googleapis.com/gcm/send';
$device_ids = array( $device_id );
$headers = array('Authorization:... | 2012/10/20 | [
"https://Stackoverflow.com/questions/12991267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/478573/"
] | From the response it seems that the message is delivered. On Android you should have a GCMIntentService class that extends GCMBaseIntentService, to receive the message on the device. You should check the gcm-demo-client that comes in the SDK samples for a good approach on how to implement this on the app. There you onl... | While sending notification from GCM Server, which url to be used?
<https://android.googleapis.com/gcm/send> or
<https://gcm-http.googleapis.com/gcm/send> |
31,807,037 | I have csv rows like this:
```
'UTAS114_1','Aqua Sphere''\n'
```
But the line endings aren't understood by excel and everything goes into the first row. How do I fix them? | 2015/08/04 | [
"https://Stackoverflow.com/questions/31807037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4498553/"
] | It might be of interest that there's a [RFC for CSV](https://www.rfc-editor.org/rfc/rfc4180) and that explicitly uses CRLF as line separator as well:
>
> Each record is located on a separate line, delimited by a line break (CRLF). For example:
>
>
>
```
aaa,bbb,ccc CRLF
zzz,yyy,xxx CRLF
``` | The problem is probably that the CSV was not generated on a Windows machine. Excel, I assume, expects `\r\n` at the end of every line. |
23,741,454 | I am trying to build a JavaScript initcap function which correctly converts the first *letter* in each word to upper case as the other letters to lower case.
All examples I have found converts the first *character* which is incorrect, eg:
joe smith (c e o) should convert to Joe Smith (C E O), not to Joe Smith (c E O)
... | 2014/05/19 | [
"https://Stackoverflow.com/questions/23741454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2089594/"
] | Just sort yourself and limit the output.
```
SELECT uuid FROM Run WHERE <some_condition> ORDER BY id DESC LIMIT 1;
``` | I think the easiest way is using `limit` and `order by`:
```
select r.*
from Run r
where <some condition>
order by id desc
limit 1;
``` |
19,171,195 | Alright, so the code is pretty straight forward. Generic class ourSet, that takes in some elements, puts it in a LinkedList, and does some functions on the two sets.
My problem is actually quite unrelated the general concept of the project, its more in the "user input interface" I've created. I want it to take in som... | 2013/10/04 | [
"https://Stackoverflow.com/questions/19171195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2844764/"
] | The reason is, you're calling `input.nextLine()` *twice*:
```
do {
set1.add(input.nextLine());
}
while (!"EXIT".equals(input.nextLine()));
```
A much easier way than do-while is while:
```
while (!(String in = input.nextLine()).equals("EXIT")) {
set1.add(in);
}
``` | You loop is doing exactly what you've told it to...
* Read a line of text and add it to `set1`
* Read a line of text and check to see if it equals `"EXIT"`
* Repeat as required...
So, every second request is being used to check for the exit state. Instead, you should assign the text from the input to a variable and u... |
30,344,634 | The goal of this code is that when you change the Section Bar radio input to yes two things happen.
[JS Fiddle Link](http://jsfiddle.net/6o7nmgan/1/)
1. The .bar div is shown
2. The Section Foo radio button is changed to the No value **and** the .foo div is hidden
Additionally, would it be possible to have the rever... | 2015/05/20 | [
"https://Stackoverflow.com/questions/30344634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1693705/"
] | **Some basics about default value in C#:**
When an instance of a class (or struct) is created, all fields are initialized to their respective default value.
For reference types, it will be `null`. For value types, it will be equivalent to `0`. This is easily explains as the memory management ensures that new allocate... | For the reference types you'll need to add a flag:
```
string m_Variable1;
bool m_IsVariable1Set;
public string Variable1
{
get{return m_Variable1;}
set{m_IsVariable1Set = true; m_Variable1 = value;}
}
```
For the value types you can use a nullable value
```
int? m_Variable2;
int Variable2
{
get{return m_Va... |
69,278,864 | I was looking at some oracle code and found these case statements are joined with a + operator? what does it do here? Is it possible to avoid '+' and do the same thing?
```
case
when t1.id is not null
then 1
else
0
end +
case
when t2... | 2021/09/22 | [
"https://Stackoverflow.com/questions/69278864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/601357/"
] | Or, yet another option, `DECODE`:
```
select
decode(t1.id, null, 0, 1) +
decode(t2.id, null, 0, 2) +
decode(t3.id, null, 0, 4) as filter
from ...
``` | >
> Is it possible to avoid '+' and do the same thing?
>
>
>
In fact, yes. Assuming the `id`s all have the same type, you can use a `lateral join`:
```
from . . . -- all your existing stuff here
cross join lateral
(select count(id) as cnt
from (select t1.id from dual union all
t... |
1,139,027 | I have Windows 10 installed on a SSD drive and want to install Linux Mint on another HDD drive.
Anyway, I don't know if my PC is UEFI (some parts are old, others recent, like the SSD) but I don't think so. Here are my partition.
I want to install my whole linux (/, swap and /home) in /dev/sda1
How can I do that wit... | 2016/10/25 | [
"https://superuser.com/questions/1139027",
"https://superuser.com",
"https://superuser.com/users/59808/"
] | The safest approach to installing Linux in a way that won't disrupt Windows is to use virtualization -- [VirtualBox](https://www.virtualbox.org/), [VMWare](http://www.vmware.com/), etc. Such tools let you run Linux within Windows (or vice-versa), so you needn't repartition your hard disk or mess with the delicate boot ... | If your Asus mainboard is less than a few years old, it will most likely have UEFI at it's heart. Also if you can use your mouse within your "BIOS", it will indeed be an UEFI. (It still can be an UEFI if you can't use your mouse though!)
There are ways upon ways to determine if your Windows was installed in UEFI or "L... |
35,023 | I run apache2 on Ubuntu, i'm sure there is a configuration or permission problem causing this. When I attempt to update plugins through the admin control panel, after I enter the FTP login/pass and click Proceed. I get the error "Unable to locate WordPress Content directory (wp-content)."
And wp-content does exist and... | 2011/11/29 | [
"https://wordpress.stackexchange.com/questions/35023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | The FTP user account likely does not have access to the wp-content directory. Are you able to access wp-content using an FTP client with the same user account?
Another solution is to change the owner of wp-content to www-data. You can do this from the command line by running `chown www-data:www-data wp-content/ -R` | What resolved for me on Lubuntu 14 was the following:
```
chown www-data:www-data /var/www/html -R
``` |
3,258,870 | I have following two tables:
```
Person {PersonId, FirstName, LastName,Age .... }
Photo {PhotoId,PersonId, Size, Path}
```
Obviously, PersonId in the Photo table is an FK referencing the Person table.
I want to write a query to display all the fields of a Person , along with the number of photos he/she has in the ... | 2010/07/15 | [
"https://Stackoverflow.com/questions/3258870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192727/"
] | You need a subquery in order to avoid having to repeat all the columns from `Person` in your group by clause.
```
SELECT
p.PersonId,
p.FirstName,
p.LastName,
p.Age,
coalesce(ph.PhotoCount, 0) as Photocount
FROM
Person p
LEFT OUTER JOIN
(SELECT PersonId,
COUNT(PhotoId) as PhotoCount
FR... | ```
SELECT
p.PersonId,
p.FirstName,
p.LastName,
p.Age,
CASE WHEN
t.ThePhotoCount IS NULL THEN 0 ELSE t.ThePhotoCount END AS TheCount
--the above line could also use COALESCE
FROM
Person p
LEFT JOIN
(SELECT
PersonId,
... |
16,863,014 | For example there is a `-c` option in Ruby that checks syntax before running a code:
```
C:\>ruby --help
Usage: ruby [switches] [--] [programfile] [arguments]
-c check syntax only
C:\>ruby -c C:\foo\ruby\my_source_code.rb
Syntax OK
```
Is there a similar functionality in Go?
P.S. An example from Ruby ... | 2013/05/31 | [
"https://Stackoverflow.com/questions/16863014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1114926/"
] | Ruby is an interpreted language so a command that checks the syntax might make sense (since I assume you could potentially run the program even if there are syntax errors at some point).
Go on the other hand is a compiled language so it cannot be run at all if there are syntax errors. As such, the simplest way to know... | **golang syntax checker**
Place the below code in a file called *gochk* in a bin dir and `chmod 0755`.
Then run `gochk -- help`
```
#!/bin/bash
#
# gochk v1.0 2017-03-15 - golang syntax checker - ekerner@ekerner.com
# see --help
# usage and version
if \
test "$1" = "-?" || \
test "$1" = "-h" || \
test "... |
60,905,571 | I have this TextView which has gravity to center
```
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="this is first line text\nsecond line"
app:autoSizeMaxTextSize="18sp"
ap... | 2020/03/28 | [
"https://Stackoverflow.com/questions/60905571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7542765/"
] | You can use below solutions, if you want to click on a **Continue with email** button:
**- XPATH**
**Example 1**
```
wait = WebDriverWait(Driver, 30)
wait.until(EC.presence_of_element_located((By.XPATH, "//div[contains(text(),'Continue with email')]"))).click()
```
**Example 2**
```
wait = WebDriverWait(Dri... | Can you try this code
```py
Element = Driver.find_element_by_xpath('//*[@id="site-content"]/div/div/div/div/div/div/div/div[2]/button')
``` |
472,579 | My question is how to stop logs on mysql
```
log_error = /var/log/mysql/error.log i have commented already.
```
with slow queries too. But i have one more log file in /var/lib/mysql/hostname.log
with hostname I mean that for example I am on server called hulk so the log will be
hulk.log and so on. In that log are ... | 2013/01/26 | [
"https://serverfault.com/questions/472579",
"https://serverfault.com",
"https://serverfault.com/users/144063/"
] | In MySQL 5.1.12+ add/change this in your `my.cnf`
```
general-log = 0
```
In MySQL 5.1.11- remove this in your `my.cnf`
```
log
```
or
```
log =
```
Source:
<http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_general_log>
<http://dev.mysql.com/doc/refman/5.1/en/server-options.html#op... | `vim /etc/my.cnf`
There are two lines you want to comment out:
```
log=...
log-error=...
```
Restart mysql by
`service mysql restart`
or
`service mysqld restart`
Logging will be turned off now. Reverse the process when you want to turn it back on (if you do...) :) |
155,731 | I'm currently looking into getting a static IP address at home. I believe that if we are given a static IP address by our ISP that will be assigned to the router, rather than a specific computer.
We have several computers that connect through the router (two desktops, a laptop, plus my iPhone and DS sometimes). Will a... | 2010/06/23 | [
"https://superuser.com/questions/155731",
"https://superuser.com",
"https://superuser.com/users/492/"
] | ### Answers first
>
> Will all these computers have the same external IP address, or will it somehow be different for each one? And does it matter?
>
>
>
These computers, behind the router, will appear as just one computer from the outside (at least they will use the same IP address; websites are still able to di... | I am very curious why you think you might want a static IP instead of the more typical dynamic IP.
I'm not sure what advantage you think you might gain from this. Since almost every ISP client uses dynamic IPs, every site on the Internet has to deal with them properly.
If you just want to reliably access your home's ... |
38,906 | So, we uploaded the managed package and installed it in a new org (as the clients would) but when accessing a vf page we get the error
```
SObject row was retrieved via SOQL without querying the requested field: namespace__MyObject__c.namespace__CustomField__c
```
The problem is that on the developer org everything ... | 2014/06/06 | [
"https://salesforce.stackexchange.com/questions/38906",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/7463/"
] | There's a glitch with Visualforce pages regarding namespaces. The workaround is to always use a Visualforce input or output element.
```
<!-- this is bad -->
{!Account.PackagedField__c}
<!-- this is good -->
<apex:outputField value="{!Account.PackagedField__c}" />
```
After installing the package in another org, yo... | I have suffered this error in the past as well, and we followed the same approach as [sfdcfox](https://salesforce.stackexchange.com/users/2984/sfdcfox).
In our Visualforce pages, we added a list of outputfields linked to the related sObject fields, and set rendered attribute to false to avoid displaying them:
```
<ap... |
53,097,668 | i need to write a program that will get from the user 5 number (a b c d e)
and will print the lowest and the highest number.
how can i do it and use less if-elss condition?
i cant use arry or loops.
```
if (a>b) {
min=b ;
max=a ;
}else {
min=a ;
max=b ;
int temp = a ;
... | 2018/11/01 | [
"https://Stackoverflow.com/questions/53097668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10579425/"
] | One option would be to just add the five input numbers to an array, and then use streams to find the min and max values:
```
int a = myScanner.nextInt();
int b = myScanner.nextInt();
int c = myScanner.nextInt();
int d = myScanner.nextInt();
int e = myScanner.nextInt();
int[] vals = {a, b, c, d, e};
int min = Arrays.st... | I think streams is like using loops, so make simple:
```
int min = a;
int max = a;
if (max < b) {max = b;}
if (min > b) {min = b;}
if (max < c) {max = c;}
if (min > c) {min = c;}
...
System.out.println(min);
System.out.println(max);
``` |
2,061,222 | I've always used dictionaries. I write in Python. | 2010/01/13 | [
"https://Stackoverflow.com/questions/2061222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179736/"
] | A dictionary is a general concept that maps keys to values. There are many ways to implement such a mapping.
A hashtable is a specific way to implement a dictionary.
Besides hashtables, another common way to implement dictionaries is [red-black trees](http://en.wikipedia.org/wiki/Red-black_tree).
Each method has it'... | Dictionary is implemented using hash tables. In my opinion the difference between the 2 can be thought of as the difference between Stacks and Arrays where we would be using arrays to implement Stacks. |
286 | When I lift weights, I lift heavy. I expect to be sore afterwards because I know I've pushed myself hard. Unfortunately, sometimes I push myself too far and get very bad delayed onset muscle soreness (DOMS). What can I do either before working out to prevent excessive soreness or after working out to relieve the sorene... | 2011/03/02 | [
"https://fitness.stackexchange.com/questions/286",
"https://fitness.stackexchange.com",
"https://fitness.stackexchange.com/users/35/"
] | I'm personally not convinced that stopping DOMS is a good idea. The processes behind super-compensation (which is what makes your muscles stronger) are not completely understood and there is some initial evidence that DOMS is part of this process. This implies that reducing DOMS will reduce the weight-building effect.
... | It is a well answered question but I wanted to add extra information about DOMS here
Muscle soreness may occur after an acute training session, especially resistance
training. The soreness manifests itself as stiffness, tenderness, inflammation
and/or pain, and as it occurs between 24β48 hours following the training
s... |
47,565,554 | I really need the help of a code guru or expert on this one.
What I canβt figure out is why in my existing code below, once a new tab has been created, after calling the add\_new\_tab() function that, when I change my active tab to another tab , and then click back on the newly created tab, that I see that the active ... | 2017/11/30 | [
"https://Stackoverflow.com/questions/47565554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3724302/"
] | Please try using jQuery on with filter. simple use of on does not ad listener to the newly created elements.
```
$( "document" ).on( "click", "ul.tabs li", function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
... | Click events are not attached for the newly created li. Try this.
```
$("ul.tabs").on('click', 'li' ,function() {
/* Your function code goes here. */
});
``` |
18,026,128 | I want to do the following steps:
1. Take a list of check box values and make them into a string array in JavaScript.
2. Take the array and send it to a server-side function.
3. Take the array server side and make it into DataTable.
4. Take the DataTable and send it as a TVP to a stored procedure.
I've gotten this to... | 2013/08/02 | [
"https://Stackoverflow.com/questions/18026128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/645070/"
] | The problem here is that you have two methods on your web form which require a post back cycle.
* When you call the `WebMethod`, it will create an instance of the `_default` class and set the `dt` variable, but do nothing with it.
* When you call `Button1_Click`, a new instance of the `_default` class is created, so ... | I would suggest using [JSON](http://www.json.org/), which is a subset of javascript, to represent the data you are passing. An example of JSON would be:
```
[ "string1", "string2" ]
```
or
```
{ "property1": "a", "property2": "b" }
```
Where the first is a valid javascript array and the second is a valid javascri... |
10,953,237 | The [DirectComponent documentation](http://camel.apache.org/direct.html) gives the following example:
```
from("activemq:queue:order.in")
.to("bean:orderServer?method=validate")
.to("direct:processOrder");
from("direct:processOrder")
.to("bean:orderService?method=process")
.to("activemq:queue:order.ou... | 2012/06/08 | [
"https://Stackoverflow.com/questions/10953237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37941/"
] | In the very case above, you will not notice much difference. The "direct" component is much like a method call.
Once you start build a bit more complex routes, you will want to segment them in several different parts for multiple reasons.
You can, for instance, create "sub routes" that could be reused among multiple... | [Direct Component](http://camel.apache.org/direct.html) is used to name the logical segment of the route. This is similar process to naming procedures in structural programming.
In your example there is no difference in message flow. In the terms of structural programming, we could say that you make a kind of [inline ... |
5,160,102 | I'm currently working on a remote control software. The unit delivers the following string (without any linebreak or something):
```
...some_general_infomations,param1=value1,param2=value2,param3=value3,paramN=valueN,...
```
I need somehow to assign these values to some variables. Since the length of this string i... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5160102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2686793/"
] | A good 'ol split should work:
```
var input = "...some_general_infomations,param1=value1,param2=value2,paramN=valueN";
var tokens = input.Split(',');
if (tokens.Length > 0)
{
foreach (var token in tokens)
{
var parts = token.Split('=');
if (parts.Length > 1)
{
string paramNa... | Regular expressions are the standard way to do that; something like so:
```
/,([^=]+)=([^,$]+)/
``` |
12,316,015 | I've a method '`getAllIDs()`' which is used for getting the ids for specific table in database. It is used by many methods in my project.
```
public static int[] getAllIDs (String TableName, String WhereClause, String trxName)
{
ArrayList<Integer> list = new ArrayList<Integer>();
StringBuffer sql =... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12316015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1654377/"
] | There are several possible ways to do this. A simple one could be to make the `WhereClause` behave like a map where you keep parameter names and values. Then you define the prepared statement template based on the keys and fill it with values. You may need a smarter data structure if you want to join the where clauses ... | Most are suggesting a complete ORM solution like Hibernate or JPA. It will take some effort to integrate either of these if you need it for just this one query, but I'm going to guess that this is not the only query subject to SQL injection and the setup can be reused for some/most/all the queries in the app.
However,... |
32,328,133 | Its seems like in new chrome version on MacOs on Linux Mint and on Windows
geolocations doesnt works!
Its returns error:
"ERROR(2): Network location provider at '<https://www.googleapis.com/>' : Returned error code 403."
Does anyone has same problem? | 2015/09/01 | [
"https://Stackoverflow.com/questions/32328133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2218661/"
] | Must be a bug in the latest version of Chrome, also happens in the page of Google Maps API: <https://developers.google.com/maps/documentation/javascript/examples/map-geolocation>
Hopefully it will be fixed fast.
Edited: Try now, it works :) | i didn't get any solution for "`Returned error code 403`" but i found one solution to get current location if google api fails
```
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
current_location_lat = position.coords.latitude;
current_locati... |
6,568,632 | I wrote the following code to get the time
```
public String getTime() {
final Calendar cld = Calendar.getInstance();
String time = cld.get(Calendar.HOUR) + ":" + (cld.get(Calendar.MINUTE));
try {
Date date = new SimpleDateFormat("HH:mm").parse(time);
time = new SimpleDateFormat("HH:mm").fo... | 2011/07/04 | [
"https://Stackoverflow.com/questions/6568632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/637236/"
] | Use `HOUR_OF_DAY` instead of `HOUR`. | Here's the code:
```
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
String time = hour + ":" + minute;
``` |
41,289,394 | I have a default message on the top of a donation form and I would like it to change dynamically depending on which amount the user hovers or clicks.
Each amount as well as "β¬Other" should have a corresponding message. For Example: "with β¬5.00 we can accomplish this..." With β¬10.00 we could do that..."
These messag... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41289394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4341263/"
] | You can use data attributes for input fields, and data can hold text. Also, to achieve desired functionality, you could set 'flag' which will check if option is selected and 'lock' text (so it will not change on hover). Something like this:
```js
locked=false;
$('input.checkbutton').on('change', function() {
$('#de... | When I run into stuff like this, I pick or create a way to easily distinguish one input from the others.
Unique ID's make it quick, and easy to find. In this example, your 5 Euro donation would get the ID of donation-5.
```
$("body").on("mouseover", "input", function () {
if ($(this).attr("id") === "donation-5")... |
6,082,029 | I am looking for a way to use the IN keyword in JasperReport. My query looks like:
```
SELECT * FROM table_name WHERE CID IN (145,45, 452);
```
following that in jasper report I can setup this;
```
SELECT * FROM table_name WHERE CID IN ($P{MY_CIDS});
```
and from my Java I would send `$P{MY_CIDS}` as a `String`, ... | 2011/05/21 | [
"https://Stackoverflow.com/questions/6082029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/222159/"
] | ```
WHERE FIND_IN_SET(CID, "145,45,452")
```
But this query will always cause table fullscan. So I suggest you to rewrite your code and use proper `IN (A, B, C)` syntax. | ```
SELECT * FROM table_name WHERE CID IN ($P!{MY_CIDS});
```
Just use
```
$P!{MY_CIDS}
```
(**exclamation mark** between $P and {MY\_CIDS}).
Jasper will now concatinate the Strings like this:
```
"SELECT * FROM table_name WHERE CID IN ("
+"145,45,452"
+")";
```
resulting in:
```
SELECT * FROM table_name WHE... |
421,430 | Recently I purchased 2 RAM carriers from a local supplier:
Micron Memory Upgrade 8GB 1867MHZ DDR3 SO-DIMM PC3L-14900S (8GBx2)
I wanted to upgrade from my current 8GB to 24GB.
However, a few days after installing, I ran into the screen going weird (for a few seconds). Please see the attached picture.
In addition, to... | 2021/05/28 | [
"https://apple.stackexchange.com/questions/421430",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/419061/"
] | You could always take out the RAM and see if the problem still occurs. It could just be a coincidence that the problem started after the RAM was installed, in which case you've got another problem! | Check that the two 4GB RAM SO-DIMMS specs match precisely to the two 8GB SO-DIMMS. Specs should be exactly the same except for the RAM capacity. The RAM you bought is definitely within spec.
Micron is very good RAM. Apple has used Micron RAM in the past. It's still possible you have some bad RAM and you would have to ... |
26,352,834 | I was trying to modify `A Records` for my domain name. i entered two different value in the name field inside `A Records`:
```
1. <balnk>.example.com
2. www.example.com
```
Now if i type `example.com` it doen't work but `www.example.com` works. How can i make `example.com` working ? | 2014/10/14 | [
"https://Stackoverflow.com/questions/26352834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1049104/"
] | You should create A Record for naked domain with wildcard simbol `@`
```
@ A RECORD 127.0.0.1 (depending on your server ip)
www CNAME example.com
``` | More details about "how" you're trying to configure the A-records would be helpful (DNS application, web interface, etc.), but at its core, consider using the `@` configuration for your naked domain A-record (`example.com`), instead of a `<blank>`.
Separately, consider using a CNAME or other redirect for `www.example... |
33,405,710 | Is there any way to set a date picker to display a specific time on load? I have four date picker instances initiated from four text fields for Start Time, Finish Time, Start Date and Finish Date using the squimer/datePickerDialog subclass from GitHub that pops up in a UIAlertView.
In my app a default start time would... | 2015/10/29 | [
"https://Stackoverflow.com/questions/33405710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3118171/"
] | Are you looking for setting the time through a string. If that''s the case you can use a date formatter like this.
```
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "HH:mm"
let date = dateFormatter.dateFromString("17:00")
datePicker.date = date
```
Adding an init to the [Picker class](https://g... | I got here as it seemed setting the start date wasn't working. Turns out you need to set the initial date after setting the min and max dates. |
49,539,674 | I have an issue with my `append` function. I was trying to show an image within a select `option` by using values from a database which works fine but users can add more `option`s dynamically by generating a select `option` using the `append` function - but I'm getting this error;
>
> Uncaught SyntaxError: missing ) ... | 2018/03/28 | [
"https://Stackoverflow.com/questions/49539674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3903365/"
] | I think you should set fetch type to lazy : (`fetch = FetchType.LAZY`),
or remove it, it's LAZY by default for @OneToMany.
This way hibernate (not spring), will do a simple select query on your Job table. But if you keep it to EAGER, hibenate will always use join on User table to get it's data, on the other side, wit... | Create a query. I.e.
```
@Query(value = "SELECT * FROM JOB WHERE USER_ID = ?1", nativeQuery = true)
Job getByUserId(Integer userId);
```
[Source](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#_native_queries) |
36,308,224 | I have a requirement, where I need to delete thousands of files efficiently. At present, files are deleted in a sequential manner.
I want to speed up the deletions, by calling delete in an asynchronous manner, using std::async().
Current Flow:
1. Get the list of files
2. For each file call delete()
Desired Flow:
... | 2016/03/30 | [
"https://Stackoverflow.com/questions/36308224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2256902/"
] | You may find this doesn't actually help as much as you would like. The file system is likely to have kernel level locks (to ensure consistency), and having many threads hitting these locks it likely to cause trouble.
I suggest
1. Get the list of files.
2. Divide the list into (say) ten equal chunks (represented by i... | The bottleneck is the I/O operations and OS level file system operations, delegating thousands of threads to do this is not likely to alleviate that bottleneck -- in fact, you're likely to find that this method will actually slow things down.
As others have mentioned, depending on the size of the files, it might be be... |
52,791,908 | I need to delete an item from my linked list.
I am willing to start at the front of the list by redirecting my header (called carbase) to the next one in the list.
When i run the function it does free the data of my struct. However, the pointer has not shifted.
```
struct carinfo_t *removeCarinfo(struct carinfo_t *... | 2018/10/13 | [
"https://Stackoverflow.com/questions/52791908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10401097/"
] | Rewrite the method this way.
```
public Wedding getWeddingAt(String date, String venue) {
for (Wedding w : wedArr)
{
if (w.getWeddingDate().equals(date) &&
w.getVenue().equals(venue)) {
return w;
}
}
return null;
}
``` | Your code will say this obviously beacise it is possible that you code will not go into the if block and temp varialble remain unintilized . So , anyone using it need to check null value before using this temp variable .
There are several ways you can remove this error :
1. Ignore this error. As this error will not... |
39,071,503 | Here is my HTML:
```css
.parent{
position: fixed;
border: 1px solid;
height: 43%;
width: 300px;
}
.first_el{
display:block;
border: 1px solid green;
height: 30px; /* constant */
}
.second_el{
border: 1px solild red;
height: 100%; /* dynamic */
overflow: scroll;
}
```
```html
<div ... | 2016/08/22 | [
"https://Stackoverflow.com/questions/39071503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5259594/"
] | You can use jQuery for this to set the height programatically, and bind a handler on resize.
```
function setSecondChildHeight() {
var BORDER_WIDTH = 1;
var parentHeight = $('.parent').outerHeight();
var firstChildHeight = $('.first_el').outerHeight();
var secondChildHeight = parentHeight - firstChildHeight + ... | try this code
```css
.parent{
position: fixed;
border: 1px solid;
height: 43%;
width: 300px;
padding-bottom:30px;
overflow:hidden;
}
.first_el{
display:block;
border: 1px solid green;
height: 30px; /* same as class .parent padding-bottom */
overflow:hidden;
}
.second_el{
border: ... |
16,553,415 | If I have:
```
function firstFunction(){
var counter = 0;
secondFunction();
secondFunction();
secondFunction();
secondFunction();
}
function secondFunction(){
counter++;
}
```
I get an error because of the local scope of the variable, but how else am I to do something like this without using... | 2013/05/14 | [
"https://Stackoverflow.com/questions/16553415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388017/"
] | One way is to use a closure:
```
(function() {
var counter = 0;
function firstFunction() {
secondFunction();
secondFunction();
secondFunction();
secondFunction();
}
function secondFunction() {
counter++;
}
})();
```
Alternately, you could pass in the valu... | As an addition to Elliot Bonneville's answer, you can also do this:
```
var firstFunction = (function()
{
var counter = 0,
secondFunction = function
{
counter++;
};
return function()
{
counter = 0;//initialize counter to 0
secondFunction();
return counter;
};... |
1,863,470 | Evaluate the following limit:
$$L=\lim\_{x\to 0} \frac{(1+x)^{1/x}-e+\frac{ex}{2}}{x^2}$$
Using $\ln(1+x)=x-x^2/2+x^3/3-\cdots$
I got $(1+x)^{1/x}=e^{1-x/2+x^2/3-\cdots}$
Could some tell me how to proceed further? | 2016/07/18 | [
"https://math.stackexchange.com/questions/1863470",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/352447/"
] | You can proceed in the following manner
\begin{align}
L &= \lim\_{x \to 0}\dfrac{(1 + x)^{1/x} - e + \dfrac{ex}{2}}{x^{2}}\notag\\
&= e\lim\_{x \to 0}\dfrac{\exp\left(\dfrac{\log(1 + x)}{x} - 1\right) - 1 + \dfrac{x}{2}}{x^{2}}\notag\\
&= e\lim\_{x \to 0}\dfrac{\exp\left(\dfrac{\log(1 + x)}{x} - 1\right) - \exp\left(\l... | It's a well-known fact that $$\log(1+x)=x-\dfrac{x^2}2+\dfrac{x^3}3+\underset{x\to 0}{o}(x^3)$$
Hence we get $$\dfrac 1x\log(1+x)=1+u(x)$$ where $$u(x)=-\dfrac x2+\dfrac{x^2}3+\underset{x\to 0}{o}(x^2)$$
Notice that $$\lim\_{x\to 0} u(x)=0$$
We can write $$(1+x)^{1/x}=ee^{u(x)}$$
But we know that $$e^u=1+u+\dfrac{u... |
29,111,571 | I'm trying to get my Passport local strategy working.
I've got this middleware set up:
```
passport.use(new LocalStrategy(function(username, password, done) {
//return done(null, user);
if (username=='ben' && password=='benny'){
console.log("Password correct");
return done(null, true);
}
... | 2015/03/17 | [
"https://Stackoverflow.com/questions/29111571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1675976/"
] | I also had the same problem, could not find any solution on the web but i figured it out.
```
app.use(require("express-session")({
secret: "This is the secret line",
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(bodyParser.urlencoded({extended: true})... | I have to agree with @karan525. However, I made sure to test the portion of my code at different locations on my app page. Where it finally worked for me was towards the start but after any configuration files.
```
// Session
app.use(session({
secret: 'not so secret',
resave: true,
saveUninitialized: true,
}));
// P... |
66,559 | I'm just wondering if there are any **2D** alternatives to Unity (excluding KDE, XFCE, LXDE, etc.) that have a modern look to them. I like Unity (since I'm newer to Ubuntu) but I just think an alternative would be cool. Replies would be appreciated.
PS: My computer is a few years old and **only has 2d acceleration.** | 2011/10/15 | [
"https://askubuntu.com/questions/66559",
"https://askubuntu.com",
"https://askubuntu.com/users/27283/"
] | Gnome 3 has a very modern look and scales nicely on older hardware:

You can install Gnome 3 by [clicking here ](http://apt.ubuntu.com/p/gnome-shell) or by entering the following in a terminal:
```
sudo apt-get install g... | Ok, so I installed Pantheon, and except for the exclusion of a background, it is ok for me. Case closed. |
12,863,663 | My question involves how to go about dealing with complex nesting of **templates** (also called **partials**) in an AngularJS application.
The best way to describe my situation is with an image I created:

As you can see this has the potential to be a fai... | 2012/10/12 | [
"https://Stackoverflow.com/questions/12863663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/875342/"
] | I too was struggling with nested views in Angular.
Once I got a hold of [ui-router](https://github.com/angular-ui/ui-router) I knew I was never going back to angular default routing functionality.
Here is an example application that uses multiple levels of views nesting
```
app.config(function ($stateProvider, $urlR... | Angular ui-router supports nested views. I haven't used it yet but looks very promising.
<http://angular-ui.github.io/ui-router/> |
51,585,095 | I previously had tensorflow with gpu support installed and working. I tried to install keras afterwhich nothing would work anymore. I have since uninstalled keras and tensorflow.
I tried re-installing tensorfow with gpu support (now version 1.9) following the instructions on the tensorflow webpage <https://www.tensor... | 2018/07/29 | [
"https://Stackoverflow.com/questions/51585095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9045339/"
] | I had same issue and I mistakenly named my file as `tensorflow.py`. Same issue would occur if folder name is tensorflow.
I just renamed file with something else and it resolve the issue. | Follow these steps:
1. Create new virtualenv
>
> How to create virtuealenv (<https://linuxhostsupport.com/blog/how-to-install-virtual-environment-on-ubuntu-16-04/>)
>
>
>
2. pip3 install requests
3. pip3 install -q -U tensor2tensor
4. pip3 install tensorflow
For some reason the dependencies of the tensorflow re... |
16,438,337 | I think it is used to check the coding but when I tried it didn't respond. I mean it doesn't give any response and showing the data of current website. | 2013/05/08 | [
"https://Stackoverflow.com/questions/16438337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361745/"
] | The f12 is a shortcut to Open up [firebug](https://addons.mozilla.org/en-US/firefox/addon/firebug/) in firefox. To open up firebug you must firstly have it installed | In newer versions of Firefox (I have 91.12.0esr), there is an
"experimental" setting in the about:config setting that can disable the F12 hotkey.
Setting the `devtools.experiment.f12.shortcut_disabled` key to `true` causes the F12 key to bring up a temporary text box that says "To use the F12 shortcut, first open DevT... |
227,407 | In my story, there are a strange species from the *Homo* genus: hematophagous humans often called vampires (their scientific name is *Homo haematophagus*) (so, they are still humans, just not *Homo sapiens*).
I think the /s/ and the /z/ consonants are the most common fricatives around the world (except for maybe the /... | 2022/03/28 | [
"https://worldbuilding.stackexchange.com/questions/227407",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71996/"
] | Centuries ago, one of the great kings of your vampire people was born with a speech impediment. He spoke with a severe lisp, and was never able to form the "s" or "z" sounds. In order to make him not feel like an oddball, the royal court began imitating the lisp. It soon became viewed as a sign of respect and had sprea... | **Hiss. . . .**
Being the walking dead, vampires have lungs that don't work. This means they cannot blow up party balloons, and they cannot make sounds that require the release of air from the lungs.
Some of these sounds can be worked around. For example one can make an /f/ sound by moving your lower lip forward over... |
44,708,300 | I have a huge class with a lot of information. Some information of that I want to print to JSON, but not all information. When I serialize the Object to JSON it off course prints all information.
So I thought I made a template Class for the data I do want to print in JSON. And then I want to copy all values that do ex... | 2017/06/22 | [
"https://Stackoverflow.com/questions/44708300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2740744/"
] | So, usually this is done with a trigger. Anytime an insert or update is done on a table, a follow on insert would be done to your audit table. So, I'd really look into that. But if you don't want to go that route or this is a 3rd party system which you can't add triggers, you could just insert changes in a few ways. A ... | I'm not sure I have understood your requirement clearly but I would have looked for a solution using INSERT / UPDATE triggers to solve this kind of audit-trial tasks. Perhaps that would make things simpler. |
37,936,571 | I did search and looked at these below links but it didn't help .
1. [Point covering problem](https://stackoverflow.com/questions/2821603/point-covering-problem)
2. [Segments poked (covered) with points - any tricky test cases?](https://stackoverflow.com/questions/35824063/segments-poked-covered-with-points-any-tricky... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37936571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5420681/"
] | Maybe this formulation of the problem will be easier to understand. You have `n` people who can each tolerate a different range of temperatures `[ai, bi]`. You want to find the minimum number of rooms to make them all happy, i.e. you can set each room to a certain temperature so that each person can find a room within ... | Here's the working code in C++ for anyone searching :)
```
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define vi vector<int>
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mp make_pair
using namespace std;
bool cmp(... |
4,912,485 | I have implemented this security proccess in my project:
[Spring Security 3 - MVC Integration Tutorial (Part 2)](http://krams915.blogspot.com/2010/12/spring-security-mvc-integration_18.html).
My problem is that I need to turn it into an Ajax-based login.
What do I need to do in order to make this XML suitable with ju... | 2011/02/06 | [
"https://Stackoverflow.com/questions/4912485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/605141/"
] | Spring is shifting away from XML based configurations and towards Java `@Configuration` classes. Below is `@Configuration` version of the setup explained in the post above ([Spring Security Ajax login](https://stackoverflow.com/questions/4912485/spring-security-ajax-login/16577637#16577637)). Steps 2 & 3 remain the sam... | You can use `HttpServletRequest.login(username,password)` to login, just like:
```
@Controller
@RequestMapping("/login")
public class AjaxLoginController {
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public String performLogin(
@RequestParam("username") String username,
@Req... |
37,934,711 | When I am trying to add a new Network Interface for Host only network, Virtual Box version :Version 5.0.22 r108108.
I am getting a following error:
```
Could not find Host Interface Networking driver! Please reinstall.
Result Code:
E_FAIL (0x80004005)
Component:
HostNetworkInterfaceWrap
Interface:
IHostNetworkIn... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37934711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5840664/"
] | You must reinstall the driver.
Go to device manager, you will find an "unknown driver" missing then update it by pointing to this link:
`C:\Program Files\Oracle\VirtualBox\drivers\network\netadp6\VBoxNetAdp6.inf` | In some cases, (worked for me) running and getting the latest update of vbox fix the problem. And got the Host Interface Networking driver automatically installed.
The update I run was:
VirtualBox-6.0.14-133895-Win |
17,135 | My Galaxy Nexus running 4.0.2 does not vibrate for any notifications while in "vibrate" mode. Haptic feedback works, and the phone vibrates when I receive phone calls, but not for notifications. The global vibrate setting under "Sound" in the menu is set to "Always", and individual apps like Gmail, Messaging, etc. have... | 2011/12/19 | [
"https://android.stackexchange.com/questions/17135",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/10743/"
] | There is a separate vibrate setting in the menu for sms messaging under Settings. | Try installing the [Llama app](https://market.android.com/details?id=com.kebab.Llama) then removing it. For some reason it fixes this, I had the same problem. There is a issue on the [tracker](http://code.google.com/p/android/issues/detail?id=23300#c8) that could help. |
64,721,568 | I would like to implement a button on a plotly chart that will copy the plot to the user's clipboard similar to how the snapshot button downloads a png of the plot as a file.
I've referenced [this documentation](https://plotly-r.com/control-modebar.html#add-custom-modebar-buttons) to create a custom modebar button, bu... | 2020/11/06 | [
"https://Stackoverflow.com/questions/64721568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5442622/"
] | I don't know how to deal with the toolbar, but here is how to copy the image to the clipboard by clicking a button:
```r
library(shiny)
library(plotly)
d <- data.frame(X1 = rnorm(50,mean=50,sd=10),
X2 = rnorm(50,mean=5,sd=1.5),
Y = rnorm(50,mean=200,sd=25))
ui <- fluidPage(
title ... | I built upon Joe's answer to resolve his solution's limitations
* Used Plotly.toImage instead of Plotly.Snapshot.toImage to enable users to either choose copied plot's size via toImageButtonOptions or default to whatever size is shown in shiny app.
* added svg copy icon
Limitations:
* only works in localhost or shin... |
28,363,952 | I don't know why this wont work. I did everything like in this same treat [link](https://stackoverflow.com/questions/7689184/select-options-jquery-case-and-show-hide-form-fields) I would like to show show one of following div when option in select is selected. When I select some option all divs dissapears but but nothi... | 2015/02/06 | [
"https://Stackoverflow.com/questions/28363952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Convert your selection to a number. It is currently a string:
```
var selection = ~~$('#type').val();
```
`~~` is a handly shortcut (instead of the slower `parseInt`). It is fine if you know the numbers are within the range of an int and not in octal format (yours are pure simple decimal values)
**A much better opt... | please check the below code
```
<label class="label"> <span>Typ:</span>
<select id="type" class="form-control">
<option value="1" selected="selected">Fotoroleta</option>
<option value="2">Fototapeta</option>
<option value="3">Obraz</option>
<option value="4">Plakat</option>
</s... |
21,037,737 | I am trying to print the hex value of an array, but I am getting an error.
Code I have tried:
```
char Routing[29];
memset(&Routing,0x00,29);
chdir("\\WWW");
tp = fopen("routing.csv", "a");
if(tp!=NULL){
if (SlaveNodeID != 0x00){
fseek(tp, (98 * SlaveNodeID), SEEK_SET);
fprintf(tp,... | 2014/01/10 | [
"https://Stackoverflow.com/questions/21037737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2901888/"
] | The line `char Routing[29];` creates an array of 29 characters and sets the address of this array to the variable Routing. `fprintf(tp, "\n %058x,",Routing);` prints out a 0 padded value of Routing, which is the address of the character array. You need to iterate over the array and print out each value individually.
`... | The easiest way to display every character in the array is as follows. I am providing a skeleton code. You can fill in the blanks yourself.
```
#include <stdio.h>
int main(int argc, char* argv[])
{
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (int i = 0; i < 10; i++)
{
printf("%x\n", arra... |
33,683 | Find the distribution functions of X+Y/X and X+Y/Z, given that X, Y, and Z have a common exponential distribution.
I think the main thing is that I wanted to confirm the distribution I got for X+Y. I'm doing the integral, and my calculus is a little rusty. I'm getting -e^-ax - ae^-as with parameters x from -infinity t... | 2011/04/18 | [
"https://math.stackexchange.com/questions/33683",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | If $X$ and $Y$ are independent exponential random variables, then $X+Y$ has a gamma distribution.
Also, your integral shouldn't go from $-\infty$ to $\infty$, because exponentials can't be negative. | Thanks so much for your help. I'm still having some trouble, however. Currently for (X+Y)/X I have denoted X+Y = t, adn the distribution of T is \int \boldsymbol{\alpha e^{-\alpha x}(1+\alpha x + \frac{(\alpha x)^2}{2})}. Then doing the integral caculations for the distribution, I get \int \boldsymbol{\alpha e^{-\alpha... |
7,490,936 | I'm using this regex to validate a scientific notation in a textbox but it's not working. This is not allowing to type anything.
```
regex = new Regex("[-+]?(0?|[1-9][0-9]*)(\\.[0-9]*[1-9])?([eE][-+]?(0|[1-9][0-9]*))?");
```
Thanks in advance. | 2011/09/20 | [
"https://Stackoverflow.com/questions/7490936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886921/"
] | The problem is that your regular expression matches the empty string. An easy solution could be to add `^` in front and `$` at the end to require the entire input string to match the regular expression.
Here is a small test:
```
var numbers = new[] {
"0", "1", "01", "+1", "-1", "+0", "-0", "1.9", "1.09", "1.90", "1... | Here's another tester that I find very useful: <http://gskinner.com/RegExr/>
If you're just looking to match a floating point number that includes scientific notation while capturing the exponent, then try this: [-+]?[0-9]\*.?[0-9]+([eE][-+]?[0-9]+)? (From <http://www.regular-expressions.info/floatingpoint.html>) |
27,509,542 | In Objective C, a common practice is to often forgo checking for nil, instead relying on the fact that messaging nil silently fails.
For example, to validate a string:
```
if ([myString length] > 1) { // Short and sweet
```
If `myString` is nil, this check will fail - as intended. It's a huge improvement over what ... | 2014/12/16 | [
"https://Stackoverflow.com/questions/27509542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/310175/"
] | NSNull objects typically crop up with people reading JSON files containing null values.
In that case, there is a chance that the server that supplied the null value thinks you should do something different than with no value. For example, if you get a dictionary and there might be a string stored under some key, you ... | >
> is this really necessary?
>
>
>
If some API can return `NSNull` instead of a string, then yes, you should check for it. It's usually not necessary since `NSNull` is not a string and won't be returned by most methods that would return a string. But a collection such as a dictionary, for example, can have any ob... |
42,964,189 | I have java program which is receiving time in Epoch in micro second as shown below
```
String time = "1487809901812";
```
I need to convert this time from micro second to milli second before sending to some other system.
I want final value to be like
```
String final = "1487809901.812"; //Note DOT here
```... | 2017/03/22 | [
"https://Stackoverflow.com/questions/42964189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3597746/"
] | You can convert it into `double`, divide it by 1000 and use `String.format` to format it, e,g.:
```
String time = "1487809901812";
String milli = String.format("%.3f", Double.parseDouble(time)/1000.0);
System.out.println(milli);
``` | ```
String time = "1487809901812";
time = new BigDecimal(Double.parseDouble(time)/1000).setScale(3, 4).toString();
System.out.println(time);
//must be "1487809901.812";
``` |
28,005,541 | First I want to say that yes - I know there are ORMs like Morphia and Spring Data for MongoDB. I'm not trying to reinvent the weel - just to learn. So basic idea behind my AbstractRepository is to encapsulate logic that's shared between all repositories. Subclasses (repositories for specific entities) passes Entity cla... | 2015/01/17 | [
"https://Stackoverflow.com/questions/28005541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1357315/"
] | You need to build an instance of type T and fill it with the data that comes in Β΄DBObjectΒ΄:
```
public abstract class AbstractRepository<T> {
protected final Class<T> entityClass;
protected AbstractRepository() {
// Don't remember if this reflection stuff throws any exception
// If it does, t... | You've stumbled onto the problem of object mapping. There are a few libraries out there that look to help with this. You might check out [ModelMapper](http://modelmapper.org/) (author here). |
17,282,799 | I need help on sum date. My issue is that all entry date are located on the same column, like:
5/10/2013
5/13/2013
5/15/2013
5/16/2013
I need to sum and get total of 6 days. | 2013/06/24 | [
"https://Stackoverflow.com/questions/17282799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2517389/"
] | You're forgetting that programs are executed as individual instructions, and (at least in the simplest case) instructions execute sequentially.
So for `if (a + 4 > 5)` an instruction will load `a` into a register, another instruction will add `4`, another instruction will compare the sum to `5`. Then an instruction wi... | As the others above have stated, there are logic comparators that ultimately make these decisions. There are a ton of different implementations of comparators depending on the design needs (power, area, swing, clocked or not, ect.). The comparators are made out of a number of CMOS NMOS/CMOS gates.
Look on the wikipedi... |
7,932,957 | There is an existing function named "Compare," which is
```
int compare(void* A, void* B) { return (int)A - (int)B; }
```
I am aware that this is an atrocious practice, but I did not write that piece of code and it is being used in many places already. But this code was generating a compilation error under 64-bit, s... | 2011/10/28 | [
"https://Stackoverflow.com/questions/7932957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/696596/"
] | This looks like a sort comparison function, so all that matters is the sign of the result.
```
int compare(void *A, void* B)
{
if (A < B) return -1;
if (A > B) return 1;
return 0;
}
``` | ```
int compare (void*p, void*q) { return (p==q)?0:((char*)p < (char*)q)?-1:1; }
``` |
23,668,459 | Can you please take a [look at this](http://jsfiddle.net/Behseini/56jhq/1/) demo and let me know how I can draw multiple circles in a canvas with different coordinate without repeating bunch of codes?
As you can see on Demo and following code
```
var ctx = $('#canvas')[0].getContext("2d");
ctx.fillStyle = "#00A308";
... | 2014/05/15 | [
"https://Stackoverflow.com/questions/23668459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1066197/"
] | ```
ctx.beginPath();
points.forEach(point => {
ctx.moveTo( point.x, point.y );
ctx.arc(point.x,point.y,1,0,Math.PI*2,false);
});
ctx.fill();
``` | You can easily create several circles with a for loop. You really just need to draw an arc and fill it each time. Using your example, you could do something like this.
```
var ctx = $('#canvas')[0].getContext("2d");
ctx.fillStyle = "#00A308";
for (var i = 0; i < 3; i++) {
ctx.arc(50 * (i+1), 50 + 15 * i, 5, 0, Math.... |
8,044,549 | unsure how to go about describing this but here i go:
For some reason, when trying to create a release build version of my game to test, the enemy creation aspect of it isn't working.
```
Enemies *e_level1[3];
e_level1[0] = &Enemies(sdlLib, 500, 2, 3, 128, -250, 32, 32, 0, 1);
e_level1[1] = &Enemies(sdlLib, 500, 2, ... | 2011/11/08 | [
"https://Stackoverflow.com/questions/8044549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1015476/"
] | Other people have already pointed out the error, namely that the temporaries are getting destroyed straight away, but all of the answers so far are using manual memory management - it's more idiomatic in C++ to use e.g. `std::vector` for something like this, e.g.
```
std::vector<Enemies> enemies;
enemies.push_back(Ene... | The code initializes the pointers to point to temporary objects that are immediately destroyed. Accessing temporaries that no longer exist through pointers or references is undefined behavior. You want:
```
Enemies *e_level1[3];
e_level1[0] = new Enemies(sdlLib, 500, 2, 3, 128, -250, 32, 32, 0, 1);
e_level1[1] = new E... |
39,274,088 | I am writing test cases for a GoLang application and i am using sqlmock for mocking the SQL queries but i am getting following error while executing **go test**
Params: [ call to query , was not expected, next expectation is: ExpectedBegin => expecting database transaction Begin]
Any idea on this? | 2016/09/01 | [
"https://Stackoverflow.com/questions/39274088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1386755/"
] | The error message means some SQL query was called which was not mocked. | I had same issue, because I used `NamedExec` (not `NamedQuery`) to perform my update, but was mocking `ExpectQuery` in test
So,
if you have expression (i.e. use `UPDATE` or `INSERT`), you should use `ExpectExec`
if you have query (i.e. use `SELECT`), you should use `ExpectQuery`
It's obvious, but I stuck with i... |
136,638 | How can I compare the content of two (or more) large .resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not also specified in a culture-specific version. | 2008/09/25 | [
"https://Stackoverflow.com/questions/136638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360388/"
] | Although it's not a diff tool per se, [RESX Synchronizer](http://www.screwturn.eu/ResxSync.ashx) may help you out here. Its main use is to update the localized .resx files with new entries from the neutral language one, and remove any deleted items.
Possibly, the output generated by using it with the /v command line s... | You can use a tool like TortoiseSVN's diff (if you're using Windows). Just select both files, right click and then select "diff" from the TortoiseSVN submenu. |
5,258,035 | Hi
When migrating from ASP.NET to MVC ASP.NET it looks like the MVC is more AJAX friendly.
but still I run into design issue,
Does someone knows Microsoft intention about the design when calling AJAX methods?
Where do I need to put this methods by default, in a separate controller, the same controller?
Is there any kin... | 2011/03/10 | [
"https://Stackoverflow.com/questions/5258035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/650060/"
] | I don't think that there is any *official best practices*. Personally I like to follow [RESTful conventions](http://mvccontrib.codeplex.com/wikipage?title=SimplyRestfulRouting) when organizing cotrollers and actions no matter how those actions are consumed (AJAX or not). | You might wanna try on having a review on [some asp.net samples here](http://www.asp.net/mvc). This will give you some ideas. :) |
55,803,526 | I'm stuck between Firebase Real Time database and Firestore for my e-commerce app. I want to know which one is cheaper. I know there will be alot of reads in an e-commerce app, does this make Firestore more expensive? | 2019/04/23 | [
"https://Stackoverflow.com/questions/55803526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11397434/"
] | You are doing this operation:
```py
range(1, 4) + [1]
```
Which doesn't mean anything in this case.
You have to do the `+ [1]` right after the `[5] * n` as in:
```py
print([[5]*n+[1] for n in range(1, 4)])
``` | This will do the trick as contributors already have answered
```
[[5] * n + [1] for n in range(1, 4)]
```
But in your solution type of range(1, 4) will be , if you want to do some list operations on it like concatenation then you should do like:
```
list(range(1, 4)) + [1]
``` |
64,174,550 | I'm getting this error every time I try to run the application though it compile well:
**pool allocator: Specified pool size too big for this device**
**Current file: /home/marco/Desktop/tools.c
function: PTC3D
line: 330**
**This file was compiled: -ta=tesla:cc35,cc50,cc60,cc70,cc70,cc75,cc80**
The strange thing is... | 2020/10/02 | [
"https://Stackoverflow.com/questions/64174550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14190508/"
] | The message should just be a warning. The pool allocator will be by-passed and instead the CUDA Unified Memory API routines will be called directly for each allocation. You might see some performance degradation if you have a lot of small allocations since the API calls have a relatively high overhead, but shouldn't hu... | I solved going in Software & Updates, in Additional Drivers, setting the recommended driver: NVIDIA driver meta package. |
33,935,612 | Hi I have an alert div as follows,
```
<div style="width: 12%;" ng-if="final_data.status =='confirmed'" class="alert alert-success" role="alert" align="left" ng-cloak>
<span class="glyphicon glyphicon-ok"></span> confirmed</div>
```
The div will pop-up when the status becomes confirmed. How can I ... | 2015/11/26 | [
"https://Stackoverflow.com/questions/33935612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5518196/"
] | You could use javascript to remove it:
```
setTimeout(function(){
var elements = document.getElementsByClassName('alert');
while(elements.length > 0){
elements[0].parentNode.removeChild(elements[0]);
}
},500);
``` | You can watch, when status gets changed to "confirmed" and do something.
```
<div style="width: 12%;" ng-show="canShow" ng-if="final_data.status =='confirmed'" class="alert alert-success" role="alert" align="left" ng-cloak>
<span class="glyphicon glyphicon-ok"></span> confirmed</div>
$scope.canShow = ... |
29,201,763 | I tried to use Google Sign-in for my website, however, it keeps giving me 400 error.
I referenced this article: <https://developers.google.com/identity/sign-in/web/sign-in>, and my code is really simple:
```
<html>
<head>
<title>Test Google Login</title>
<script src="https://apis.google.com/js/platform.js" async ... | 2015/03/23 | [
"https://Stackoverflow.com/questions/29201763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2310331/"
] | Redirect URIs
```
http://localhost:8000/ this **/** at end solve my problem
```
JavaScript origins
```
http://localhost:8000
```
**NOTE: localhost and 127.0.0.1 conflicts can create problems for you sometime** | Replace everywhere`http://127.0.0.1:8000/` to `HTTP://localhost:8000/`even in your browser too. The Problem comes when you use `http://127.0.0.1:8000/` either in the developer console or a browser. |
12,974,115 | I want to open the pdf file in an iframe. I am using following code:
```
<a class="iframeLink" href="https://something.com/HTC_One_XL_User_Guide.pdf"> User guide </a>
```
It is opening fine in Firefox, but it is not opening in IE8.
Does anyone know how to make it work also for IE ? | 2012/10/19 | [
"https://Stackoverflow.com/questions/12974115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1753210/"
] | This is the code to link an HTTP(S) accessible PDF from an `<iframe>`:
```
<iframe src="https://research.google.com/pubs/archive/44678.pdf"
width="800" height="600">
```
Fiddle: <http://jsfiddle.net/cEuZ3/1545/>
EDIT: and you can use Javascript, from the `<a>` tag (`onclick` event) to set iFrame' SRC attribute a... | Do it like this: Remember to close iframe tag.
```
<iframe src="http://samplepdf.com/sample.pdf" width="800" height="600"></iframe>
``` |
1,425,012 | Is it possible to clear the output cache of one asp.net web application from inside another asp.net web application?
Reason being... We have several wep applications structured like...
* <http://www.website.com/intranet/cms/>
* <http://www.website.com/area1/>
* <http://www.website.com/area2/>
Pages in /area1/ and /a... | 2009/09/15 | [
"https://Stackoverflow.com/questions/1425012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1573/"
] | The way I've done this in the past is to have a "hidden" page (in each of the `/areaX` sites) that does the flushing, reloading, etc. The page validates a shared secret query parameter before doing anything (to avoid DoS attacks). If valid the page would output an "OK" message once the operation is complete; generates ... | One way I know of doing this is by using a shared resource as a dependency, usually a file. When the file is changed, the cache is cleared. I think you can use [HttpResponse.AddFileDependency](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.addfiledependency.aspx) for this.
However, in these cases it's... |
11,160 | I want take a photo of a scene lit by a yellow-orange street light. Unlike many of the questions here, I don't want to balance the colours in the scene, rather I want the areas lit by that light to remain yellow. The street light is the dominant light source in the scene.
What white balance settings do I need to captu... | 2011/04/21 | [
"https://photo.stackexchange.com/questions/11160",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/3356/"
] | For my taste, "tungsten" has worked best in such situation. The street lights are actually way more yellow than standard tungsten, but the eye somewhat adjusts to the color cast, so the photo will be quite similar to what was actually seen. For example, this shot is a (resized) camera JPEG, tungsten WB:
![A bridge to ... | There is no simple answer to this as it depends on what the lighting produced by, there are several gasses and metal vapours used for street lights,some, such as metal halide are full spectrum, i.e. they contain all colours of the spectrum but just colour shifted, and some i.e. Sodium vapour are not full spectrum, with... |
19,071,933 | I've been doing some tests with Valgrind to understand how functions are translated by the compiler and have found that, sometimes, functions written on different files perform poorly compared to functions written on the same source file due to not being inlined.
Considering I have different files, each containing fun... | 2013/09/28 | [
"https://Stackoverflow.com/questions/19071933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2264920/"
] | If you are using `gcc` you should try the options `-combine` and `-fwhole-program` and pass all the source files to the compiler in one invocation. Traditionally different C files are compiled separately, but it is becoming more common to optimize cross compilation units (files). | The *compiler proper* cannot inline functions defined in different translation units simply because it cannot see the definitions of these functions, i.e. it cannot see the source code for these functions. Historically, C compilers (and the language itself) were built around the principles of *independent translation*.... |
39,124,468 | I am having few ISO8583 logs in a text file. I want to parse these logs from this text file and write them to any database with some descriptive information such as class of the message, message function, message origin, processing code, response code etc.
I am new to the BASE24/ISO8583 and was trying to find any read... | 2016/08/24 | [
"https://Stackoverflow.com/questions/39124468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2710961/"
] | what is displayed in log file is parsed ISO.Hence you need not use jpos.jpos is only for packing and unpacking when you transmit the message.
Assign the field to variable and write in DB
for example,Field 39 is response code. | Using jpos is good idea. You should go for your custom packager design class. |
837,167 | About 10 years ago, I was using a computer language called INFO on an ancient Prime. It was a funky, but oddly useful language, and I'd like to find out more about it. For instance, can I get a copy that would run on a PC? However, if I google for "INFO" and "Computer Language," I'm not going to find it. I've tried. I ... | 2009/05/07 | [
"https://Stackoverflow.com/questions/837167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22523/"
] | The easiest way is to not try and make a regex do this. Just loop over the string one character at a time. If you read a '(', increment a counter. If you read a ')', decrement that counter. If you read a comma, delete it if the counter is 0, otherwise leave it alone. | ```
Sub Main()
'
' remove Commas from a string containing expression-like syntax
' (eg. 1,000,000 + IntPow(3,2) - 47 * Greep(9,3,2) $ 5,000.32 )
' should become: 1000000 + IntPow(3,2) - 47 * Greep(9,3,2) $ 5000.32
'
Dim tInput As String = "1,000,000 + IntPow(3,2) - 47 * Greep(9... |
58,962,313 | Assume I have the following code:
```
template<bool t>
class A{
class B{
class C{
public:
void foo();
};
};
};
template<bool t>
void A<t>::B::C::foo() {
// some code
}
```
when writing the definition of this function `foo()` , I wish to avoid writing the too-long nested name specifier `A<t... | 2019/11/20 | [
"https://Stackoverflow.com/questions/58962313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7005200/"
] | While you can create an alias:
```
template<bool T>
using X = typename A<T>::B::C;
```
You cannot use that alias as a specifier in the declaration:
```
template<bool T>
void X<T>::foo() // not allowed; doesn't compile
{
...
}
```
Afaik you need to use the fully qualified name in the declaration. | I think the best you can do is:
```
template <bool T> using aShortAlias = typename A<T>::B::C;
template<> void aShortAlias<false>::foo() {
}
template<> void aShortAlias<true>::foo() {
}
``` |
6,328,187 | This code gives every step-result of computing factorial of given number but I want only the final.
```
#include <stdio.h>
long int factorial(int n) {
if (n <= 1)
return(1);
else
n = n * factorial(n - 1);
printf("%d\n", n);
return(n);
}
main() {
int n;
printf("Enter n: ");
scanf("%d", &n);
/... | 2011/06/13 | [
"https://Stackoverflow.com/questions/6328187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/700089/"
] | How about this ?
```
int final;
final = factorial(n);
printf("%d! = %d\n", n, final);
```
And stop using `printf` in the `factorial` function. | ```
long int factorial(int n){
if(n<=1)
return 1;
return n*factorial(n-1);
}
``` |
49,642,800 | I have a DialogFragment in my Android app, and I need to set `android:configChanges="orientation|screenSize`, I want to load different layout for my DialogFragment in portrait or landscape, but now Android will not automatically do this for me, I think I need to update the layout in `onConfigurationChanged` , but I don... | 2018/04/04 | [
"https://Stackoverflow.com/questions/49642800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7290767/"
] | Your code will not compile as is. `s1` is not in main method and `reverse` method is accepting an `int` not `String`.
Also, if you need to return an `int` from your method why not the reversed `int` which is the answer.
Few edits to your code which will solve your issue.
```
public static void main(String[] args)... | ```
import java.util.Scanner;
public class Lab7 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Type the integer you'd like to be reversed:");
int num = s.nextInt();
String strNum = ""+num;
reverse(strNum);
}
public static int reverse(String strN... |
48,829,263 | I dont know how to attach onClick action with jquery to all the element from the list of attached files.
That is my html file.
```
<p>Attachements</p>
<div>
<ul id="attach">
<li id="KjG344D">liu-kang.jpg<img src="/images/thrash.gif" id="delete_file"></li>
<li id="3ujRCMB">kitana.jpg<img src="/images/th... | 2018/02/16 | [
"https://Stackoverflow.com/questions/48829263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3950348/"
] | All your links have id's an id has to be unique on a webpage so use classes instead. give each element a class e.g. `class="delete-file"` and then set your trigger onto the class name.
```
$('.delete-file').on('click', function() {
//do delete
})
```
Also use `.on` or `.once` for attaching the event instead of `... | THank YoU VerRy mUch for Your answers. I solved the problem. And I have learned something new. Creating it as 'class' and using it in jquery made it WORK ! Thanks |
70,811,647 | I have two snippets of code that I want to put in the same line and center, but am unable to do
Number 1:
```
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_whatsapp"></a>
<a class="a2a_button_pinterest"></a>
... | 2022/01/22 | [
"https://Stackoverflow.com/questions/70811647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18001085/"
] | Waiting for the child works. However, your expectations are wrong.
Apparently you think that computations in the child process after the fork are visible in the parent process. They are not. The child is a new copy of the parent program at the time of fork. At that time, the parent's `sum` is 0 and stays that way.
Th... | The issue here is the variable **sum** is not shared by the parent & child process, after fork() call the child will have its own copy of the variable sum.
Use **shmget(),shmat()** from **POSIX** api. Or use **pthread** which will share the same memory space for the newly created thread.
Update---
Added the shared memo... |
724,474 | I was reading a book about Special Relativity. There is a chapter where it explains why magnetism is just an electrostatic force because of lenght contraction.
The book, uses two reference systems $S$ and $S'$. In the first one, is "at rest", and sees the electrons drifting with velocity $v$ (for simplicity we will ... | 2022/08/23 | [
"https://physics.stackexchange.com/questions/724474",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/281431/"
] | It's simply the converse of length contraction. In $S$, the spacing between the electrons was contracted compared to its rest frame $S'$, so when you switch to $S'$, you have an effective length dilation of value $\gamma$.
Mathematically, you obtain the following. Let $\lambda\_+,\lambda\_-$ be the respective linear c... | Lorentz transformations are reversible. You can reason about the "old" frame by treating the "new" frame as if it's the old one, and then doing a boost in the other direction.
If the separation between electrons in the "new" frame (where the electrons are stationary) is $d$, then in the "old" frame, which is moving wi... |
12,356,056 | I have seen the other errors about this problem. I have done the exact same thing. When I try to render the menu I get this Fatal error:
```
Fatal error: Call to undefined method Knp\Menu\MenuItem::setCurrentUri()
in ProjectBundle/Menu/Builder.php on line 23
```
This is how my Builder looks:
```
<?php
use Knp\Menu\... | 2012/09/10 | [
"https://Stackoverflow.com/questions/12356056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366455/"
] | It looks like the `MenuItem::setCurrentUri()` method was deprecated as of v1.1.0. See <https://github.com/KnpLabs/KnpMenu/issues/63> for more information. That issue has several links on how to set the current uri of the menu using `UrlVoter` instead. | I found the simplest solution.
just add:
```
$menu->setCurrent(true);
```
It adds class 'current' to current menu. Method `setCurrentUri` has been deprecated and later removed from knpmenu. |
12,596,098 | I have these two tables:
```
desc students
+-----------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------+------+-----+---------+----------------+
| student_id | int(11) | NO | PRI |... | 2012/09/26 | [
"https://Stackoverflow.com/questions/12596098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1398242/"
] | ```
for(int j=0;j< GenresArray.count; j++)
{
NSString *value=[[genre componentsSeparatedByString: @","]objectAtIndex:j];
if([value isEqualToString:@"movies"])
{
[genreMovies addObject:value];
}
... | You can try to check if the string contains the substring you want . Like this:
```
NSString *typesString = [dic objectForKey:"genres_en"];
NSRange range = [typesString rangeOfString:@"horror"];
if(range.location != NSNotFound)
{
//it contains the substring "horror"
}
```
Or , the better way would be to get the ... |
32,795,160 | When I open web-forms page on a browser but i am getting this error
```
Object reference not set to an instance of an object
```
Kindly review the code snippet, what i am doing wrong
```
if (!IsPostBack)
{
if (string.IsNullOrEmpty(Session["LoginUser"].ToString()) == false && string.IsNullOrEmpty(Session["Custom... | 2015/09/26 | [
"https://Stackoverflow.com/questions/32795160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5370744/"
] | When you update your composer it will check the providers. Because you haven't installed `laravelcollective/html` yet he can't find it and throws an error:
So first require your packeges, then add them to the config file.
You can also work with `composer require laravelcollective/html`, it will add it to the json fil... | Installation failed, reverting `./composer.json` to its original content.
>
> [ErrorException]
>
> copy(/home/zahid/.composer/cache/files/laravelcollective/html/20e9e29d83e23aba16dc4b8d93d0757e1541f076.zip):
> failed to open stream: Permiss ion denied
>
>
>
Command: `composer require laravelcollective/html --p... |
38,081,807 | The following for loop in Go isn't allowed,
```
for i := 0, j := 1; i < 10; i++, j++ {...}
```
What's the correct equivalent of the for-loop of two variables below?
```
for (int i = 0, j = 1; i < 10; i ++ , j ++) {...}
``` | 2016/06/28 | [
"https://Stackoverflow.com/questions/38081807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/363663/"
] | Although above Answer is accepted, and it fully satisfy the need. But I would like to contribute some further explanation to it.
Golang Does not support many things which could be done in simple terms. For loop is a most common example of this. The beauty of Go's For loop is that it merges many modern style of loopin... | Suppose you want to loop using two different starting index, you can do this way.
This is the example to check if string is palindrome or not.
```
name := "naman"
for i<len(name) && j>=0{
if string(name[i]) == string(name[j]){
i++
j--
continue
}
return false
}
return true
```
This... |
2,918,464 | I need to get a closed form from
$$
\sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} \sum\_{k=1}^{j} 1
$$
Starting from the most outer summation, I got
$$
\sum\_{k=1}^{j} 1 = j
$$
But now I don't know how to proceed with:
$$
\sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} j
$$
Could you guys please help me?
Thanks in advance. | 2018/09/16 | [
"https://math.stackexchange.com/questions/2918464",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/585618/"
] | Thanks @Winther for pointing out the previous mistake
\begin{equation}
\sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} \sum\_{k=1}^{j} 1
\end{equation}
We know that
\begin{equation}
\sum\_{k=1}^{j} 1 = j
\end{equation}
So
\begin{equation}
\sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} \sum\_{k=1}^{j} 1 =
\sum\_{i=1}^{n-1} \sum\_{j=i+1}... | Knowing that
\begin{align}
\sum\_{k=1}^{n} (1) &= n \\
\sum\_{k=1}^{n} k &= \frac{n \, (n+1)}{2} \\
\sum\_{k=1}^{n} k^2 &= \frac{n(n+1)(2n+1)}{6}
\end{align}
then
\begin{align}
S &= \sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} \sum\_{k=1}^{j} (1) \\
&= \sum\_{i=1}^{n-1} \sum\_{j=i+1}^{n} j \\
&= \sum\_{i=1}^{n-1} \left(\sum\_{j... |
35,146,538 | The [WeakMap polyfill](https://github.com/webcomponents/webcomponentsjs/blob/master/src/WeakMap/WeakMap.js) is throwing an error when trying to define property on inextensible object.
Those are in the middle of a bunch of node, javascript code and libraries so I couldn't actually point out where causes the issue. There... | 2016/02/02 | [
"https://Stackoverflow.com/questions/35146538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159297/"
] | As best I can tell that `weakMap` polyfill is ONLY designed to work with extensible objects as keys. It simply won't work with a non-extensible object.
Your modification has made it so it doesn't throw an exception, but then the non-extensible item will not be in the `weakMap` either. So, your fix isn't really a fix.... | As in my question, I want a solution which does not have huge impact on other functionality or plugins, so here is my fix for this issue. The fix is based on the answer of @jfriend00 above and reference from other implementation in the internet.
```
var defineProperty = Object.defineProperty;
var counter = Date.now() ... |
880,141 | I need to generate something that can be used as a unique handle for a user defined type (struct or class) in the [D programming language](http://digitalmars.com/d/1.0/index.html). Preferably this would be a compile time computable value. I want the handle to relate to the name of the type as well as change if the inte... | 2009/05/18 | [
"https://Stackoverflow.com/questions/880141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | The fully qualified name of a type should be unique. This is the same as typeid(T).toString. This is *not* the same as T.stringof -- T.stringof will erase any template instantiations and will not give the fully qualified name.
The workaround is to use demangled(T.mangleof) at compiletime and typeid(T).toString at runt... | You know, you can just hardcode a revision into the type, like "const REV = 173; ", then update it every time you change the layout, then mix that with the type name to produce your identifier.
This is a bit of a hassle because it requires manual updates, but you could script it to be updated automatically on commit w... |
312,834 | In the context of quantum mechanics one cannot measure the velocity of a particle by measuring its position at two quick instants of time and dividing by the time interval. That is,
$$ v = \frac{x\_2 - x\_1}{t\_2 - t\_1} $$ does not hold as just after the first measurement the wavefunction of the particle "collapses".
... | 2017/02/17 | [
"https://physics.stackexchange.com/questions/312834",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/133131/"
] | For a cold atom experiment, experimentalists use time-of-flight (TOF) measurement to determine the momentum distribution of atoms in the optical trap. Suppose there are an ensemble of atoms trapped in the optical trap, when the optical trap is switched off, the atoms will "fly around" with their momentum. With detector... | In condensed matter physics community, one can use the [ARPES apparatus](https://en.wikipedia.org/wiki/Angle-resolved_photoemission_spectroscopy). [ARPES gives information](http://www.arpes.org.uk/Index.html) on the direction, speed and scattering process of valence electrons in the sample being studied (usually a soli... |
10,404,208 | I heard it is possible to write an Operating System, using the built in bootloader and a kernel that you write, for the PIC microcontroller. I also heard it has to be a RTOS.
1. Is this true? Can you actually make an operating system kernel (using C/C++) for PIC?
2. If yes to 1, are there any examples of this?
3. If y... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10404208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162346/"
] | 1. Yes, you can write your own kernel (I have written 2 of my own). Yes you can write it in C for PIC. If you want pre-emptive scheduling, then you're going to have a real tough time avoiding assembly completely when writing the context switch. On the other hand, you can *easily* write a cooperative kernel purely in C ... | I second the vote for FreeRTOS; we use this all the time on PIC24 designs. The port works well and doesn't use a ton of memory.
[Microchip supports many third party RTOSes.](http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en531543&page=wwwRTOS)
Most have free demo projects that yo... |
28,418,233 | I have a django application with an angular front-end. When from the front-end I try to send a request for passwordReset, I get the following error:
>
> Reverse for 'password\_reset\_confirm' with arguments '()' and keyword
> arguments '{u'uidb64': 'MTE', u'token': u'3z4-eadc7ab3866d7d9436cb'}'
> not found. 0 patte... | 2015/02/09 | [
"https://Stackoverflow.com/questions/28418233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131194/"
] | For those who are still struggling with this issue, I found that the reverse look up internal view looks for reverse lookup within the core project urls and not within any application. It could work within application with some tweak, but I am not sure. But it works creating the reset urls directly on core project urls... | Add this to your project url.py file
```
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
url('', include('social.apps.django_app.urls', namespace='social')),
``` |
26,975,914 | I have a list of packages and want to remove suffixes from specific combination of characters.
Should I use regex or other mehotds such as replace ? All packages' endings are different because these are versions so I am not sure which to use and how. I think I should clear the remaining characters from `-0:` in string... | 2014/11/17 | [
"https://Stackoverflow.com/questions/26975914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4095134/"
] | `partition` on "-0" and take the left portion.
```
seq = ['znc-devel-0:1.4-1.el6.i686', 'znc-devel2-0:1.4-1.el6.x86_64']
print [item.partition("-0")[0] for item in seq]
```
Result:
```
['znc-devel', 'znc-devel2']
``` | Through `re.sub` and list comprehension.
```
>>> L = ['znc-devel-0:1.4-1.el6.i686', 'znc-devel2-0:1.4-1.el6.x86_64']
>>> import re
>>> [re.sub(r'-0:.*', r'', line) for line in L]
['znc-devel', 'znc-devel2']
``` |
19,418 | I need to edit my OpenOffice documents.
Is there any version of LibreOffice for Android?
Or
Is there any ODT texteditor app for Android? | 2012/02/13 | [
"https://android.stackexchange.com/questions/19418",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/9897/"
] | [Zoho Writer](https://play.google.com/store/apps/details?id=com.zoho.writer) seems to support viewing & editing ODT files (only tested with a very simple document):
>
> ...
>
>
> * Supports saving of documents in different formats like doc,docx,rtf,odt,txt,html and PDF
>
>
>
Though it seems to work awkwardly:
... | [Collabora Office](https://play.google.com/store/apps/details?id=com.collabora.libreoffice), a LibreOffice derivative, works well on my tablet. |
18,969,798 | Essentially, I'm trying to find a good way to attach more views to a Router without creating a custom Router. **What's a good way to accomplish this?**
Here is something sort of equivalent to what I'm trying to accomplish. Variable names have been changed and the example method I want to introduce is extremely simplif... | 2013/09/23 | [
"https://Stackoverflow.com/questions/18969798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/485900/"
] | The [answer given by mariodev](https://stackoverflow.com/a/18970651/3216056) above is correct, as long as you're only looking to make `GET` requests.
If you want to `POST` to a function you're appending to a ViewSet, you need to use the `action` decorator:
```
from rest_framework.decorators import action, link
from r... | You can now do this with the list\_route and detail\_route decorators: <http://www.django-rest-framework.org/api-guide/viewsets/#marking-extra-actions-for-routing>
For example:
```
from rest_framework.decorators import list_route
from rest_framework.response import Response
...
class MyObjectsViewSet(viewsets.ViewSe... |
6,283,837 | About pyQt4
I prefer to use the static method for the getSaveFilename in the QFileDialog so that the user sees the Windows/Mac native dialog.
My problem is that if the user doesn't type the file extension the in the save file name (say when selecting an image type to save a file as), then I don't have a way of checki... | 2011/06/08 | [
"https://Stackoverflow.com/questions/6283837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/771740/"
] | In PyQt5 just use:
```
files_types = "GML (*.gml);;Pickle (*.pickle);;YAML (*.yml)"
options = QFileDialog.Options()
filename, _ = QFileDialog.getSaveFileName(
self, 'Save as... File', 'untitled.gml', filter=file_types,options=options)
``` | Its not possible.
The only way to do this, is creating a generical dialog, but by another hand you will lost the pretty native windows. |
53,778,712 | I have been trying to create a **custom** login feature in **ASP.NET Core 2.1**. However, it doesn't seem the work and I have no idea why.
This is run in the controller:
```
var claims = new List<Claim>
{
new Claim(ClaimTypes.Email, email),
new Claim(ClaimTypes.Role, loginResult.User.RoleName)
};
ClaimsIdent... | 2018/12/14 | [
"https://Stackoverflow.com/questions/53778712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5350903/"
] | I know this was asked a long time ago, but I recently encountered this same issue. So,here I am sharing my finding.
```
app.UseHttpsRedirection();
app.UseStaticFiles();
var cookiePolicyOptions = new CookiePolicyOptions
{
MinimumSameSitePolicy = SameSiteMode.Strict,
HttpOnly = Microsoft.AspNetCore.CookiePolicy.Ht... | Try one of the following process:
1. Clear browser cache.
2. Use a different browser. |
192,852 | Output Distinct Factor Cuboids
==============================
Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors.
Explanations
------------
A cuboid's volume is the product of its three side lengths. For example, a cuboid of volume 4 whose side lengt... | 2019/09/15 | [
"https://codegolf.stackexchange.com/questions/192852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/78850/"
] | [JavaScript (V8)](https://v8.dev/), ~~61~~ 60 bytes
===================================================
Prints the cuboids to STDOUT.
```javascript
n=>{for(z=n;y=z;z--)for(;(x=n/y/z)<=y;y--)x%1||print(x,y,z)}
```
[Try it online!](https://tio.run/##JYxNCoMwGET3PUU2xYSOlST9EdLPXbe9QOlCBKldpGJFTNSzpxE3w8wbeJ9yKH9V17R9... | [Pyth](https://github.com/isaacg1/pyth), 11 bytes
=================================================
```
fqQ*FT.CSQ3
```
[Try it online!](https://tio.run/##K6gsyfj/P60wUMstRM85OND4/39jMwA "Pyth β Try It Online")
```
SQ # range(1, Q+1) # Q = input
.C 3 # combinations( ... |
34,448,539 | * MySQL version: 5.6
* Storage engine: InnoDB
The deadlock occurred when two tasks tried to `select` and then `insert` the same table. The procedure looks like:
```
Task_1 Task_2
------ ------
Phase 1 | SELECT SELECT
Phase 2 | INSERT INSERT
SELECT count(id) from mytbl where n... | 2015/12/24 | [
"https://Stackoverflow.com/questions/34448539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3510918/"
] | >
> where name = 'someValue' and timestampdiff(hour, ts, now()) < 1;
>
>
>
That is rather inefficient. Let's clean that up to speed things up, to decrease the likelihood of a deadlock.
`timestampdiff(hour, ts, now()) < 1` hides any index with `ts`; let's rewrite it to
```
ts < NOW() - INTERVAL 1 HOUR
```
Yours... | Write your every query in **BEGIN** and **END** transaction. I hope it will not happened.
More : [here](http://dev.mysql.com/doc/refman/5.7/en/commit.html) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.