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 |
|---|---|---|---|---|---|
292,621 | I've downloaded the Windows 7 `.vhd` from Microsoft's site. I created a virtual PC from that `.vhd`. It runs OK, but the welcome screen want a password for one of the accounts (admin and administrator).
I've tried guessing a few passwords but with no luck...
Anyone knows the correct password? | 2011/06/03 | [
"https://superuser.com/questions/292621",
"https://superuser.com",
"https://superuser.com/users/82407/"
] | Note the new password might be
>
> Login Instructions
>
> Login Information (for Windows Vista, 7, 8 VMs):
> IEUser, Passw0rd!
>
>
>
If you downloaded from <http://www.modern.ie/en-us/virtualization-tools#downloads>
see <https://modernievirt.blob.core.windows.net/vhd/virtualmachine_instructions_2013-07-22.p... | Here it is: Passw0rd!
As the following image shows:
 |
25,266,989 | I am trying to submit form which is in primefaces dialog `<p:dialog/>`.
```
<h:form>
<h:inputHidden value="123" id="domesticTransferId" />
<p:commandButton action="#{domesticTransactionsController.addFirstSignerSignToTransaction}"
id="domesticTransferFirstSignerSign"
value="... | 2014/08/12 | [
"https://Stackoverflow.com/questions/25266989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/791195/"
] | Your command button must be :
```
<p:commandButton action="#{domesticTransactionsController.addFirstSignerSignToTransaction()}"
id="domesticTransferFirstSignerSign"
value="#{msg['label.FirstSignerSignature']}"
icon="ui-icon-print"
styleClass="myButton" ... | Try with this:
```
public String addFirstSignerSignToTransaction(ActionEvent event){
System.out.println("DomesticTransactionsController.addFirstSignerSignToTransaction()");
return "";
}
```
Check that ManagedBean is javax.faces.bean.ManagedBean |
186,084 | Just this - How do you add a timer to a C# console application? It would be great if you could supply some example coding. | 2008/10/09 | [
"https://Stackoverflow.com/questions/186084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535708/"
] | Or using Rx, short and sweet:
```
static void Main()
{
Observable.Interval(TimeSpan.FromSeconds(10)).Subscribe(t => Console.WriteLine("I am called... {0}", t));
for (; ; ) { }
}
``` | Use the PowerConsole project on Github at <https://github.com/bigabdoul/PowerConsole> or the equivalent NuGet package at <https://www.nuget.org/packages/PowerConsole>. It elegantly handles timers in a reusable fashion. Take a look at this sample code:
```
using PowerConsole;
namespace PowerConsoleTest
{
class Pro... |
13,511,565 | just feeling that i'm wasting loops here = CPU time, and was wondering if there's a way to optimize this code, or just minimize it.
Basically what the code does is, goes trough every controls inside the editOkkInfo control.
checking if the current control is an textbox, if yes, then it will perform some stuff, if no i... | 2012/11/22 | [
"https://Stackoverflow.com/questions/13511565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1670729/"
] | There is no need to use `FindControl`, as you already have the control. Just cast it:
```
iterate = 0;
foreach (System.Web.UI.Control ctrl in this.editOkkInfo.Controls)
{
if (ctrl is TextBox)
{
tb = (TextBox)ctrl;
tb.Text = dt.DefaultView[0][iterate++].ToString();
}
if (iterate == 14)... | I have seen one faster way to find all controls of specific type rather than looping.
This seems more efficient.
[Using linq to get list of web controls of certain type in a web page](https://stackoverflow.com/questions/3613561/using-linq-to-get-list-of-web-controls-of-certain-type-in-a-web-page)
Hope that helps
Milind |
8,405,412 | Maybe I'm not understanding something, but can somebody explain to me why the following code is behaving the way it is:
```
/^[1-9]\d*(\.\d{2})?$/.test('0.50') === false;
/^\.\d+$/.test('0.50') === false;
/^([1-9]\d*(\.\d{2})?)|(\.\d+)$/.test('0.50') === true; // <-- WTF?
```
What's going on here? As you can see the... | 2011/12/06 | [
"https://Stackoverflow.com/questions/8405412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115049/"
] | This is because of precedence of operators.
Your expression is `^[1-9][0-9]*(\.\d{2})?` or `\.\d+$`.
If you do the following:
```
/^([1-9][0-9]*(\.\d{2})?)$|^(\.\d+)$/.test('0.50')
```
you will get `false` as you expect.
(Note extra $ and ^ at the boundaries).
More details: in your second part of last expression... | Yeah, but that isn't false | false. I'll add some more parentheses to make it clear what the third regex is evaluating as:
```
/(^([1-9]\d*(\.\d{2})?))|((\.\d+)$)/.test('0.50') === true; // <-- WTF?
``` |
856,318 | I am trying to host two seperate domains on one IP address. I want to be able to determine from the STARTTLS command which certificate was being requested and forward to a different mail server based on the domain.
This doesn't seem to be possible from the RFCs, but is there any other way something like this can be ac... | 2017/06/16 | [
"https://serverfault.com/questions/856318",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | [According to the documentation](http://www.postfix.org/TLS_README.html), Postfix sends SNI information in the TLS handshake after `STARTTLS` command, at least in the case where TLSA records are published in DNS:
>
> When usable TLSA records are obtained for the remote SMTP server the Postfix SMTP client sends the SN... | You don't need SNI for this. Most MTAs support routing based on domain. For example [postfix has a transport map](http://www.postfix.org/transport.5.html). You'd make a map something like:
```
foo.com smtp:[mail.foo.com]
bar.com smtp:[mail.bar.com]
``` |
30,999,820 | How to retrieve `int` value from `List` that is biggest number on it but still smaller than `X` value to which i am comparing.
```
Value = 10
Example one: List = {1,4,6,8}; => number 8 biggest on list and smaller than 10
Example two: List = {1,15,17,20}; => number 1 biggest on list and smaller than 10
```
I was tr... | 2015/06/23 | [
"https://Stackoverflow.com/questions/30999820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1606426/"
] | You can just restrict the values you use to get the "Max" by using a `Where` clause:
```
return myList.Where(x => x < 10).Max();
``` | You can use [`Where`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.where%28v=vs.100%29.aspx) to filter your values which less than `10` and use [`Max`](https://msdn.microsoft.com/en-us/library/system.linq.enumerable.max%28v=vs.100%29.aspx) to get maximum values in them like;
```
var list = new List<... |
60,768 | In the Brexit negotiations there have been various pledges and demands that the final agreement will "not compromise [UK] sovereignty". E.g:
* [Brexit fishing fury: Boris warned fishing compromise is step to forfeiting UK sovereignty](https://www.express.co.uk/news/politics/1368010/Brexit-fishing-news-Boris-Johnson-tr... | 2020/12/07 | [
"https://politics.stackexchange.com/questions/60768",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/13141/"
] | I once heard Harold Wilson argue that if you organised the World Cup, in doing so you "lost a little bit of sovereignty" (this was in late 1966). He was not opposed to doing so but just pointing out that - yes membership of the EU would involve loss of sovereignty, but so did our organising the World Cup, which in any ... | After the Tudors and up until 1689 there was a political struggle between the King and the English Parliament which ended with the "Glorious Revolution" and the recognition of Parliamentary sovereignty.
This meant that what is now the UK Parliament was the highest legal authority. Acts passed by parliament cannot be a... |
62,157,695 | Is there any sort of Maven plugin that allows me to copy the class files for a dependency into the target\classes folder for my project? Currently I have to manually open the jar file that has the dependencies extract the package that I need to copy over and then copy it into the target\class folder for my project.
I... | 2020/06/02 | [
"https://Stackoverflow.com/questions/62157695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13667190/"
] | This sounds like a terrible idea. If you want to include unpacked dependencies into your project, use the maven assembly plugin or the maven shade plugin. | below is the example to use of assembly pulgin and it works for me
below is the child pom plugin
```
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<ma... |
491,681 | I would like to have an `enumerate` list, **with the numbers expressed in unary**. That is, "1" would be represented as `•`, "3" as `•••`, and "8" as `•••••|•••`.
I'm able to print the dots already, and that's working fine:
```
\newcommand{\xxdot}{\textbullet} % The dot character to use
\newcounter{loopcntr} % A one-... | 2019/05/20 | [
"https://tex.stackexchange.com/questions/491681",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/169121/"
] | The `enumitem` package is your friend. You can define a new list style, which I have called `unerate`, and then make this list style use your `\unary` code. To achieve this it is enough to add the following lines to your code:
```
\let\realItem\item
\newcommand\unerateItem{\refstepcounter{uneratei}\realItem[\unary{une... | Here's an expandable `\unifive` macro:
```latex
\documentclass{article}
\usepackage{xparse,enumitem,tipa}
\usepackage{showframe}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\unifive}{m}
{% #1 should be an integer
\draconis_unifive:n { #1 }
}
\cs_new:Nn \draconis_unifive:n
{
\int_compare:nTF { #1 > 5 }
{
... |
30,345,134 | I am getting the following exception in Android Studio plugin Android Support.
To get out of this error, I updated the Android Studio to 14.1, but studio just builds the app but not runs it.
```
null
java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.android.sdklib.internal.avd.AvdManager.pa... | 2015/05/20 | [
"https://Stackoverflow.com/questions/30345134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2738452/"
] | I Slove it by this step
you should delete this file that you can do it .
go to the path :"C:\Users\Administrator.android\avd"
and delete all the avd folders files .
try again ,you can get it. | ### Why this happens
```
at com.android.sdklib.internal.avd.AvdManager.parseAvdInfo(AvdManager.java:1616)
```
The error seems to be in Android SDK library [Android Virtual Device Manager](https://developer.android.com/tools/help/avd-manager.html). It tries to open a file, and some argument in File constructor is nu... |
1,930,062 | My friend had an interview at Cambridge. He was asked the following question, and was stumped:
>
> I fly to Chicago. The plane trip is $8$ hours. I look at the time and then set my watch back $6$ hours. Knowing that the Earth rotates $360^\circ$ in $24$ hours, what is the radius of the Earth?
>
>
> | 2016/09/17 | [
"https://math.stackexchange.com/questions/1930062",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/279340/"
] | There is not enough information in the question to get anywhere near an estimate of the earth's radius.
Even if we assume that "setting your watch back 6 hours" means that the difference in *longitude* between the two points is exactly 90°, the question still doesn't specify the **latitude** of the two cities. And, of... | My guess is that the interviewer was not expecting to get an exact answer, but was looking to see how confident your friend was at making their own approximations and working using those. For example, here are two guestimates that, if correct, would provide the information that is needed as previous answers have pointe... |
332,474 | I've just installed Ubuntu 12.04 yesterday, and i'm having problems watching video's on YouTube. Once I get to full screen the frame rate drops to 16fps.
My PC runs the latest games on very high, so I don't think my hardware would be a problem.
I'm using Chromium, but Firefox has the same issue.
Other flash based ... | 2013/08/14 | [
"https://askubuntu.com/questions/332474",
"https://askubuntu.com",
"https://askubuntu.com/users/184001/"
] | Sadly Adobe Flash 11.2 has a blacklist of graphics cards which it will not allow to use hardware acceleration, even with a good card, so it's just luck if yours is supported and on the white list...
You could try installing MiniTube and gstreamer0.10-ffmpeg which allows you to search and play YouTube videos full scre... | Maybe this helps, but I'm not sure.
Switch to full screen and click the right mouse button and then click on Configurations and try to activate or deactivate graphic acceleration.
I once had problems with YouTube and this solved it. |
40,349,038 | I have a UIView at my view controller. And I want to draw some labels programmatically at the screen. So I thought I can subclass it and at that class to the UIView.
My code:
```
import Foundation
import UIKit
class MainBottomView : UIView{
required init?(coder aDecoder: NSCoder) {
super.init(frame: UIS... | 2016/10/31 | [
"https://Stackoverflow.com/questions/40349038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477850/"
] | If you’d like to create conformance profiles by scratch, or by generating rules from existing messages then I recommend you use the HL7 Soup tool.
They have a video on the subject here that will cover how to create the rules, and get you started.
<http://www.hl7soup.com/ValidateHighlightAndCompare.html>
Once you’ve ... | To build conformance profiles from scratch or from existing messages, you may take a look at Caristix Conformance (<http://caristix.com/hl7-tools/conformance/scope-hl7-interfaces/>). Once you have the conformance profile set, you can compare it with another profile (or set of messages) an get a gap analysis report.
Th... |
136,359 | I have the below screen that shows a list of items. The list can sometimes be long and sometimes short. When the list is long, the UI looks okay, but when it is short, the screen looks a little boring. Is there any suggestion to improve the display in this scenario?
[![Display of two phone mockups; one has only two it... | 2021/01/18 | [
"https://ux.stackexchange.com/questions/136359",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/141727/"
] | ### The first screen isn't "boring," it's "focused."
A user will be task-driven and goal-oriented during this setup process. Rather than looking to be entertained or stimulated (as with a news or social media application), they're trying to get a task completed. If the user happens to see fewer options during this ste... | A footer after the final list item (with, say, the number of results) may help indicate that the user has seen all the possible results.
[](https://i.stack.imgur.com/1HpQf.png)
(Please excuse my art skills) |
50,275,945 | I create an Angular app that search students from API. It works fine but it calls API every time an input value is changed. I've done a research that I need something called debounce ,but I don't know how to implement this in my app.
**App.component.html**
```
<div class="container">
<h1 class="mt-5 mb-5 text-c... | 2018/05/10 | [
"https://Stackoverflow.com/questions/50275945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If you are using angular 6 and rxjs 6, try this:
Notice the `.pipe(debounceTime(1000))` before your `subscribe`
```
import { debounceTime } from 'rxjs/operators';
search() {
this.http.get("https://www.example.com/search/?q="+this.q)
.pipe(debounceTime(1000))
.subscribe(
(res:Response) => {
... | user.component.html
```
<input type="text" #userNameRef class="form-control" name="userName" > <!-- template-driven -->
<form [formGroup]="regiForm">
email: <input formControlName="emailId"> <!-- formControl -->
</form>
```
user.component.ts
```
import { fromEvent } from 'rxjs';
impor... |
7,388,397 | Hi please help me out in getting regular expression for the
following requirement
I have string type as
```
String vStr = "Every 1 nature(s) - Universe: (Air,Earth,Water sea,Fire)";
String sStr = "Every 1 form(s) - Earth: (Air,Fire) ";
```
from these strings after using regex I need to get values as `"Air,Earth,Wat... | 2011/09/12 | [
"https://Stackoverflow.com/questions/7388397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11114/"
] | The regular expression would be something like this:
```
: \((.*?)\)
```
Spelt out:
```
Pattern p = Pattern.compile(": \\((.*?)\\)");
Matcher m = p.matcher(vStr);
// ...
String result = m.group(1);
```
This will capture the content of the parentheses as the first capture group. | If you have each string separately, try this expression: `\(([^\(]*)\)\s*$`
This would get you the content of the last pair of brackets, as group 1.
If the strings are concatenated by `:` try to split them first. |
31,175,158 | Example I have 10 textbox and each has the same attribute with different value, say for example they have an attribute `data-same` with different value and I have something like this in my code
`$('#test').each(function(){
$(this).val();
});`
and I want to filter the result using the attribute of each textbox. Ho... | 2015/07/02 | [
"https://Stackoverflow.com/questions/31175158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use [**attr()**](http://api.jquery.com/attr/)
```
$('#test').each(function(){
var attributeValue = $(this).attr('data-same');
//do whatever you want with the value
});
```
Also, your code indicates you have the same ID for multiple elements. Avoid that and use classes or attributes instead.
```
$('[data-s... | Ok If my assumption is correct you want to get all the `textbox` with same attribute then below code will work and I would suggest keep an unique `id`:
to each elements and you can try with `classname` instead say `class="test"`:
```
var sameTextBox=[];
$('.test').each(function(){ //change this selector to class
... |
39,500,556 | In this program after rolling a die "x" amount of times (userInput) I'm wanting to count the number of times each number occurs.
I tried making an else if that would add one to each random number occurrence but it only seems to work with the last random number, maybe it's because the if isn't in the while loop? I'm no... | 2016/09/14 | [
"https://Stackoverflow.com/questions/39500556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6832979/"
] | No need for jQuery, use a [`Array.forEach()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) like this:
```
var dates = [];
var clientCosts = [];
$.ajax({
url: 'inc/wip-data.php',
dataType: 'json'
}).done(function(data) {
data.forEach(function(item) {
dates.p... | My preference is to use lodash for operations involving arrays. The [lodash api has a function called map](https://lodash.com/docs/4.15.0#map) which meets your requirements nicely. Here is an example:
```
var jsonArray = [
{
"date": "2015-10",
"clientCostsTotal": "0.00"
},
{
"date": "2015-11",
"clientC... |
6,944,910 | Given the code:
```
uint Function(uint value)
{
return value * 0x123456D;
}
```
Inputting the value 0x300 yields the result 0x69D04700. This is only the lower 32 bits of the result.
Given the result 0x69D04700 and the factor 0x123456D, is it possible to retrieve all numbers such that (value \* 0x123456D) & 0xFFFFF... | 2011/08/04 | [
"https://Stackoverflow.com/questions/6944910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553294/"
] | What you need is modular division, which can be computed with a version of Euclid's algorithm. In this case the result is 768.
This is very fast -- time (log *n*)2 even for a naive implementation. (If you needed to work with large numbers I could give references to better algorithms.)
See [extended Euclidean algorith... | Your function:
```
uint Function(uint value)
{
return value * 0x123456D;
}
```
multiplies in `uint` (which works just like the integers modulo `2**64` in so-called `unchecked` context) by an *odd* number. Such an odd number has a unique inverse, modulo `2**64`. In this case it is `0xE2D68C65u`, because as you may ... |
16,825,305 | So I have a bunch of files like:
```
Aaron Lewis - Country Boy.cdg
Aaron Lewis - Country Boy.mp3
Adele - Rolling In The Deep.cdg
Adele - Rolling In The Deep.mp3
Adele - Set Fire To The Rain.cdg
Adele - Set Fire To The Rain.mp3
Band Perry - Better Dig Two.cdg
Band Perry - Better Dig Two.mp3
Band Perry - Pionee... | 2013/05/29 | [
"https://Stackoverflow.com/questions/16825305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2418049/"
] | To remove the leading white space char in the file names you provided you can use:
```
IFS=$'\n'
for f in $(find . -type f -name ' *')
do
mv $f ${f/\.\/ /\.\/}
done
```
This:
* changes the IFS to only be newline characters; this way it does not choke on the whitespaces in the file names.
* finds all files... | `cat <file> | sed -e 's/^[ ]*//'`
should do the trick. Capture stdout and write to a file. |
11,692,575 | I have an app working that is `GPS` based. It has many activities and all use the `GPS`. For example, one activity shows the distance to a location, another shows the speed and direction. I set up and call `requestLocationUpdates()` in `onCreate()` and call `removeUpdates()` in `onPause()`.
This all works but the `GPS... | 2012/07/27 | [
"https://Stackoverflow.com/questions/11692575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1510255/"
] | I've done something similar to your app, except that I've delegated the GPS functionality to a service which stops the GPS when no activities are bound to it and starts it when an activity binds to it. I bind to the service in the onStarts and unbind in the onStops. Logging the on.. methods when I switch activities giv... | First of all I'd suggest following good read about [location strategies](http://developer.android.com/guide/topics/location/strategies.html).
If you just want a one-time location fix you need to make it a bit more independent from the activity life cycle because acquiring the GPS location can take longer than the user... |
45,367,609 | I want to add the plugin in the maven project. I want it to be added to build only when I build the project for testing purpose.
I found that `<scope>` can be used for dependency as shown below
```
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback</artifactId>
<version>0.5</version>
<scope>t... | 2017/07/28 | [
"https://Stackoverflow.com/questions/45367609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4185515/"
] | **Swift 4.2 , XCode 10 , ios 12 , 2018 Answer**
```
self.children.forEach{$0.willMove(toParent: nil);$0.view.removeFromSuperview();$0.removeFromParent()}
```
Hope it is helpful to someone | ```
if self.childViewControllers.count > 0{
let viewControllers:[UIViewController] = self.childViewControllers
for viewContoller in viewControllers{
viewContoller.willMove(toParentViewController: nil)
viewContoller.view.removeFromSuperview()
viewContoller.removeFrom... |
3,649,662 | In my project i have used master page.In one particular page , i want a function to be executed on page unload(javascript event) event of that particular page.To achieve this i have written
```
$('body').bind('unload',function()
{
alert('hello');
} );
```
But this is not working.This function is not ... | 2010/09/06 | [
"https://Stackoverflow.com/questions/3649662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/340183/"
] | Well, I suppose its a problem when writing the question but your code should be:
```
$(window).bind('unload',function()
{
alert('hello');
});
```
You are missing the ending ); and the event should be bound to the window...
[Edit: Added the bind to the window instead of `'body'`] | ```
$(window).bind("unload", function(){
alert(123);
});
```
worked for me :) |
5,161,850 | I'm being forced to send data via GET (query string) to another server.
```
For example: http://myserver.com/blah?data=%7B%22date%22%3A%222011-03-01T23%3A46%3A43.707Z%22%2C%22str%22%3A%22test%20string%22%2C%22arr%22%3A%5B%22a%22%2C%22b%22%2C%22c%22%5D%7D
```
It's a JSON encoded string. However, anyone with half a b... | 2011/03/01 | [
"https://Stackoverflow.com/questions/5161850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/302064/"
] | HTTPS resolves it -- even the data in the HTTP header (including the URI) is protected, since the whole connection happens over an SSL channel.
There is one exception: the host name will be exposed if the client uses a proxy, since it is transmitted in the clear in the CONNECT request. | * HTTPS is indeed a solution for protecting your data.
It first creates a secure connection to the server (via TLS) using IP address and port.
-then all the HTTP packets are sent over this connection encrypted.
( [Is GET data also encrypted in HTTPS?](https://stackoverflow.com/questions/4143196/is-get-data-also-encrypt... |
53,862,521 | Suppose I have the following data frame:
```
0 1 2
new NaN NaN
new one one
a b c
NaN NaN NaN
```
How would I get the number of unique (non-NaN) values in a row, such as:
```
0 1 2 _num_unique_values
new NaN NaN 1
new one one 2
a b... | 2018/12/20 | [
"https://Stackoverflow.com/questions/53862521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Just use nunique(axis=1).
```
import numpy as np
import pandas as pd
data={0:['new','new','a',np.nan],
1:[np.nan,'one','b', np.nan],
2:[np.nan,np.nan,'c',np.nan]}
df = pd.DataFrame(data)
# print(df.nunique(axis=1))
df['num_unique'] = df.nunique(axis=1)
``` | A more abstract solution:
```
df['num_uniq']=df.nunique(axis=1)
``` |
51,359,783 | I am trying to convert JSON to CSV file, that I can use for further analysis. Issue with my structure is that I have quite some nested dict/lists when I convert my JSON file.
I tried to use pandas `json_normalize()`, but it only flattens first level.
```
import json
import pandas as pd
from pandas.io.json import json... | 2018/07/16 | [
"https://Stackoverflow.com/questions/51359783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3668922/"
] | I used the following function (details can be found [here](https://towardsdatascience.com/flattening-json-objects-in-python-f5343c794b10)):
```
def flatten_data(y):
out = {}
def flatten(x, name=''):
if type(x) is dict:
for a in x:
flatten(x[a], name + a + '_')
elif ... | In case anyone else finds themselves here and is looking for a solution better suited to subsequent programmatic treatment:
Flattening the lists creates the need to process the headings for list lengths etc. I wanted a solution where if there are 2 lists of e.g. 2 elements then there would be four rows generated yield... |
46,544,118 | ```
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
[request setHTTPBody:jsonData];
// configure NSURLSessionConfiguration with request timeout
NSURLSessionConfiguration *defaultConfigOb... | 2017/10/03 | [
"https://Stackoverflow.com/questions/46544118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4011722/"
] | The task never completes because it never gets started. You have to manually start the data task using its resume() method.
And Don't use the dataTask object inside the try block. | ```
if ([self checkNetworkStatus]) {
@try {
// Create the data and url
NSString *encryptedString = [self createRequest:userContext objectType:deviceObjectType projectType:projectId];
NSDictionary *dictRequest = @{REQ_KEY_REQUEST: encryptedString};
requestString... |
26,228,674 | I am writing a program that reads from multiple audio and video devices and writes the data to suitable containers (such as mpeg). I have wrote the code in Linux, but now I have to write another version for windows as well. This is how I wrote it in Linux:
```
initialize the devices (audio: ALSA, video: V4L2)
get the ... | 2014/10/07 | [
"https://Stackoverflow.com/questions/26228674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2308801/"
] | Roman is an expert in these topics and I don't think you'll find a better answer.
To add to Roman's answer, you would do something like this in DirectShow:
```
Enumerate video/audio capture devices/select capture device
Construct DirectShow graph
Add video and audio capture source filters to graph
Add 2 sample gra... | Windows offers several APIs for video and audio, which happens because older APIs were replaced with [supposed] descendants, however older APIs remained operational to maintain compatibility with existing applications.
Audio APIs: `waveInXxx` family of functions, DirectSound, DirectShow, WASAPI
Video APIs: Video for... |
13,529 | Suppose there is a doctor who wants a patient to cancel a planned abortion for the patient's safety. What should this doctor say?
Can an English speaker please help me to fix the following sentence so that it would sound more natural?
>
> Please don't abort the baby, **you have to bear the baby** for your own safet... | 2013/11/23 | [
"https://ell.stackexchange.com/questions/13529",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2436/"
] | Instead of "bear the baby", you can say "carry the baby to term". This means to carry the baby until it's ready to be born. Unlike your phrase, it doesn't describe the birth itself.
*Term* is short for *full term*. From [Collins](http://www.collinsdictionary.com/dictionary/english/term):
>
> **term**. *Also called:*... | As a doctor I would add the reason: For reasons of your own safety you should not think of abortion. |
39,937,971 | I am trying to call JavaScript `reset()` function by using button `onclick` method. The code is embedded in PHP as follows :
```
<?php
echo "<form>";
echo "<input type='text' name='keyword'>";
echo "<input type='button' value='Clear' onclick='<script>reset();</script>'>";
echo "</form>";
?>
```
The clear button ... | 2016/10/08 | [
"https://Stackoverflow.com/questions/39937971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3262077/"
] | ok i fixed it so the problem is that the parent fragmentstatepager loads fragmentA + fragmentB into memory, then the child fragmentstatepagers load there own childfragmentA + childfragmentB so we now have 2 parents and 4 children, onPrepareOptionsMenu is called from the child fragments so the the first is loaded childf... | Maybe, it'll still help someone struggling to make one SearchView work for multiple Fragments. I found that onQueryTextListener would work on Fragment 1 (where the SearchView is initially created) but would not fire on Fragment 2,3, etc.
Fragments 2 worked when onPrepareOptionsMenu is overridden and onViewCreated incl... |
2,879,711 | I want to be able to call a global function from an imported class, for example
In file PetStore.py
```
class AnimalSound(object):
def __init__(self):
if 'makenoise' in globals():
self.makenoise = globals()['makenoise']
else:
self.makenoise = lambda: 'meow'
def __str__(self):
... | 2010/05/21 | [
"https://Stackoverflow.com/questions/2879711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/126406/"
] | The `globals()` call returns the globals of the module in which the call is *lexically* located; there is no intrinsic "dynamic scoping" in Python -- it's lexically scoped, like just about every modern language.
The solid, proper way to obtain the effect you desire is to explicitly pass to the initializer of `AnimalSo... | "Global" scope in Python is Module scope.
```
import PetStore
PetStore.makenoise = makenoise
``` |
26,812,595 | I have the following piece of python code that I just can't get to work the way I want to. Here's the code:
```
l = [['#' for _ in range(10)] for _ in range(10)]
o = ['\n'.join(r) for r in l]
print ''.join(r for r in o)
```
Here's the current program output:
```
#
#
#
#
#
#
#
#
#
##
#
#
#
#
#
#
#
#
##
#
#
#
#
#
#
#... | 2014/11/08 | [
"https://Stackoverflow.com/questions/26812595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3500191/"
] | You simply join in the wrong order:
```
l = [['#' for _ in range(10)] for _ in range(10)]
o = [''.join(r) for r in l] # join the columns
print '\n'.join(r for r in o) # join the rows
```
Or more easy to read:
```
'\n'.join((''.join(r) for r in l))
```
Or without `l`:
```
(('#' * 10 + '\n') * 10)[:-1]
```
O... | try this:
```
for x in range(1,11):
print "#"*10
```
output:
```
##########
##########
##########
##########
##########
##########
##########
##########
##########
##########
```
explanation: if you multiply a string with a number, it will produce the number of repeating string
Demo:
```
>>> "a"*10
... |
64,374,423 | I have a table with the total number of secondary IDs per each principal ID. So I need to generate a second table in which each row correspond to the combination of primary ID and Secondary ID. For example if for primary ID1 I have 5 as the number of secondary ids I would need 5 rows, each with the same Primary ID and ... | 2020/10/15 | [
"https://Stackoverflow.com/questions/64374423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14456915/"
] | try this example :
html :
```
<div class="test" ng-controller="Ctrl">
<div ng-repeat="division in divisions | orderBy:['group','sub']">{{division.group}}-{{division.sub}}</div>
<div>
```
js :
```
var app = angular.module('app', []);
function Ctrl($scope) {
$scope.divisions = [{'group':1,'sub':1}, {'group':2,'... | alright what i did to solve this is that i moved the sort function to the front when i GET the data from the JSON repsonse.
```
$http({
method: 'Get',
url: "https://xxxxxxx.azurewebsites.net/api/team/" + id_company
})
.success(function (data) {
var n... |
38,993,071 | I'm trying to achieve something where the answer is already given for. But it's in `c#` and I don't have any knowledge what-so-ever over `c#` so I'm looking for a vb.net alternative.
I made a `class` called `BomItem` which has several properties like quantity, description etc.
I add these `BomItems` into a `List(of B... | 2016/08/17 | [
"https://Stackoverflow.com/questions/38993071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6071727/"
] | Use [LINQ](https://msdn.microsoft.com/de-de/library/bb763068.aspx) [OrderBy](https://msdn.microsoft.com/de-de/library/bb882684.aspx):
```
_NewBomList.OrderBy(Function(bi) bi.ItemNumber)
```
and for descending:
```
_NewBomList.OrderByDescending(Function(bi) bi.ItemNumber)
```
If you want a numeric order in your st... | This C# code from that other thread:
```
List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
```
equates to this VB code:
```
List(Of Order) SortedList = objListOrder.OrderBy(Function(o) o.OrderDate).ToList()
```
As you can see, very little changes. You just have to know the syntax for generic... |
30,915,008 | I have the following HTML input boxes:
```
<form>
<input type="text" name="1" id="1" disabled>
<input type="text" name="2" id="2" disabled>
<input type="text" name="3" id="3" disabled>
<input type="text" name="4" id="4" disabled>
<input type="submit" name="submit" value="submit>
</form>
```
Next I am trying to use j... | 2015/06/18 | [
"https://Stackoverflow.com/questions/30915008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4983280/"
] | The error is the selector, try:
```
$('input').prop('disabled', false);
``` | Try this:
```
$('input:text').prop('disabled', false);
```
Or
```
$('input[type=text]').prop('disabled', false);
``` |
62,474,393 | ```
$response = Http::withHeaders([
'Authorization' => 'Basic '. base64_encode(env('CLIENT_ID').':'.env('CLIENT_SECRET')),
'Content-Type' => 'application/x-www-form-urlencoded'
])->post('https://accounts.spotify.com/api/token', [
'code' => trim($code),
'redirect_u... | 2020/06/19 | [
"https://Stackoverflow.com/questions/62474393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13220584/"
] | Every time you construct a new instance of this class, you are overriding the field. Really a better name than `INSTANCE` would be `LAST_CREATED_INSTANCE`.
That said, given that the field is not declared [`volatile`](https://docs.oracle.com/javase/specs/jls/se11/html/jls-8.html#jls-8.3.1.4), a write to that field does... | One way to avoid leaking `this` in a constructor is with a static factory method. Also, as Michael has pointed out, `INSTANCE` should be volatile.
```
public class Foo {
private static volatile Foo INSTANCE;
private Foo() {
// ...
}
private static Foo create() {
// This should probab... |
743,024 | In Vim, one *searches* for newlines as `\n`, but newlines in the replacement-string must be entered as `\r`. I understand that there are [reasons for this behavior](https://stackoverflow.com/q/71417/1858225), but for my purposes I just find it irritating. I want to be able to use `\n` to mean (essentially) the same thi... | 2014/04/17 | [
"https://superuser.com/questions/743024",
"https://superuser.com",
"https://superuser.com/users/199803/"
] | You have to hook into the command-line; either when executing it via `<CR>`, or immediately when you enter a `\n`. With `:help c_CTRL-\_e`, you can evaluate a function and modify the command-line. Here's a demo that you can build upon and improve (the check for a substitution is simplistic right now):
```
cnoremap n <... | Alternate answer using a plugin (this is the solution I have decided to use, although it only works with Vim 7.4+):
Using [Enchanted Vim](https://github.com/coot/EnchantedVim), put `let g:VeryMagicSubstituteNormalise = 1` in your `.vimrc`.
(This plugin uses the [CRDispatcher](https://github.com/coot/CRDispatcher) plu... |
28,688,288 | I'm pretty new to C++ but I couldn't find a workaround for this online, I feel like there might be an interesting, elegant solution possible for this.
I'm ultimately trying to code a leapfrog algorithm for planetary motion. I've defined a class called planet
```
Planet(double mass, double x0, double x1, double v0, do... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28688288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309330/"
] | Why not try this
```
for(int i=0; i<4 ; ++i)
{
if( i != j )
cout << planets[i].getvx() << "\n";
}
```
This is the simplest method I could think of without trying anything complex. You just have to check whether `i` is equal to `j` inside the loop. If `i` is not equal to `j`, then give output.
If you don't w... | Use the keyword [continue](http://www.tutorialspoint.com/cplusplus/cpp_continue_statement.htm) inside for loop. It forces the next iteration of the loop
```
if(i==j) continue;
``` |
47,384,501 | I have a list like this:
```
[(0, 1), (0, 2), (0, 3), (1, 4), (1, 6), (1, 7), (1, 9)]
```
That I need to convert to a tuple that looks like this:
```
[(0, [1, 2, 3]), (1, [4, 6, 7, 9])]
```
This is the code I have:
```
friends = open(file_name).read().splitlines()
network = []
friends = [tuple(int(y) for y in x.... | 2017/11/20 | [
"https://Stackoverflow.com/questions/47384501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8968784/"
] | Use table-cell as display property
```
.footer-links,
.built-with {
display: table-cell;
max-width: 40%;
height: 100%;
border: 2px solid black;
}
```
I think , it'll horizontally aligned these boxes | this is based off of obsidian ages answer since it wasn't updated to match my exact question.
I edited `.footer-above` to 1400px since `width:100%` with code doesn't scale as viewport width changes.
Also, it should be `align-items: flex-start;` on `container` class, since i want a baseline at the top of parent div
`... |
6,566,318 | In javascript suppose you have this piece of code:
```
<div>
<script type="text/javascript">var output = 'abcdefg';</script>
</div>
```
Is there any way to simply "echo" (using PHP terminology) the contents of `output` into `#test`? That is, to output a string inline, assuming you have no standard way of travers... | 2011/07/04 | [
"https://Stackoverflow.com/questions/6566318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257878/"
] | "Kosher" code aside, yes.
`document.write()` | If your code is in the div, then `document.write('abcdefg')` is the proper choice for inserting something inline at the point of execution.
Or, if your code is not inside the div, you can do this:
```
<div id="test">
</div>
<script type="text/javascript">
var output = 'abcdefg';
document.getElementById("test").inner... |
30,404,587 | I have created a structure with a Id variable and a list of values. When I check the size before passing it to a function as a void\* it is 12. Once it gets in the function it is 4. How do I keep the size the same?
Struct Code:
```
typedef struct
{
int id;
std::list<int> sensorValues;
}dataPacketDef;
```
Se... | 2015/05/22 | [
"https://Stackoverflow.com/questions/30404587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/373445/"
] | The size of a pointer is 4 bytes (or 8 if you were using an x64 compiler). If `writeData` needs to know the size of the pointed-to object, that information will need to be passed to it somehow; a common idiom is to pass the size as a second argument. With that done, you could use a helper function template to simplify ... | sizeof(void\*) is 4 bytes on a 32bit machine. |
25,160,918 | I have come across such a code and my Java knowledge is not enough for it - I am pretty sure it is
something simple, but I have not found an explanation as don't know how to express it in google.
Here is the abstracted code, I hope nothing is missing:
```
public class A{
Car car;
.
.
.
public A... | 2014/08/06 | [
"https://Stackoverflow.com/questions/25160918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822768/"
] | 1. `return this;` - Being that, the return type is an `A` object, when the `.do()` method is called, the method will return `this`, `this` is the exact same instance that called it.
2. `public A doSomething(final A a)`, the only contract here is that an `A` object is returned. What happens in the code block doesn't mat... | Using `return this;` at the end of methods is a technique called [Method Chaining](http://en.wikipedia.org/wiki/Method_chaining) and can be a very convenient way of performing a chain of operations on an object.
`StringBuilder` is a good example:
```
String s = new StringBuilder().append("Hello").insert(0, "Goodb... |
137,721 | I am pulling up carpet and putting down a floating, vinyl plank floor in a three-season room built on slap. The tack strips are nailed into the concrete. I see [How to repair concrete damage from pulling up nail strips](https://diy.stackexchange.com/questions/111434/how-to-repair-concrete-damage-from-pulling-up-nail-st... | 2018/04/21 | [
"https://diy.stackexchange.com/questions/137721",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/20103/"
] | Jim and Taylor are correct.
Use a small pry par because it is not as thick and will get under the tack strip better. Hold the the long straight part or the pry bar and place the curved end so that the but is against the floor and the wedge part is up against the tack strip **directly in front of the nail**. Whack the ... | Prybar, hammer, elbow grease. There are many prybar styles, but this is the one I would choose.
[](https://i.stack.imgur.com/JG3Gt.jpg) |
8,370,757 | So, I have an array of unsigned chars, currently I'm trying to write a Set method (changes the bit in given index to 1). The best way I could think to do this was instead of creating a mask for the whole array, I would just create a mask the size of a byte and only mask the index spot in the array with the given bit th... | 2011/12/03 | [
"https://Stackoverflow.com/questions/8370757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079357/"
] | To preselect a value, just add the selected attribute to the desired option.
```
<select id="viewSelector" name="when" style="width:92%;">
<option value="USA">USA</option>
<option value="Australia" selected="selected">Australia</option>
<option value="Germany">Germany</option>
</select>
```
This will pre... | You need to add a `selected` attribute to the option you want to select, as described in the [spec](http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1).
```
<select id="viewSelector" name="when"">
<option value="USA">USA</option>
<option value="Australia" selected="selected">Australia</option>
<option... |
26,159 | I've kept diaries all my life and now have over 100...which I've recently started turning into an autobiography - where some of the original diary quotes are included along with the new text.
I belong to a local writers group, most of whom are well into their 70's & have led much more 'normal' lives than myself. Toda... | 2017/01/19 | [
"https://writers.stackexchange.com/questions/26159",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23089/"
] | There are two factors that sell an (auto)biography: fame and relevance.
(Auto)biographies by famous persons sell because everyone wants to know what their lives were (or are) like. We, the common people, want to know how rich, famous, or talented people live. The (auto)biography of a celebrity will sell, even if that ... | You might benefit from clarifying the difference between an autobiography and a memoir. There are many articles on these topics on the Internet. They might help you find an answer. Autobiographies tend to be chronological; memoirs focus on a theme, topic or event. What makes any story standout is getting the voice righ... |
779,946 | Find the greatest possible value of $5\cos x + 6\sin x$.
I attempted to solve this using graphing, however, the answer appears to be an ugly irrational. Is there a better method of solving this problem?
Thank you. | 2014/05/03 | [
"https://math.stackexchange.com/questions/779946",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/147474/"
] | A simple vector-based approach: you recognize in the expression the dot product $$(5, 6) \cdot (\cos x, \sin x).$$ This product is maximized when the two vectors are parallel and it is then the product of the moduli $$\sqrt{5^2+6^2} \cdot 1.$$ | Let $r^2=5^2+6^2=25+36=61$ and $\alpha = \arctan \frac 56$
You will find that $$5\cos x+6\sin x=r(\sin\alpha\cos x+\cos\alpha \sin x)=r \sin (x+\alpha)$$ |
61,283,484 | ```
| (true, Select(true)) => true
| (false, Select(false)) => false
```
How can I combine these two in a switch statement with generic type? | 2020/04/18 | [
"https://Stackoverflow.com/questions/61283484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11537438/"
] | Unfortunately the patterns that you match against in a switch statement have to be 'linear' (ie, the variants inside the patterns should only appear once):
See <https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora016.html>
>
> A pattern must necessarily be linear, that is, no given variable can occur more than ... | Yeah this is doable:
```
// using switch
let theSolution = x => switch(x) {
| (_, Select(inside)) => inside
};
// using `fun`
let theSolution = x => x |> fun | (_, Select(inside)) => inside;
// or for a super short solution:
let theSolution = fun | (_, Select(inside)) => inside;
```
For example:
```
type sele... |
1,017,396 | I am using Ubuntu 15.10 x64 and have skype 4.3.0.37.
It is a well-known issue that with this old version all pictures sent by the other party are received as links like this:
```
https://api.asm.skype.com/s/i?0-xxx-a3-somehashkeysecretnumberchars
```
That's OK, I used to use it.
Two days ago by some reason I enter... | 2015/12/23 | [
"https://superuser.com/questions/1017396",
"https://superuser.com",
"https://superuser.com/users/437717/"
] | Thanks to the information provided in the question itself, I was able to create a chrome extension to automatically redirect to a correct URL.
In Order to Run it
1. Put the two files(manifest.json and background.js) with source code in a folder.
2. Go to Chrome Extension Manager (chrome://extensions/) and Check "Deve... | Not a solution I'm afraid, but a clue to the right direction.
/msnp24 is possibly unrelated so you are looking for the wrong answer.
I also use Ubuntu 15.10 (Mate) and the last 24 hours or so both skype image links I have received have been blank like yours.
I have not entered then msnp24 command though.
To me this... |
2,182,459 | I have a string from which I have to remove following char: '\r', '\n', and '\t'.
I have tried three different ways of removing these char and benchmarked them so I can get the fastest solution.
Following are the methods and there execution time when I ran them 1000000 times:
It should be fastest solution if I have 1... | 2010/02/02 | [
"https://Stackoverflow.com/questions/2182459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150830/"
] | Even faster:
```
public static string RemoveMultipleWhiteSpaces(string s)
{
char[] sResultChars = new char[s.Length];
bool isWhiteSpace = false;
int sResultCharsIndex = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] == ' ')
{
if (!... | try this
```
string str = "something \tis \nbetter than nothing";
string removeChars = new String(new Char[]{'\n', '\t'});
string newStr = new string(str.ToCharArray().Where(c => !removeChars.Contains(c)).ToArray());
``` |
156,473 | I have a list with items and one of the column is a due date `{DueDate}`. I have a view, which displays items that are overdue (`{DueDate} <= [Today]`) that are assigned to a particular user `[Me]`. The `{DueDate}` column is calculated column - adding one year to another date from other column.
I have an alert which i... | 2015/09/09 | [
"https://sharepoint.stackexchange.com/questions/156473",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/4577/"
] | You can use a Workflow to wait till the DueDate then send an email.
The Workflow approach is the Normal method
OR be abnormal
You can watch the Today calculation in a VIEW,
[How to use Today and Me in Calculated column](https://sharepoint.stackexchange.com/questions/151144/how-to-use-today-and-me-in-calculated-co... | Firstly,the calculated column gets updated only when the item is updated.So,there are no chance for the item to get into your view without any modification. |
7,657 | I am looking for a cheap way to get +24V DC max 3A from computer power supply. I prefer easy soldering solution like DIP, and standard components that do not need to be purchased over internet. Any ideas, please? | 2010/12/08 | [
"https://electronics.stackexchange.com/questions/7657",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/1129/"
] | I have done this in the past using 2 supplies in series. The ground for the supply is the wall ground so to make it work I had to take one of the supplies apart and mount the board on nylon bolts to isolate it from the case. Then that supply floats and can be put in series. Not quite sure what happens around the curren... | <http://cdn.makezine.com/uploads/2014/04/da87333a_atx24-1bcq.jpg>
The blue wire is -12v, as @Yann Vernier said. Computer PSU, even the oldest one is a switching power supply, has no 7912 or anything like that, should handle 3 amps.
I had a PSU from old computer that has 29 amps on +12v rail and 19 amps on -12 v rail. |
6,177,734 | I read alot about this on this forum, but I cant make it work.
I want to use the ajax function on my asp.net web application
So here is the Javascript on VerifMain.aspx
```
$(document).ready(function () {
//menu()
$("#btnImprimer").click(function () {
$.ajax({
type: "POST",
url: "/VerifMain.... | 2011/05/30 | [
"https://Stackoverflow.com/questions/6177734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/776438/"
] | Try to call this method instead just to test it once more:
```
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Shared Function GetDate() As String
Return Date.Now.ToString()
End Function
```
Replace URL with this:
```
url: "/VerifMain.aspx/GetDate",
``` | ASP.NET AJAX modified the JSON returned in 3.5. You need to access the `d` property, see <http://encosia.com/never-worry-about-asp-net-ajaxs-d-again>. I don't know what you're error is, but you'll see it if you changed the code to what's below:
```
$(document).ready(function () {
//menu()
$("#btnImprimer").click(func... |
28,925,447 | ```
import logging
import graypy
my_logger = logging.getLogger('test_logger')
my_logger.setLevel(logging.DEBUG)
handler = graypy.GELFHandler('my_graylog_server', 12201)
my_logger.addHandler(handler)
my_adapter = logging.LoggerAdapter(logging.getLogger('test_logger'),
{ 'username': ... | 2015/03/08 | [
"https://Stackoverflow.com/questions/28925447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391936/"
] | Open your Graylog Webapp, click 'System'. You will see a list of links on the right. On of them is 'Input', click this one.
Now you have an overview of all running inputs, listening on different ports. On top of the page you can create a new one. There should be a drop box containing certain modes for the input listene... | I think you've setup your input stream For Gelf TCP instead of UDP. I set up a TCP Stream and it got the curl message. However my python application wouldn't send to the stream. I then created a Gelf UDP stream and voila! I ran into this same issue configuring my Graylog EC2 Appliance just a few moments ago.
Also mak... |
51,040,710 | Assuming you must use a Windows batch file, *(not `powershell`)*, and one wants to delete all files ending in `.zip` that are in the current active directory. How to do this?
All attempts so far are failing:
```
forfiles -p "C:\temp\test" -s -m *.zip -d 1 -c "cmd /c del *.zip"
```
For this it says
>
>
> ```
> ER... | 2018/06/26 | [
"https://Stackoverflow.com/questions/51040710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/211425/"
] | As suggested in my comment, your problem could easily be solved by reading the usage information for your command, *(available when entering `FORFILES /?` at the Command Prompt)*.
Based on your questions criteria, "`delete all files ending in .zip` that are in `the current active directory`":
You don't need to use th... | You did not mention anything about subdirectories or windows version so I'm assuming somewhat. You have an old version syntax. In Windows 7 and further the syntax changed a little bit.
For windows 7:
```
forfiles /P "C:\temp\test" /S /M *.zip /D -1 /C "cmd /c del @path"
``` |
28,825,157 | I am trying to store a jQuery datepicker value into a php date formatted variable.
The desired outcome: Example
input field name "reviewdate" = 03/02/2015
input field name "reviewmonth" = 3
Both values will be submitted to a mysql database. I am able to store "reviewdate", but "reviewmonth" remains "null" after th... | 2015/03/03 | [
"https://Stackoverflow.com/questions/28825157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4225742/"
] | In order for [`date_format`](http://php.net/manual/en/datetime.format.php) to work, you need to initialize a `DateTime` object first:
```
<?php
$month = '';
if(isset($_GET["reviewdate"])) {
$date = new DateTime($_GET["reviewdate"]); // or $date = date_create($_GET["reviewdate"]); will work the same
$month = ... | you have to replace this
```
<script>
$( "#datepicker" ).datepicker({
inline: true
});
</script>
```
with
```
<script>
$( "#datepicker" ).datepicker({
inline: true,
dateFormat: 'Y-m-d'
});
</script>
``` |
1,333,524 | We have to prove that $$\frac{(x\_1+x\_2+x\_3+...+x\_n)}{n} \geq (x\_1\cdot x\_2\cdot x\_3\cdots x\_n)^{1/n}$$
**Attempt:** Raising both sides to the nth power gives $\left(\frac{x\_1+x\_2+x\_3+...x\_n}{n}\right)^{n} \geq x\_1x\_2x\_3...x\_n$
This is equivalent to proving that if a sum of random numbers is a fixed num... | 2015/06/21 | [
"https://math.stackexchange.com/questions/1333524",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/249641/"
] | That's pretty good.
One aspect I'd want to fiddle with is the existence of the maximizer. You argued that it's bounded (which as a commenter noted could be made more explicit) and so a maximizer exists; this requires some kind of compactness argument, and the continuity of $\mathbb R^n\to\mathbb R$, $(x\_1,\dotsc,x\_n... | **Hint:** Your idea is correct. Here is a north to let things rigorous.
Consider $f, \psi : U \to \mathbb R$ defined as $$ f(x) = x\_1 \cdot x\_2 \cdots x\_n \,\,\, \text{and} \,\,\, \psi (x) = x\_1 + x\_2 + \ldots + x\_n$$
for all $x = (x\_1, x\_2, \ldots , x\_n) \in U$. Fix $s > 0$ and search for the critical point... |
37,431,844 | I am working with a `IReadOnlyCollection` of objects.
Now I'm a bit surprised, because I can use `linq` extension method `ElementAt()`. But I don't have access to `IndexOf()`.
This to me looks a bit illogical: I can get the element at a given position, but I cannot get the position of that very same element.
Is ther... | 2016/05/25 | [
"https://Stackoverflow.com/questions/37431844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1302653/"
] | `IReadOnlyCollection` is a collection, not a list, so strictly speaking, it should not even have `ElementAt()`. This method is defined in `IEnumerable` as a convenience, and `IReadOnlyCollection` has it because it inherits it from `IEnumerable`. If you look at the source code, it checks whether the `IEnumerable` is in ... | This extension method is almost the same as Mike's. The only difference is that it includes a predicate, so you can use it like this: `var index = list.IndexOf(obj => obj.Id == id)`
```
public static int IndexOf<T>(this IReadOnlyList<T> self, Func<T, bool> predicate)
{
for (int i = 0; i < self.Count; i++)
{
... |
160,886 | I have a MacBook Pro which has Leopard Mac OS X 10.5.8 and i want to upgrade this to Snow Leopard 10.6.2. Is it possible? If yes then give me some guidelines. | 2010/07/07 | [
"https://superuser.com/questions/160886",
"https://superuser.com",
"https://superuser.com/users/42125/"
] | This really isn't the right forum for a question of this sort our sister site superuser.com would be. That said this is very easy; just buy 10.6 from Apple, backup your system, boot from the disk, follow the installation instructions then update your system once it's installed - it's that easy. | According to Apple here are the required specs.
* Mac computer with an Intel processor
* 1GB of memory
* 5GB of available disk space DVD drive for installation
* QuickTime H.264 hardware acceleration requires a Mac with an NVIDIA GeForce 9400M, GeForce 320M, or GeForce GT 330M graphics processor.
* Developer tools req... |
2,556,344 | I'm using quartz to display pdf content, and I need to create a table of contents to navigate through the pdf. From reading Apple's documentation I think I am supposed to use CGPDFDocumentGetCatalog, but I can't find any examples on how to use this anywhere. Any ideas?
**Update:** Still haven't found a solution for th... | 2010/03/31 | [
"https://Stackoverflow.com/questions/2556344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/306372/"
] | Something like this might help you get started:
```
NSURL *documentURL = ...; // URL to file or http resource etc.
CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)documentURL);
CGPDFDictionaryRef pdfDocDictionary = CGPDFDocumentGetCatalog(pdfDocument);
// loop through dictionary...
CGPDFDictionaryA... | Here is my approach.
1. Download this framework [**`vfr reader`**](https://github.com/vfr/Reader)
2. Use this lines of code to get all PDF chapters
```
NSString *path = [[NSBundle mainBundle] pathForResource:@"Reader" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSArray *arr = [ReaderDocumentOutl... |
68,485,907 | var ToDateTime = formatDate(DateTime.now(), [dd, '/', mm, '/', yyyy, ' ', HH, ':', nn, am]); | 2021/07/22 | [
"https://Stackoverflow.com/questions/68485907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16206561/"
] | The `in` operator looks for substrings. In your case, you want `==` to compare the whole string.
Instead of:
```
if 'task' in elem
```
Use:
```
if 'task' == elem
``` | The problem is that you named your list, list. List is a built-in keyword in Python, and you are confusing Python.
Change the list name to something like `my_list` and change `if elem == 'task'`
* Carden |
15,654 | We've more or less asserted why the [Hogwart's express exists](https://scifi.stackexchange.com/a/10288/3804), but at some point in Hogwarts history it didn't. No problem I though, everyone just apparated with their children to Hogsmeade, no problem a long and tedious process considering luggage, and number of children.... | 2012/04/29 | [
"https://scifi.stackexchange.com/questions/15654",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/3804/"
] | I'm not totally sure, but I somehow remember reading from somewhere that they used portkeys. Even if I'm talking rubbish, it still seems like the most logical answer, as you could transport quite many children at the same time and you could do it quickly. | Before the Hogwarts Express, everyone used Portkeys:
>
> Portkeys were therefore arranged at collecting points all over
> Britain.
>
>
>
For Muggle-borns, a teacher would explain how it worked.
Source: [Hogwarts Express](https://www.pottermore.com/writing-by-jk-rowling/the-hogwarts-express) |
6,522,042 | I have two tables, the 1st:
```
users(id,name, birth_date)
skills(user_id,skill_name,skill_level)
```
I want to select all users with 3 some skills on level 2.
its possible make this in one query ?
example:
```
user has
3,marcus,19/03/1989
4,anderson,08/02/1990
skills has
3,php,2
3,html,1
4,php,1
```
what i wa... | 2011/06/29 | [
"https://Stackoverflow.com/questions/6522042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/821223/"
] | ```
select *
from users u join skills s on u.id=s.user_id
where skill_level=2
group by id
having count(*)>2
``` | Okay. Now that you've updated your question a bit more, the answer becomes "yes, it can be done, but you shouldn't necessarily do it like that".
Firstly, just to show that it can be done:
```
SELECT u.* FROM users u
INNER JOIN skills s1 ON (u.id = s1.user_id AND s1.skill_name = 'php')
INNER JOIN skills s2 ON (u.id ... |
2,364,612 | Is it possible to pass a chunk of html content to a hidden field and how would I do this?
Thanks
Jonathan | 2010/03/02 | [
"https://Stackoverflow.com/questions/2364612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/100238/"
] | You could do this with Javascript:
```
<input type="hidden" id="htmlCodes" />
```
```
document.getElementById("htmlCodes").value = "<strong>Hello World</strong>";
```
Just be sure that your values are properly-escaped when you pass them into the hidden form field.
Online Demo: <http://jsbin.com/ubofu/edit> | You can also "spawn" a hidden textarea after processing the content inside.
This can be done easily with Jquery :
```
$('#your_form')
.append('<textarea name="content" class="hidden">' + your_content + '</textarea>');
```
Here we assuming that you've got a "hidden" class, Bootstrap's got one, but you can also use t... |
26,911,892 | In Ubuntu, I have this line present in `/etc/resolv.conf`:
```
search example.com uk.example.com se.example.com
```
Now when I type `host svr1.uk` I get the record for svr1.uk.example.com
If I `ping svr1.uk`, I see pings from svr1.uk.example.com.
However, If I try to `ping svr1.uk` on a mac with the same `sear... | 2014/11/13 | [
"https://Stackoverflow.com/questions/26911892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4248705/"
] | This doesn't work for El Capitan anymore. If you upgrade to El Capitan you need to do this:
1. `defaults write /Library/Preferences/com.apple.mDNSResponder.plist AlwaysAppendSearchDomains -bool true`
2. Reboot
See the mDNSResponder man page for more details. | **On OS X 10.7-8**
Look for these lines (Around line 16; 10.8 starts around line 17), and add the third line on the end, then save the file
```
<string>/usr/sbin/mDNSResponder</string>
<string>-launchd</string>
<string>-AlwaysAppendSearchDomains</string>
```
**On OS X 10.9**
This is still around line 17 and will n... |
25,441,723 | I'm just working with `HashMaps` and now it pops up a question I actually can't answer by myself...
In my HashMap there are some entries. I'm now searching through all the entries for a certain value. If that value is found It delete it using `hashmap.remove();`. But I don't "only" want to delete the entry but the who... | 2014/08/22 | [
"https://Stackoverflow.com/questions/25441723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3951790/"
] | Understanding how `HashMap` works here [Link](http://javarevisited.blogspot.com/2011/02/how-hashmap-works-in-java.html).
Also see java doc here [link](http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html).
If you want to set pack your hashmap try to check size of the map then delete one then check size agai... | OK I got a codeable example that's pretty easy.
```
public class TestingThingsOut {
public static void main(String [] args) {
HashMap<Integer, String> myMap = new HashMap<Integer, String>();
myMap.put(123, "hello");
myMap.put(234, "Bye");
myMap.put(789, "asdf");
System.out.println(myMap); // it ... |
65,557,038 | I am building a login page using Kivy and it always says that I have a name error and password is not defined. I found some tutorials but they look the same as mine so I cant figure out the problem. Hope someone can help.Thank you
Here is my code:
```
FloatLayout:
TextInput:
id: "password"
name: "... | 2021/01/04 | [
"https://Stackoverflow.com/questions/65557038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14761890/"
] | As mentioned in the other answers, the issue is that you're changing an existing object every iteration instead of adding a new one.
I'd like to add that that you can also use `reduce` instead (I personally prefer the syntax and it's a bit shorter):
```js
let nums = [{id:1, first_name: "sade", last_name: "Smith"}, {i... | That's because you keep pushing the same object to the `em` array in each iteration in the `forEach` loop.
A simple approach would be to do this:
```
const nums = [{id:1, first_name: "sade", last_name: "Smith"}, {id:2, first_name: "Jon", last_name: "Doe"}];
const em = [];
nums.forEach(e => {
em.push({id: e.id, nam... |
47,022,131 | I have a vendor and customer in login, It works fine and redirects to the vendor or customer dashboard but how can I do the same after registration?
**Register Controller**
```
protected $redirectTo = '/';
```
**Login Controller**
```
<?php
public function login(Request $request)
{
$this->validate($request, [... | 2017/10/30 | [
"https://Stackoverflow.com/questions/47022131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Not sure which version you are using I'm posting my answer for Laravel 5.7+
After registration Laravel call this method:
```
// Auth\RegisterController
/**
* The user has been registered.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function registered(Reque... | Overwrite the authenticated method in LoginController
```
protected function authenticated(Request $request, $user)
{
//write your logic's here
if ($user->role_id == 1) {
return redirect()->route('write the route name');
}
return redirect('/home');
}
``` |
41,935,581 | I'm trying to remove the empty element from the array by copying the existing element to a new array. However, initialization of the new array is causing my return value to be null even when I initialize it within the `for` loop.
```
public String[] wordsWithout(String[] words, String target) {
for(int i = 0; i < ... | 2017/01/30 | [
"https://Stackoverflow.com/questions/41935581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6865102/"
] | To check the equality use .equals() method i-e string1.equals(string2) and to check non-equality you can use the same method but with not(!) operator i-e. !string1.equals(string2). You should declare the store array outside the loop because in each iteration it makes a new object onamed store. In the else condition do ... | You shouldn't compare strings using `==` operator. This is incorrect, because strings are objects. Use `.equals()` method instead, this should fix your problem.
Rest part of your code is quite confusing, it's hard to understand what you are trying to achieve: you create new string array `store` each time in loop itera... |
3,855,218 | I'm trying to get the real size of an image displayed in an image view. Actually my image is larger than the screen and the imageview is resizing the image to diplay it. I'm looking for this new size.
I've tried to override the onDraw method of the ImageView in a custom view but I'm not getting the correct height and ... | 2010/10/04 | [
"https://Stackoverflow.com/questions/3855218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/465803/"
] | I'm just passing by but hope it still helps
I'm going under the assumption your talking about bitmaps in your imageView
what you want to understand is the difference between
`bmpBack.getWidth()`
-> this gives you the size of your bitmap
and
`bmpBack.getScaledWidth(canvas)`;
-> this will give you the size of the bitma... | If I get you correctly you need your ImageView dimension, in order to scale your image accordingly. I did this with a custom class, where I override the `onMeasure()` call to get width and height.
```
class LandImageView extends ImageView{
public LandImageView (Context context, AttributeSet attrs) {
super (context... |
33,352,930 | I'm using JQ <https://stedolan.github.io/jq/> to work in bash with my json and when I read the json is throwing me an error
```
parse error: Invalid numeric literal at line 2, column 5=
```
Since my json has some comments
```
// comment
"spawn": {}
```
I've been seen looking the options and I cannot find ... | 2015/10/26 | [
"https://Stackoverflow.com/questions/33352930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/854207/"
] | JSON and thus jq do not support comments (in the usual sense) in JSON input. The jq FAQ lists a number of tools that can be used to remove comments, including jsonlint, json5, and any-json. I'd recommend one that can act as a filter.
See <https://github.com/stedolan/jq/wiki/FAQ#processing-not-quite-valid-json> for lin... | Remove them; JSON does not support comments.
(JSON is defined [here](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf); you can see a briefer description of the grammar [here](http://json.org).) |
16,268,868 | I am using a function "loadScript" to insert an external .js if the browser detects it is online.
```
<script type="text/javascript">
function loadScript()
{
if (navigator.onLine == true)
{
var src = "js/getdata.js";
var script = document.createElement("script");
script.type = "text/ja... | 2013/04/28 | [
"https://Stackoverflow.com/questions/16268868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1150866/"
] | If you want the script to be generated by PHP, you need to put it in a PHP file. Rename the file to `js/getdata.js.php` and update the `src` accordingly.
Another option would be to configure the web server to parse all `.js` files as PHP, but it's unlikely you actually want to do that. | The problem is solved. Thanks to Mark Parnell and W3Geek who gave me the script.js.php extension clue. The element to load the script should not be a function.
Details: It now runs as a script in the head, loads the function if it is online, then waits for window.onload before trying to call the new function.
So now,... |
26,531,065 | I have a method that takes an array as a parameter and returns a boolean.
Inside the method, I have an if/else statement. If the statement is true, I want the result to return true, if the statement is false, I want the statement to returns false.
```
public static boolean allPositive (double[] arr)
{
for (int i ... | 2014/10/23 | [
"https://Stackoverflow.com/questions/26531065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4168379/"
] | ```
public static boolean allPositive (double[] arr)
{
boolean b = true;
for (int i = 0; i < arr.length; i++)
{
if(!(arr[i] > 0))
{
b = false;
}
}
return b;
}
```
The way Java works, it ensures no problems with your code by making sure all your returns happen... | You have to return in the end of the method (after the loop) the value that should be returned if an empty array is passed to your method. It's up to you to decide whether an empty array is "allPositive" or not. |
61,693,429 | I am trying to transform the array using `.reduce` function into an object of type:
```
{
"date": xxxx,
"amount": xxxx,
}
```
Insted of:
```
{01-2018: 0, 09-2019: 0, 02-2020: 0, 03-2020: 142.95999999999998, 04-2020: 652.78, …}
```
I would like to obtain a json like this one:
```
{
"date": 01-2018,
"amount": 0,
}... | 2020/05/09 | [
"https://Stackoverflow.com/questions/61693429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12380654/"
] | ```
let aggregatedMonthlyData = monthlyData.reduce((acc, item) => ({
...acc,
[item.yearMonth]: (acc[item.yearMonth] || 0) + Number(item.CantidadGanadaNETO)
}), {}
);
const formatAggregatedMonthlyData = function(aggregatedMonthlyData) {
const dateFieldName = 'date';
const amountFieldName = 'amount';... | Assuming your input value is like below
```
const input = {"01-2018": 0, "09-2019": 0, "02-2020": 0, "03-2020":
142.95999999999998, ..}
```
Below solution will work
```
const transformData = input =>
JSON.stringify(Object.entries(input).reduce((acc, [date, amount]) => [...acc, { date, amount }], []))
const out... |
2,357,091 | A simple situation here,
If I got three threads, and one for window application, and I want them to quit
when the window application is closed, so is it thread-safe if I use one global variable,
so that three threads will quit if only the global variable is true, otherwise continue its work?
Does the volatile help in ... | 2010/03/01 | [
"https://Stackoverflow.com/questions/2357091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/283734/"
] | If you only want to "read" from the shared variable from the other threads, then it's ok in the situation you describe.
Yes the *volatile* hint is required or the compiler might "optimize out" the variable.
Waiting for the threads to finish (i.e. `join`) would be good too: this way, any clean-up (by the application) ... | It's safe right up to the point that you change the variable's value to get the threads to quit. At that point 1) you need to synchronize access, and 2) you need to do something (sorry, volatile isn't enough) to assure that the new value gets propagated to the other threads correctly.
The former part is pretty easy. T... |
104,017 | On a clear day is it possible to see the Isles of Scilly from Cornwall with the aid of binoculars? A distance of around 40km.
I know on a very clear day you can only see maximum 20km from sea level but the coast of Cornwall is higher than sea level. So does the height advantage of the cliffs enable you to see further... | 2017/10/20 | [
"https://travel.stackexchange.com/questions/104017",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/19694/"
] | I saw the islands from near St Just last week, a distance of almost 30 miles. Very faint, but definitely visible. I had no trouble with binoculars separating the islands and the hill on Samson. | Based on [Mark Mayos](https://travel.stackexchange.com/users/101/mark-mayo) excellent answer to this [question](https://travel.stackexchange.com/questions/3666/can-i-see-lebanon-from-cyprus) and calculating the height 80 metres close to the Cornwall coast line you can only see a maximum of 32km with the naked eye.
Thi... |
61,055,324 | I can't run any binary in my docker container.
Dockerfile:
```
FROM ubuntu:eoan AS compiler-build
RUN apt-get update && \
dpkg --add-architecture i386 && \
apt-get install -y gcc \
gcc-multilib \
make \
cmake \
git \
... | 2020/04/06 | [
"https://Stackoverflow.com/questions/61055324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/309240/"
] | From [this forum thread](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2109):
>
> This error occurs when you use a shell in your entrypoint without the "-c" argument
>
>
>
So, if you change your `Dockerfile` to end with
```
ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
```
then you can run binary files.
Note ... | I hit the same error. Unlike the other answers, my error was related to my `docker run` parameters:
```
# failed
docker run -it $(pwd | xargs basename):latest bash
# worked
docker run -it $(pwd | xargs basename):latest
```
I didn't need to add `bash` as I already had this in my Dockerfile:
```
ENTRYPOINT ["/bin/ba... |
38,358,953 | I am trying to find the field name "User Settings Updated Successfully" from the following code:
```
<div id="btn-usersettings" class="tab-content clearfix">
<h4>Set your User Settings in This Section</h4>
<div class="notice success">
<i class="icon-ok icon-large"/>
User Settings Updated Successfully
<a href="#close" ... | 2016/07/13 | [
"https://Stackoverflow.com/questions/38358953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When you open the menu, you should listen for clicks on document. Then when the document is clicked you close the popup (and you remove the listener on the document as well).
PS: keep your listener on the menu-container as well ;)
Here is an example you can use (I edited your fiddle) :
```js
(function(){
//Remembe... | Thanks to [finding-closest-element-without-jquery](https://stackoverflow.com/questions/18663941/finding-closest-element-without-jquery) my solution is based on:
* window.onload: try to insert always your code in such handler to be sure all the elements are already loaded and so ready for your code
* to test if an elem... |
14,727,407 | I am new to android. I want to display buttons on the screen at particular x and y position.
I have an one Relative layout and i put background image to that relative layout now i want to create or draw buttons on that image at particular x and y position and that X and Y position are given by me through XML i have 5 X... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14727407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996794/"
] | Is your `web config` pointing to the correct database?
Are the credentials correct?
Entity Framework will create tables in the database if you are going to use the `MVC4 WebSecutiy()` to handle the Authentication and Authorisation of users. This could be throwing the exception.
In this case where you cannot create... | I encountered a similar error after refactoring and renaming some code. The issue was that my C# code didn't match table name in the Database.
My code in c#:
```
public virtual DbSet<MyTableName>
```
And the table name in SQL Server:
```
MyActualTableName
```
Since the table names didn't match (MyTableName != My... |
10,085,132 | Is there any way to simply declare static `NSString` as defined int identifier ? I want to do something like in C++ `#define MY_SIMPLE_ID 4`.
EDIT:
Where should I declare this? In C++ I have global access to resource file with it. Is there a way to do that in Objective-C? | 2012/04/10 | [
"https://Stackoverflow.com/questions/10085132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1317394/"
] | Why not using :
```
#define MY_STRING @"MyString"
``` | You can also go into your Project or Target **Build Settings**, and add to **Preprocessor Macros** or **Preprocessor Macros Not Used In Precompiled Headers**. See [Xcode Preprocessor Macros](https://stackoverflow.com/a/245288/1318452) for the distinction between these two options. |
9,795,693 | I am learning c programming in Linux. There are a lot of linux functions I need to look at. Is there a website that gives me the details of the Linux functions? | 2012/03/20 | [
"https://Stackoverflow.com/questions/9795693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1250904/"
] | Are you referring to system calls in Linux? There are lots of sources. The man pages are your good friends in this regard. Try also <http://linux.die.net/man/2/syscalls>. I am sure there are lots of others. | IMHO <http://linux.die.net/man/> is the easiest to get to start with.
It has useful sections introductions, so you can get your bearings
Most usefully are the one line synopsis pages, e.g. <http://linux.die.net/man/3/>
This shows the scale of what you are asking, and also lets you search for a key word describing e... |
1,476,107 | I am wondering how to notate "for all positive real value $c$"
Is there a correct notation among the following?
$$
\forall c \in \mathbb{R} > 0\\
\forall c \left( \in \mathbb{R} \right) > 0\\
\forall c > 0 \in \mathbb{R}\\
\forall c > 0 \left( \in \mathbb{R} \right)\\
$$
My ultimate goal is notating the following sen... | 2015/10/12 | [
"https://math.stackexchange.com/questions/1476107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/250170/"
] | I see someone has already explained why not the options you listed. Alternative options, summing up comments :
1. $\forall c\in\mathbb R^+\_0\text\ \{0\}$
2. $\forall c\in\mathbb R,c>0$
3. $\forall c\in (0,\infty)$
From comments:
4. $\forall c\in\mathbb R\_{>0}$
(similar:[this question](https://math.stackexchange.c... | Another commonly used self-explanatory notation is $\mathbb{R}\_{> c}$. Anything beyond half-line ranges would need some interval notation like $(a,b)$ or $]a,b[$. |
3,300,708 | I'm getting a strange error. I have a function of the following signature:
```
template <typename DATA, DATA max>
static bool ConvertCbYCrYToRGB(const Characteristic space, const DATA *input, DATA *output, const int pixels) {
```
Which is later called like this:
```
case kByte:
return ConvertCbYCrYToRGB<U8, 0x... | 2010/07/21 | [
"https://Stackoverflow.com/questions/3300708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/398098/"
] | As aaa pointed out, you can't use floating point numbers as template value parameters. But in this instance you don't need to. Get rid of the second parameter entirely, and then in the definition of ConvertCbYCrYToRGB instead of using 'max' use `std::numeric_limits<DATA>::max()`. Documentation on numeric\_limits is her... | you can not use floating point numbers at template value parameters.
Template value parameters must be integral types, ICE to be exact: <http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/template_non-type_arguments.htm> |
14,357,196 | I want to know if we can host Drupal application on AppHarbor ?
Thanks | 2013/01/16 | [
"https://Stackoverflow.com/questions/14357196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1138133/"
] | this may help you
```
DataGridViewImageColumn delCol = new DataGridViewImageColumn();//create image column
delCol.ImageLayout = DataGridViewImageCellLayout.Zoom;//column properties
int icIndex = DGV_showTable.Columns.Add(delCol);//add column to DGV
DGV_showTable.Columns... | You have to change `img.ValuesAreIcons` from `true` to `false` on the second code that you wrote it.
It will works, it happened to me when I used your code to fix this problem. |
34,487,470 | I have a list of an Object and I want to detect whether Object Id is duplicate or not.
Here is the object:
```
public class data{
private String id;
private String value;
private String status;
}
```
All duplicate `data` will have "invalid" `status` except the first one.
What is the most effective way for this? | 2015/12/28 | [
"https://Stackoverflow.com/questions/34487470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4101051/"
] | Try like this first you should override `equals` method to check duplicates
```
private class data{
private String id;
private String value;
private String status;
public data(String id, String value, String status) {
this.id = id;
this.value = value;
... | Make a list of the `id` of objects. Loop over the list of objects. See if the `id` of each object is already in the list. If the `id` is already present, then change the `status` of the object. Otherwise, add the `id` of the object to the list. |
33,677,920 | I am trying to cast a sfixed (from ieee.fixed\_pkg) to std\_logic\_vector and I wonder what the correct syntax is and why the following is (appearently wrong). I tried compiling the following 3 architectures:
```
library ieee;
use ieee.std_logic_1164.all;
use ieee.fixed_pkg.all;
entity test is
port (input... | 2015/11/12 | [
"https://Stackoverflow.com/questions/33677920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3938428/"
] | Funnily enough, this might actually be a grey area in the specification of the VHDL language itself. The same problematic conversion has been [discussed as a possible "bug"](https://sourceforge.net/p/ghdl-updates/tickets/102/) against the open-source simulator, [ghdl.](https://sourceforge.net/projects/ghdl-updates/)
T... | The fixed package conversion function is not the solution to the OP's reported error, see posting of the function to convert to std\_ulogic\_vector below. Note that 'result' is a std\_ulogic\_vector and is obtained by performing a type cast of the operand 'arg', exactly the same as the OP did (except OP used std\_logic... |
57,181,002 | I'm working on an input mask for a little software tool. Therefore I have different possibilities to allow the user to give his input (input types). Also I have a select field for choosing an answer out of a given sort order. These answers are read from a table of my database. It is dynamic.
After the user selected a... | 2019/07/24 | [
"https://Stackoverflow.com/questions/57181002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11801841/"
] | You can use `$casts` property (<https://laravel.com/docs/5.8/eloquent-mutators#array-and-json-casting>):
```
class User extends Model
{
protected $casts = [
'user_preferences' => 'array',
];
}
```
By doing this, Laravel will automatically serialize array to JSON and vice versa. | I think the easiest solution is to store your value in [JSON](https://www.json.org/json-en.html).
There is a php function that allows you to encode and decode objects and arrays to JSON, namely [json\_encode](https://www.php.net/manual/de/function.json-encode.php) and [json\_decode](https://www.php.net/manual/de/functi... |
2,351,425 | I want to merge to very diverged Git branches together. That will be a lot of work because they have several hundreds conflicts.
What would be the best way, so that maybe also others can help me and also work on this merge?
Normally, I am doing just the 'git merge ...' and then going through all conflicts, resolving ... | 2010/02/28 | [
"https://Stackoverflow.com/questions/2351425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133374/"
] | Chances are, you do not have a formal data source, such as a back-end database. For situations like this, use the .NET [application settings architecture](http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx) to save and restore application settings between runs. | public partial class Form1
{
public string defaultValue;
```
private void form2Open_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
if (defaultValue != null)
f.textBox1.Text = defaultValue;
f.mainForm = this;
f.Show();
}
```
}
public partial class Form2
{
public Form1 mainForm;
... |
45,432,120 | Initially I had various **XSD** definition for each **XSD** I had set of XML files stored.
After some time duration there are some changes in **XSD** definition so my stored XML is no more validation again new **XSD**.
For support I need to write **XSLT** and do changes in my stored XML to validate again new **XSD**.... | 2017/08/01 | [
"https://Stackoverflow.com/questions/45432120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8391924/"
] | It looks like `Class1` is not the only class that has a `static void Main()` method defined. Usually, when you create a console application, there's a class called "Program" that already contains a method `Main`. There should be no need to add another class.
Just modify the existing `Main` method. This should solve th... | The first error is caused by a typo. To correct it, change `Writeline` to `WriteLine` (with a capital letter L).
The second error is caused by the fact that you did not specify clearly which entry point the program should use. To fix this, follow these steps:
Right-click on your project in **Solution Explorer**, and ... |
3,127,088 | I am querying a firebird database with a relatively complicated query that takes a while to execute and thought that it would be helpful if the user could get some form of feedback regarding the progress of the query. I intend to display a suitable 'please wait' message on a status bar when the query is started and cle... | 2010/06/27 | [
"https://Stackoverflow.com/questions/3127088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162502/"
] | In retrospect, I'm sorry I posted this question as the answer was remarkably easy and has nothing to do with events. Here is my simple solution.
```
statusbar1.simpletext:= 'Opening query';
qComplicated.open;
statusbar1.simpletext:= '';
```
When the query returns with its data, program control moves to the statement... | Since this is UI related (showing a message), I would probably use the TClientDataSet's AfterOpen event. |
74,131,585 | Found this question by @CarstenWE but it had been closed with no answer: [How to get classification report from the confusion matrix?](https://stackoverflow.com/questions/73308803/how-to-get-classification-report-from-the-confusion-matrix)
As the question is closed, I opened this question to provide an answer.
The que... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74131585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3168934/"
] | This is how I solved it!
```
deliver(
app_identifier: '{{YOUR_APP_ID}}',
submit_for_review: false,
skip_screenshots: true,
force: true,
itc_provider: "{{YOUR_TEAM_ID}}" // <- added!
)
``` | For me adding the environment variable works perfectly:
```
ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD: true
```
For my case, here is an example of Azure DevOps pipelines:
```yaml
- task: AppStoreRelease@1
env:
ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD: true
...
```
Source [Fastlane GitHub issue](h... |
15,778,947 | How does the Aggregation Framework's `$max` operator evaluate on a compound key. For example:
```
{
$project: {
user: 1,
record: { date: "$upload_date", comment: 1, some_integer: 1 }
}
},
{
$group: {
_id: "$user",
latest: { $max : "$record" }
}
}
```
Will it get the maximum by `date`, `comm... | 2013/04/03 | [
"https://Stackoverflow.com/questions/15778947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1847471/"
] | Replacing the Highchart with 3.0 works for me..Sebastian Bochan also answered same thing | Replace the jQuery 1.8.2 with jQuery 1.4.2 |
33,335,471 | I'm trying to set up a basic Titan example. In following the docs, I tried running `bin/gremlin-server.sh -i com.thinkaurelius.titan titan-all 1.0.0` which throws;
```
Could not install the dependency: java.io.FileNotFoundException: /usr/share/titan/ext/titan-all/plugin/titan-all-1.0.0.jar (No such file or directory)
... | 2015/10/25 | [
"https://Stackoverflow.com/questions/33335471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/998101/"
] | The basic install for Titan is unzip the titan-1.0.0-hadoop1.zip. That is it!
Download it from <http://titandb.io>
<http://s3.thinkaurelius.com/docs/titan/1.0.0/getting-started.html>
It is already packaged with the Titan plugins, so you don't need to install them into the Gremlin Console or Gremlin Server.
If you w... | For anyone that comes across this strangeness, read the whole stack trace. It turns out waaay at the bottom, it actually had the real issue; it couldn't connect to Cassandra because I had not enabled Thrift. |
169,198 | I have a script as below:
```
#!/bin/bash
df -k | tr -s " " "," | awk 'BEGIN {FS=","} {print $1,$5}'|sed 1d > file1.txt
while read partition percentUsed
do
if [ $percentUsed > 75 ]
then
echo Partition: ${partition} space is ${percentUsed}
else
echo Pration: $partition: OK!!
fi
done < file1.txt
```
The script is exec... | 2014/11/21 | [
"https://unix.stackexchange.com/questions/169198",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/80040/"
] | In line 5 you write the contents of $percentUsed to file "75". Instead, try `if [ ``echo $percentUsed | sed 's/%//'`` -gt 75 ]` which should do what you desire. At least with bash 4.2.25 on Linux it works. Note: Please only use one backtick instead of two shown here - that's because the Stackexchange web platform inter... | This is one efficient way to calculate the disk space. In this example, I am using the `/home` dir.
```
#!/bin/bash
{ read -r; read -rd '' -a disk_usage; } < <(LC_ALL=C df -Pk "/home"; printf \\0)
percent=$(echo "${disk_usage[4]}" | awk '{print $0+0}')
if (( percent > 75 )); then echo "Disk is critical"; els... |
45,654,051 | What I am trying to accomplish is when a user clicks on a button, such as "Sign In", I fire my action which sets my state in my app state reducer to `loading:true` and the loading screen pops up. I would like to have that functionality across my screens just by setting my show loading state to true via an action.
I do... | 2017/08/12 | [
"https://Stackoverflow.com/questions/45654051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1361375/"
] | Use `error` event attached to `<link>` and, or `<script>` element, see [Is there a way to know if a link/script is still pending or has it failed](https://stackoverflow.com/questions/39824927/is-there-a-way-to-know-if-a-link-script-is-still-pending-or-has-it-failed/39908873?s=1|0.1926#39908873) | For checking `css` file exist or not, Just check if a `<link>` element exists with the `href` attribute set to your CSS file's URL:
```
if (!$("link[href='/path/to.css']").length){
// css file not exist
}
```
and for `js`
```
if (!$("script[src='/path/to.js']").length){
// js file not exist
}
``` |
31,309,494 | I have a requirement where i have to populate drop down with list of all the weeks in a particular year as shown in the image

How can i achieve the list dynamically depending on the year using jquery or Rails? | 2015/07/09 | [
"https://Stackoverflow.com/questions/31309494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1273282/"
] | ```
start_date = Date.current.beginning_of_year
end_date = Date.current.end_of_year
weeks = []
(start_date..end_date).to_a.in_groups_of(7).each do |range|
weeks << "#{range.first} to #{range.last}"
end
``` | This might help you:
```
date1 = Date.today.beginning_of_year
date2 = Date.today.end_of_year
weeks = []
while date2>date1 do
weeks << [date1.beginning_of_week, date1.end_of_week]
date1=date1+7.days
end
```
You can also format date as per your requirement before pushing it to array. |
49,665,461 | I am trying to read a .txt file into two different arrays one 1d string array and one 2d int array. The code reads the names into the NamesArray just fine. However, the code seems to either only read the first column of numbers in or only outputs the first column. I'm not sure where I'm going wrong with the code. Any h... | 2018/04/05 | [
"https://Stackoverflow.com/questions/49665461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9599452/"
] | The problem is that you are only storing one number in the `MileageArray` at index `[count][count]`. You will need to populate the array with a loop that loops for the total number of integer tokens expected like so:
```
for(int j = 0; j < 7; j++){
Mileage = inFile.nextInt();
MileageArray[Count][j] = Mileage;
... | The answer is simple, what you do by invoking `Mileage = inFile.nextInt()` you get the next token of the input line you are currently at and parse it to an `int` but since the numbers are delimited by something (assumed a whitespace) only the first number is read and parsed.
You have multiple options to fix this. You... |
5,391,394 | I would like to enter the values in a range like 1-60. The `EditText` shouldn't accept values like 61,62..., or 0,-1,-2...
How can we give the range 1-60 to `EditText` in android?
I have done in main.xml as
```
<EditText android:layout_height="wrap_content"
android:id="@+id/editText1"
android:layout_width=... | 2011/03/22 | [
"https://Stackoverflow.com/questions/5391394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/769225/"
] | I fixed Daniel Wilson's solution:
```
public class InputFilterMinMax implements InputFilter {
private int min, max;
public InputFilterMinMax(int min, int max) {
this.min = min;
this.max = max;
}
public InputFilterMinMax(String min, String max) {
this.min = Integer.parseInt(min);
this.max = Integer.p... | Why not use a Seekbar Instead of EditText?
That way, only numbers can be entered and the maximum limit can be specified/modified as and when you need.
```
public class SeekBar1 extends Activity implements SeekBar.OnSeekBarChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCrea... |
12,148,729 | Is there a way to echo a variable that is already echoing something, I try doing it this way but its not echoing it out
```
if (logged_in() === true) {
echo
'
<li ><a href="#">',$user_data['username'],'</a>
<ul>
<li><a href="../social.php">socail</a></li>
<li><a href="../my/pictures.... | 2012/08/27 | [
"https://Stackoverflow.com/questions/12148729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1610606/"
] | Do you mean concatenation?
```
<li ><a href="#">' . $user_data['username'] . '</a>
``` | You're concatenating the string wrong, you should use dots:
**EDIT**
After some googling I found out that it is apparently OK to concatenate with commas also, I did not know that...
```
echo "text".$variable."text".$variable2; //and so on.
```
**EDIT 2**
Apparently echo can take multiple parameters, which is wha... |
16,747,056 | I have two tables: posts and comment. One post has many comments.
Often I want to retrieve all posts along with any comment they may have. I do this with a left join as shown:
```
select p.post_id, p.content_status, p.post_title, c.comment_id,
c.content_status as comment_status
from post p
left join comment... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16747056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356282/"
] | Just move the condition on the right-hand table into the `ON` clause.
Any condition in the `WHERE` clause will remove rows entirely, while conditions in the `ON` clause will - as you want - not remove the row but just prevent a match.
```
SELECT p.post_id, p.content_status, p.post_title, c.comment_id,
c.cont... | Move the condition on the left-joined table into the join condition:
```
select p.post_id, p.content_status, p.post_title, c.comment_id, c.content_status as comment_status
from post p
left join comment c
on p.post_id = c.post
and c.content_status = 'Approved'
where p.content_status = 'Approved'
```
It seems to b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.