Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
39,681,284 | Normalizr - How to generate slug/id related to parent entity | <p>How can I assign id/slug related to the entity's parent using <a href="https://github.com/paularmstrong/normalizr" rel="noreferrer">normalizr</a>?</p>
<p>Example:</p>
<p>API Response for a user call:</p>
<pre><code>{
id: '12345',
firstName: 'John',
images: [
{
url: 'https://www.domain.com/image0',
name: 'image0'
},
{
url: 'https://www.domain.com/image1',
name: 'image1'
}
]
}
</code></pre>
<p>I could define my schemas in the following way:</p>
<pre><code>const image = new Schema('images');
const user = new Schema('users');
user.define({
images: arrayOf(image)
})
</code></pre>
<p>The problem is that images don't have an <code>id</code> property, so normalizr will not be able to distinguish them unless we provide an <code>id</code> property. Of course, we could do something like </p>
<pre><code>const image = new Schema('images', { idAttribute: uuid.v4() });
</code></pre>
<p>and generate unique identifiers.</p>
<p>Suppose we receive a user update and an image's name has been updated. Because we generate unique identifiers in every normalization, we are not able to identify and update the existing image.</p>
<p>I need a way to reference the parent entity (user) in the image entity (either in its id/slug like <code>12345-image0</code>, <code>12345-image1</code> or as a separate property.</p>
<p>What would be the optimal way to achieve this?</p>
| <javascript><reactjs><redux><normalizr> | 2016-09-24 21:50:59 | HQ |
39,681,674 | Use disable with model-driven form | <p>I'm trying to use the <code>disabled</code> inside my model-driven form. I have the following form:</p>
<pre><code>this.form = this.formBuilder.group({
val1: ['', Validators.required],
val2: [{value:'', disabled:this.form.controls.val1.valid}]
});
</code></pre>
<p>I'm getting an error (not finding <code>controls</code> of <code>this.form</code>) probably because I'm using <code>this.form</code> inside <code>this.form</code>.</p>
<p>How can I fix that?</p>
<p>PS I've also tried to add <code>[disabled]='...'</code> inside my html but I get a warning saying I should use the formBuilder instead</p>
| <angular><angular2-forms><angular2-formbuilder> | 2016-09-24 22:51:24 | HQ |
39,682,223 | Passing an options hash to a sidekiq worker | <p>I remember when I tried passing a params (JSON) option to a sidekiq worker method and it didn't work out well because I was referencing the option like:</p>
<pre><code>options[:email_address]
</code></pre>
<p>But I think it would have worked if I did:</p>
<pre><code>options["email_address"]
</code></pre>
<p>So for some reason when it gets serialized and deserialized the hash can only be referenced with a string not a symbol.</p>
<p><strong>Is this a safe practise?</strong></p>
<p>I have a transaction email worker that looks like:</p>
<pre><code>class TransactionEmailWorker
include Sidekiq::Worker
def perform(action, options)
case action
when 'welcome'
welcome(options["email_address"], options["something_else"])
when 'reset_password'
reset_password(options["email_address"])
end
end
def welcome(email, title)
# ...
end
def reset_password(email)
# ..
end
</code></pre>
| <ruby-on-rails><sidekiq> | 2016-09-25 00:23:55 | HQ |
39,682,285 | code signature in (/xxxxx) not valid for use in process using Library Validation | <p>I'm trying to build proxychains with xcode 8. When I run a program I got:</p>
<pre><code>/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib: code signing blocked mmap() of '/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib'
</code></pre>
<p>When I signed the program and library:</p>
<pre><code>codesign -s "Mac Developer: xxxx" `which proxychains`
codesign -s "Mac Developer: xxxx" /usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib
</code></pre>
<p>No errors, but when I run it again, it says</p>
<pre><code>/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib: code signature in (/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib) not valid for use in process using Library Validation: mapping process is a platform binary, but mapped file is not
</code></pre>
<p>What should I do now? Do I need some sort of entitlements?</p>
| <macos><validation><codesign> | 2016-09-25 00:33:44 | HQ |
39,682,774 | remove item object javascript | <p>I have the following object:</p>
<pre><code>[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}, {
"id": 1,
"price": 1000,
"name": "Mr Robot T2",
"image": "http://placehold.it/270x335"
}]
</code></pre>
<p>and what I want is to remove the first item (id = 1) and the result is:</p>
<pre><code>[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}]
</code></pre>
<p>as it could do?</p>
| <javascript><jquery><object> | 2016-09-25 02:17:36 | LQ_CLOSE |
39,682,971 | How to parse TextBox to arguments to run a exe | <p>I need to parse login and password from textbox to arguments to run a exe</p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
string password = textBox2.Text;
Process p = new Process();
p.StartInfo.FileName = "Main.exe";
p.StartInfo.Arguments = "-IFZUpdatedOk_K0 -gna -login @username -pwd @password";
p.Start();
p.WaitForExit();
// System.Diagnostics.Process.Start("Main.exe", " -IFZUpdatedOk_K0 -gna -login email@email.com -pwd mypassword");
}``
</code></pre>
| <c#> | 2016-09-25 03:03:00 | LQ_CLOSE |
39,683,151 | Is Google In-app Subscriptions available in Egypt? | <p>I am going do develop new android app using google play services and I am asking Is Google In-app Subscriptions available in Egypt ? how it works for upgrading subscriptions pricing ?
Thanks.</p>
| <android><google-play><google-play-services> | 2016-09-25 03:39:51 | LQ_CLOSE |
39,683,516 | I have a database with primary key set to auto increment. But can't enter form data from a post method in php. Can anyone help me? | Here's the code. I have logins table in users database. Also a form whose action is set to below code.
<?php
if(isset($_POST['signup'])){
if (isset($_POST['Full-name']) && isset($_POST['psd']) && isset($_POST['email'])) {
$link2 = @mysqli_connect('localhost', 'root', '') or die("Oops! Can't connect");
@mysqli_select_db($link2, 'users') or die("Can't find Database");
$fullname = $_POST['Full-name'];
$email2 = $_POST['email'];
$newpassword = $_POST['psd'];
echo $fullname.$email2.$newpassword; //print sucessfully
$query2 = mysqli_query($link2, "INSERT INTO logins VALUES (NULL, $email2, $newpassword)");
if ($query2) {
echo "You have signed up successfully";
} else {
echo "Error: "; //query prints this statement
}
mysqli_close($link2);
}
}
?> | <php><sql><post> | 2016-09-25 04:51:35 | LQ_EDIT |
39,683,862 | Facebook Graph Request using Swift3 - | <p>I am rewriting my graph requests with the latest Swift3. I am following the guide found here - <a href="https://developers.facebook.com/docs/swift/graph">https://developers.facebook.com/docs/swift/graph</a>. </p>
<pre><code>fileprivate struct UserProfileRequest: GraphRequestProtocol {
struct Response: GraphResponseProtocol {
init(rawResponse: Any?) {
// Decode JSON into other properties
}
}
let graphPath: String = "me"
let parameters: [String: Any]? = ["fields": "email"]
let accessToken: AccessToken? = AccessToken.current
let httpMethod: GraphRequestHTTPMethod = .GET
let apiVersion: GraphAPIVersion = .defaultVersion
}
fileprivate func returnUserData() {
let connection = GraphRequestConnection()
connection.add(UserProfileRequest()) {
(response: HTTPURLResponse?, result: GraphRequestResult<UserProfileRequest.Response>) in
// Process
}
connection.start()
</code></pre>
<p>However, I am getting this error in the connection.add method:</p>
<pre><code>Type ViewController.UserProfileRequest.Response does not conform to protocol GraphRequestProtocol.
</code></pre>
<p>I can't seem to figure this out what to change here. It seems like the developer guide is not up to date on Swift3, but I am not sure that is the issue. </p>
<p>Is anyone able to see what is wrong here?</p>
<p>Thanks.</p>
| <swift><facebook><facebook-graph-api><facebook-ios-sdk> | 2016-09-25 05:54:21 | HQ |
39,684,161 | Why an application starts with FPU Control Word different than Default8087CW? | <p>Could you please help me to understand what is going on with FPU Control Word in my Delphi application, on Win32 platform.</p>
<p>When we create a new VCL application, the control word is set up to 1372h. This is the first thing I don't understand, why it is 1372h instead of 1332h which is the <code>Default8087CW</code> defined in <code>System</code> unit.</p>
<p>The difference between these two:</p>
<pre><code>1001101110010 //1372h
1001100110010 //1332h
</code></pre>
<p>is the 6th bit which according to documentation is reserved or not used.</p>
<p>The second question regards <code>CreateOleObject</code>.</p>
<pre><code>function CreateOleObject(const ClassName: string): IDispatch;
var
ClassID: TCLSID;
begin
try
ClassID := ProgIDToClassID(ClassName);
{$IFDEF CPUX86}
try
Set8087CW( Default8087CW or $08);
{$ENDIF CPUX86}
OleCheck(CoCreateInstance(ClassID, nil, CLSCTX_INPROC_SERVER or
CLSCTX_LOCAL_SERVER, IDispatch, Result));
{$IFDEF CPUX86}
finally
Reset8087CW;
end;
{$ENDIF CPUX86}
except
on E: EOleSysError do
raise EOleSysError.Create(Format('%s, ProgID: "%s"',[E.Message, ClassName]),E.ErrorCode,0) { Do not localize }
end;
end;
</code></pre>
<p>The above function is changing control word to <code>137Ah</code>, so it is turning on the 3rd bit (Overflow Mask). I don't understand why it is calling <code>Reset8087CW</code> after, instead of restoring the state of the word which was before entering into the function? </p>
| <delphi><com><fpu><delphi-10.1-berlin> | 2016-09-25 06:41:20 | HQ |
39,684,974 | Docker for Windows error: "Hardware assisted virtualization and data execution protection must be enabled in the BIOS" | <p>I've installed Docker and I'm getting this error when I run the GUI:</p>
<blockquote>
<p>Hardware assisted virtualization and data execution protection must
be enabled in the BIOS</p>
</blockquote>
<p>Seems like a bug since Docker works like a charm from the command line, but I'm wondering if anyone has a clue about why this is happening?</p>
<p>Before you ask, yes, I've enabled virtualization in the BIOS and the Intel Processor Identification Utility confirms that it's activated. Docker, docker-machine and docker-compose all work from the command line, Virtualbox works, running Docker from a Debian or Ubuntu VM works.</p>
<p>There's just this weird issue about the GUI.</p>
<p>My specs:</p>
<ul>
<li>Windows 10 Pro x64 Anniversary Edition</li>
<li>Intel core i5-6300HQ @ 2.30GHz</li>
</ul>
| <windows><docker> | 2016-09-25 08:45:26 | HQ |
39,685,271 | Getting metadata in EF Core: table and column mappings | <p>Looking to get metadata in EF Core, to work with the mappings of objects & properties to database tables & columns.</p>
<p>These mappings are defined in the DBContext.cs OnModelCreating() method, mapping tables with .ToTable(), and columns via .Property.HasColumnName().</p>
<p>But I don't see this metadata under the Entity Types returned by...</p>
<pre><code>IEnumerable<IEntityType> entityTypes = [dbContext].Model.GetEntityTypes();
</code></pre>
<p>Is this metadata available anywhere in EF Core?</p>
| <entity-framework-core> | 2016-09-25 09:20:53 | HQ |
39,685,740 | Calculate sklearn.roc_auc_score for multi-class | <p>I would like to calculate AUC, precision, accuracy for my classifier.
I am doing supervised learning:</p>
<p>Here is my working code.
This code is working fine for binary class, but not for multi class.
Please assume that you have a dataframe with binary classes:</p>
<pre><code>sample_features_dataframe = self._get_sample_features_dataframe()
labeled_sample_features_dataframe = retrieve_labeled_sample_dataframe(sample_features_dataframe)
labeled_sample_features_dataframe, binary_class_series, multi_class_series = self._prepare_dataframe_for_learning(labeled_sample_features_dataframe)
k = 10
k_folds = StratifiedKFold(binary_class_series, k)
for train_indexes, test_indexes in k_folds:
train_set_dataframe = labeled_sample_features_dataframe.loc[train_indexes.tolist()]
test_set_dataframe = labeled_sample_features_dataframe.loc[test_indexes.tolist()]
train_class = binary_class_series[train_indexes]
test_class = binary_class_series[test_indexes]
selected_classifier = RandomForestClassifier(n_estimators=100)
selected_classifier.fit(train_set_dataframe, train_class)
predictions = selected_classifier.predict(test_set_dataframe)
predictions_proba = selected_classifier.predict_proba(test_set_dataframe)
roc += roc_auc_score(test_class, predictions_proba[:,1])
accuracy += accuracy_score(test_class, predictions)
recall += recall_score(test_class, predictions)
precision += precision_score(test_class, predictions)
</code></pre>
<p>In the end I divided the results in K of course for getting average AUC, precision, etc.
This code is working fine.
However, I cannot calculate the same for multi class: </p>
<pre><code> train_class = multi_class_series[train_indexes]
test_class = multi_class_series[test_indexes]
selected_classifier = RandomForestClassifier(n_estimators=100)
selected_classifier.fit(train_set_dataframe, train_class)
predictions = selected_classifier.predict(test_set_dataframe)
predictions_proba = selected_classifier.predict_proba(test_set_dataframe)
</code></pre>
<p>I found that for multi class I have to add the parameter "weighted" for average.</p>
<pre><code> roc += roc_auc_score(test_class, predictions_proba[:,1], average="weighted")
</code></pre>
<p>I got an error: raise ValueError("{0} format is not supported".format(y_type))</p>
<p>ValueError: multiclass format is not supported</p>
| <python><scikit-learn><supervised-learning> | 2016-09-25 10:17:43 | HQ |
39,685,765 | conversion of integers to roman numerals (python) | I understand there were many similar questions being asked on this topic.But I still have some doubts need to be clear
def int_to_roman(input):
if type(input) != type(1):
raise TypeError, "expected integer, got %s" % type(input)
if not 0 < input < 4000:
raise ValueError, "Argument must be between 1 and 3999"
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
result = ""
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
return result
I dont really understand the code below:
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
anyone please explain this code?? Thanks!! If there is any example it would be best!!! | <python><python-2.7><function><roman-numerals> | 2016-09-25 10:19:56 | LQ_EDIT |
39,686,363 | How to create playstore like shapes | <p><a href="https://i.stack.imgur.com/ymHW0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ymHW0.png" alt="Playstore like shapes"></a></p>
<p>How to create these download, rating , Media & Video and similar kind of shapes in android ? Is there any library available to do that ?</p>
<p>Thanks in advance.</p>
| <android> | 2016-09-25 11:36:14 | LQ_CLOSE |
39,686,382 | How to reset the index to 0 in an arraylist | As per the flow..
I added 3 values to arraylist
then removed the value for the index 1
then when i am trying to display all values using for loop, i am getting below error.
**Code** marked where the exception occurred
[Code][1]
Below is the error message
[error][2]
[1]: http://i.stack.imgur.com/nY4Wc.png
[2]: http://i.stack.imgur.com/Sr2f5.png | <java> | 2016-09-25 11:39:20 | LQ_EDIT |
39,686,780 | Memory allocation using calloc | <p>I want to initialize my large 2D array to zero.
if i allocate memory through calloc it will automatically initialize all the cells to zero.
Whether it is possible to allocate memory for 2D array using single calloc function ?
Thank you</p>
| <c> | 2016-09-25 12:25:13 | LQ_CLOSE |
39,688,422 | Correct S3 Policy For Pre-Signed URLs | <p>I need to issue pre-signed URLs for allowing users to GET and PUT files into a specific S3 bucket. I created an IAM user and use its keys to create the pre-signed URLs, and added a custom policy embedded in that user (see below). When I use the generated URL, I get an <code>AccessDenied</code> error with my policy. If I add the <code>FullS3Access</code> policy to the IAM user, the file can be GET or PUT with the same URL, so obviously, my custom policy is lacking. What is wrong with it?</p>
<p>Here's the custom policy I am using that is not working:</p>
<pre><code>{
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::MyBucket"
]
},
{
"Action": [
"s3:AbortMultipartUpload",
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:DeleteBucketPolicy",
"s3:DeleteObject",
"s3:GetBucketPolicy",
"s3:GetLifecycleConfiguration",
"s3:GetObject",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListMultipartUploadParts",
"s3:PutBucketPolicy",
"s3:PutLifecycleConfiguration",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::MyBucket/*"
]
}
]
}
</code></pre>
| <amazon-s3><amazon-iam><amazon-policy> | 2016-09-25 15:10:54 | HQ |
39,688,512 | How to get class name of the WebElement in Python Selenium? | <p>I use Selenium webdriver to scrap a table taken from web page, written in JavaScript.
I am iterating on a list of table rows. Each row may be of different class. I want to get the name of this class, so that I can choose appropriate action for each row.</p>
<pre><code>table_body=table.find_element_by_tag_name('tbody')
rows=table_body.find_elements_by_tag_name('tr')
for row in rows:
if(row.GetClassName()=="date"):
Action1()
else:
Action2()
</code></pre>
<p>Is this possible with Selenium? Or suggest another approach.</p>
| <python><selenium-webdriver> | 2016-09-25 15:20:19 | HQ |
39,688,693 | how to develop UI for desktop application using TELERIK | <p>i want my interface to look more elegant though professional and i want to make it good as web/android UI's. But how do i do it? I have heard about TELERIK UI. but i have no idea about how to use it. I have downloaded it and initialised it but do not know what and how to do next. any help would be really appreciated.Thanks. </p>
| <c#><user-interface><telerik><desktop-application> | 2016-09-25 15:39:58 | LQ_CLOSE |
39,688,739 | vba code to display multiple rows in excel | I want to display multiple rows with same name in excel sheet that I have created using vba code.. I have created a textbox in my excel sheet 1 and when I enter a name in the text box and click search button I want the multiple rows of the same person to be displayed in excel sheet 3..
Code:
I have created the excel sheet called "List" and the data in there is
NAME CITY
LAKHA LONDON
KIKI US
LAKHA US
I have a code here.
Sub finddata()
Dim erow As Long
Dim ws As Worksheet
Dim lastrow As Long
Dim count As Integer
lastrow = Sheets("List").Cells(Rows.count, 1).End(xlUp).Row
For x = 2 To lastrow
If Sheets("List").Cells(x, 1) = Sheet1.Range("E7") Then
Sheet3.Range("A2") = Sheets("List").Cells(x, 1)
Sheet3.Range("B2") = Sheets("List").Cells(x, 2)
End If
Next x
End Sub
Sub printdata()
Sheet3.Range("A1:B2").PrintPreview
'Sheet3.Range("A1:B2").PrintOut
End Sub
Sub Clear_Cells()
Sheets("Sheet3").Range("A2:B2").ClearContents
Sheets("Sheet1").Range("E7:E7").ClearContents
End Sub
But this only displays one row at a time...
Immediate answers please. I am in deadline...
| <excel><vba> | 2016-09-25 15:43:32 | LQ_EDIT |
39,688,830 | Why use/develop Guice, when You have Spring and Dagger? | <p>To my knowledge, Dagger does generate code, while Guice and Spring rely on runtime processing, thus Dagger works faster, but requires more work on programmer side. Because of performance edge it's good for mobile (Android) development.</p>
<p>However, when we are left with Guice and Spring, the latter has lots of integrations. What's the point of developing/using Guice, if we can use Spring Framework (that does basically same thing, but offers ex. easier database access)?</p>
<p>Isn't Google trying to reinvent wheel by creating their own DI tool, instead of using (and possibly contributing to) Spring Framework?</p>
<p>I am looking for decision tree, that guides through choosing DI tool.</p>
| <java><spring><guice><dagger-2> | 2016-09-25 15:52:14 | HQ |
39,689,683 | Choose if array element repeats itself twice -- Javascript | <p>There is a javascript array</p>
<pre><code>var arr = [0, 1, 2, 2, 3, 3, 5];
</code></pre>
<p>I want to choose elements that repeats twice. In this case its <code>2</code> and <code>3</code>. and i want attach them into a variable.</p>
<pre><code>var a = 2, b = 3;
</code></pre>
<p>As far as i know there is no built-in function to do that job. How can i do that. Thanks.</p>
| <javascript><arrays> | 2016-09-25 17:22:25 | LQ_CLOSE |
39,689,707 | Sort a python dictionary value which is a list | <p>I have a dictionary with the following structure, how can I sort each list within itself in ascending order?</p>
<pre><code>mydictionary = {'1':[1,4,2], '2':[2,1,3], '3':[1,3,2]}
</code></pre>
<p>I want to have the dictionary sorted like this:</p>
<pre><code>mydictionary_sorted = {'1':[1,2,4], '2':[1,2,3], '3':[1,2,3]}
</code></pre>
| <python><list><sorting><dictionary> | 2016-09-25 17:25:47 | LQ_CLOSE |
39,689,982 | Sql Data Type for a specific string | i have a string format like :
<p>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
might be alot of ligns like those ,
<<p>My question is wich data type i should store those lignes (i think Maximum will be 100 Lignes) in a `SQL Database`
have a nice day ! | <sql><database> | 2016-09-25 17:56:16 | LQ_EDIT |
39,690,492 | How do you connect to multiple databases on a single webpage? | <p>I was wondering how i can connect to multiple databases on a single PHP webpage.
i know how to connecet to a single database using:</p>
<pre><code>enter code here:
$dbh=mysql_connect($hostname,$username,$password)or die("unable to connect to MYSQL");
</code></pre>
<p>However,can i just use multiple "mysql_connect"commands to open the other databases,and how would PHP know what databases i want the informaion pulled from if I do have multiple databases connected</p>
| <php><mysql> | 2016-09-25 18:42:50 | LQ_CLOSE |
39,690,963 | C# How to find how much of numbers are Entered? | <p>How to find how much of numbers are Entered ? </p>
<pre><code> static void Main(string[] args)
{
string x;
double t, s = 1;
while ((x = Console.ReadLine()) != null)
{
}
</code></pre>
| <c#> | 2016-09-25 19:30:37 | LQ_CLOSE |
39,691,186 | How to make a mobile designed site appear similar on differn't screen resoloutions | <p>I am currently designing a mobile site, that would work perfectly on a 320x480 screen. The issue comes, as newer phones don't use that size anymore, and are much much bigger. (As I found out after I put all that effort in and read it on my phone.) I was wondering if there is any easy way to make it all expand the the proper size I would like it to look without going ahead and giving everything a view-width/vw or view-height/vh rating. (Nvm, I wonder how that would impact the font size.)</p>
<p>Or would I need to go ahead and do that, or something similar? (As it would be particularly bad if it wasn't mobile friendly, for a variety of reasons involving it's creation.)</p>
| <html><css><mobile><font-size> | 2016-09-25 19:53:11 | LQ_CLOSE |
39,692,230 | Got "is not a recognized Objective-C method" when bridging Swift to React-Native | <p>I'm trying to bridge my React-Native 0.33 code to a super simple Swift method, following <a href="https://facebook.github.io/react-native/docs/native-modules-ios.html">this guide</a> but all I'm getting is <code>show:(NSString *)name is not a recognized Objective-C method</code>.</p>
<p>Here's my code:</p>
<h3>SwitchManager.swift</h3>
<pre><code>import Foundation
@objc(SwitchManager)
class SwitchManager: NSObject {
@objc func show(name: String) -> Void {
NSLog("%@", name);
}
}
</code></pre>
<h3>SwitchManagerBridge.h</h3>
<pre><code>#import "RCTBridgeModule.h"
@interface RCT_EXTERN_MODULE(SwitchManager, NSObject)
RCT_EXTERN_METHOD(show:(NSString *)name)
@end
</code></pre>
<h3>SwitchManager-Bridging-Header.h</h3>
<pre><code>#import "RCTBridgeModule.h"
</code></pre>
<p>Then on my <code>index.ios.js</code> file I'm importing SwitchManager with <code>import { SwitchManager } from 'NativeModules';</code> and calling <code>SwitchManager.show('One');</code>. This is where the error happened.</p>
<p>Not sure what's wrong.</p>
| <objective-c><swift><reactjs><react-native> | 2016-09-25 21:56:12 | HQ |
39,692,362 | Why doesn't onClick activate function? | <p>I'm trying to write a simple code in JavaScript where selecting a button calls a prompt function, but the prompt never pops. </p>
<p>This is the HTML:</p>
<pre><code> <div id="btnDiv">
<button type="submit" id="btn" onclick="submit"> send info </button>
</div>
</code></pre>
<p>And this is the JavaScript code:</p>
<pre><code> document.getElementById("btn").onclick = function(){
prompt("Thank you");
}
</code></pre>
<p>What am I doing wrong?</p>
| <javascript><onclick><submit> | 2016-09-25 22:17:12 | LQ_CLOSE |
39,692,418 | How to create my own delay function in C | <p>I'm developing an OS and don't have access to the standard library. Therefore, I don't have access to <code>time.h</code>.</p>
<p>I'm using the following function to create a time delay.</p>
<pre><code>void delay() {
int c = 1 , d = 1 ;
for ( c = 1; c <= 100000; c++) {
for ( d = 1; d <= 100000; d ++) {
asm("nop");
}
}
}
</code></pre>
<p>This waits around twenty seconds; however, I'd like the function to take in an integer and wait for that many seconds. What will I need to do to make this possible?</p>
| <c><assembly><timedelay> | 2016-09-25 22:28:21 | LQ_CLOSE |
39,692,617 | Copy a string to clipboard from Mac OS command line | <p>is there a way to copy a string to clipboard from command line?</p>
<p>To be more specific, I want to make a script which copies my email address to clipboard, so that when I need to insert it several times for logging in / register, I just run the script once and then CMD+V it whenever I need.</p>
<p>I heard of <code>pbcopy</code>, but I think this is not my case. Any suggestion?
Many thanks!</p>
| <bash><macos><shell><terminal><clipboard> | 2016-09-25 23:00:23 | HQ |
39,692,722 | What do assembly registers refer to in C code? | <p>I'm currently refactoring c code and inside there is assembly code:</p>
<pre><code>asm("movl $8, %esi\n\t"
movl $.LC0, %edi\n\t"
"movl $0, %eax");
</code></pre>
<p>What doe each of the registers mean? In the c code, there isn't other asm code that assigns $8 or $.LC0, I'm assuming $0 is just a zero value</p>
| <c><assembly> | 2016-09-25 23:16:47 | LQ_CLOSE |
39,693,629 | I am getting a class, interface, or enum epected error in blue jay | I am using Blue Jay and want to just create a simple rectangle. I tried adding a class to use the method Canvas but it does not seem to work.
java.lang.Object;
java.awt.Component;
java.awt.Canvas;
/**
* Write a description of class test here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Canvas
{
// instance variables - replace the example below with your own
private int x;
/**
* Constructor for objects of class test
*/
public test()
{
// initialise instance variables
//Going to insert the code right here
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public int sampleMethod(int y)
{
// put your code here
return x + y;
}
}
| <java><canvas> | 2016-09-26 01:45:19 | LQ_EDIT |
39,694,756 | So i made a simple program in C, which calculates factorial of a number | So i made a simple program in C, which calculates factorial of a number, but at the end i want to run the program instead of "press any key to continue" I want it to show "press any key to find factorial of a number again"
code :
#include<stdio.h>
int main()
{
int facto, i, m ;
m=1 ;
printf("Ener a Value : ");
scanf("%d", &facto) ;
for( i=facto-1 ; i>m ; i-- )
facto *= i ;
printf("My Reg num:SP-16/BBS/033\nFactorial of the number : =%d\n",facto );
system ("pause") ;
} | <c> | 2016-09-26 04:31:18 | LQ_EDIT |
39,696,038 | Why using Bash readonly variable to capture output fails to capture return code $? | <p>Here's example that tries to execute command and checks if it was executed successfully, while capturing it's output for further processing:</p>
<pre><code>#!/bin/bash
readonly OUTPUT=$(foo)
readonly RES=$?
if [[ ${RES} != 0 ]]
then
echo "failed to execute foo"
exit 1
else
echo "foo success: '${OUTPUT}'"
fi
</code></pre>
<p>It reports that it was a success, even there is no such <code>foo</code> executable. But, if I remove <code>readonly</code> from <code>OUTPUT</code> variable, it preserves erroneous exit code and failure is detected.</p>
<p>I try to use readonly as for "defensive programming" technique as recommended somewhere... but looks like it bites itself in this case.</p>
<p>Is there some clean solution to preserve <code>readonly</code> while still capturing exit code of command/subshell? It would be disappointing that one has to remember this kind of exceptional use case, or revert to not using <code>readonly</code> ever...</p>
<p>Using Bash 4.2.37(1) on Debian Wheezy.</p>
| <bash><variables> | 2016-09-26 06:30:17 | HQ |
39,696,310 | Django contrib admin default admin and password | <p>This may be a silly question. I start a new Django project as Document says, which only included an admin page. I start the server and use a web browser accessing the page. What can I enter in the username and password? Is their any place for me to config the default admin account?</p>
| <django> | 2016-09-26 06:47:16 | HQ |
39,697,099 | File upload not working in oops php | public function upload($file=array(),$where){
if (file_exists($this->src.$file['name']))
{
$data['error'] = "Sorry, file already exists.";
}
elseif($file["name"]["size"] > 500000) {
$data['error'] = "Sorry, your file is too large.";
}
elseif(is_array($file))
{
if(in_array($file['type'],$this->type))
{
$filePath = $this->src.$file['name'];
$file_Check = move_uploaded_file($file['name']['tmp_name'], $filePath);
if($file_Check )
{
print_r($file); die();
$name = $file['name'];
//$this->update(array('photo'=>$name,'candi_id'=>$where));
}
$data['error'] = 'File has been uploaded';
}
else
{
$data['error'] = 'File formet was not supported';
}
}
else
{
$data['error'] = 'No File was uploaded...';
}
return $data;
}
output:
file path show correctly.function also working fine but file not move to folder?
file path show correctly.function also working fine but file not move to folder?
| <php><oop> | 2016-09-26 07:35:27 | LQ_EDIT |
39,697,438 | I own vote am getting a Runtime error 6 'overflow' message on the following code please solve it | Sub yahoo()
Dim n As Integer
Range("A:a").AutoFilter Field:=1, Criteria1:="*yahoo*"
n = Range("a:a").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count
Range("c1") = n
End Sub | <vba><excel> | 2016-09-26 07:56:04 | LQ_EDIT |
39,697,977 | data exists but my program says, No data exists for the row/column C# | Please guide me how to resolve this. Thaaaaaaaaaaank youuuuuuuu
private void button3_Click(object sender, EventArgs e)
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
string student = "Select * From tbl_student";
OleDbCommand loadstudent = new OleDbCommand(student, cn);
loadstudent.Parameters.AddWithValue("@SId", textBox8.Text + "%");
rd = loadstudent.ExecuteReader();
if (rd.HasRows == true)
{
// ipapalabas ung labas
while (rd.Read())
{
messageBox.Show("Oops sobra tama na ");
}
}
else
{
MessageBox.Show("No record(s) found.");
}
cn.Close();
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
string s = "Select * From Borrow";
OleDbCommand sa = new OleDbCommand(s, cn);
loadstudent.Parameters.AddWithValue("@SId", textBox8.Text + "%");
rd = sa.ExecuteReader();
if (Convert.ToInt32(rd["B_Quan"].ToString()) > 3)
{
MessageBox.Show("Oops sobra tama na ");
}
cn.Close();
if (cn.State == ConnectionState.Closed) cn.Open();
cmd = new OleDbCommand("Select * From Borrow", cn);
rd = cmd.ExecuteReader();// ipapalitaw
if (rd.HasRows == true)
{
// ipapalabas ung labas
while (rd.Read())
{
if (Convert.ToInt32(rd["B_Quan"].ToString()) > 3)
{
MessageBox.Show("Oops sobra tama na ");
return;
}
}
}
}
}
} | <c#> | 2016-09-26 08:28:57 | LQ_EDIT |
39,698,069 | How to save secret key securely in android | <p>I just read this article <a href="http://android-developers.blogspot.in/2013/02/using-cryptography-to-store-credentials.html" rel="noreferrer">http://android-developers.blogspot.in/2013/02/using-cryptography-to-store-credentials.html</a> where I learnt to generate security key.</p>
<p>I want to know how to save this generated key securely so hackers wont get this even phone is rooted.</p>
<p>If we save this <code>SharedPreference</code>, <code>Storage</code> then hacker can get this.</p>
<p>Thanks.</p>
| <android><security> | 2016-09-26 08:33:17 | HQ |
39,698,357 | Disable Marketplace from Eclipse | <p>I'm running Eclipse Neon on a virtual machine without Internet connection.</p>
<p>I frequently get the annoying prompt "Search Marketplace for compatible editor has encountered a problem", how can I disable the lookup for editors or just entirely the Marketplace?</p>
| <eclipse> | 2016-09-26 08:48:19 | HQ |
39,698,476 | Error on parsing json result? | Greeting! After I removed hardcoded json data and moved to request data from url. I am having exception error. The code is pretty much same as final official git but I am getting these errors.
> Problem parsing the earthquake JSON results org.json.JSONException:
> Index 10 out of range [0..10)
You can view more on github link [gitlink here][1]
[1]: https://github.com/SimonAstaniPersonal/QuakeReportTEst | <java><android><json> | 2016-09-26 08:55:01 | LQ_EDIT |
39,698,564 | Invalid parameter number: number of bound variables does not match number of tokens in C:\wamp\www\midtermexam\update.php on line 78 | <p>Please help, this is my midterm exam, i got stucked for three days :(</p>
<pre><code> if(!isset($errMSG))
{
$stmt = $DB_con->prepare('UPDATE tbl_students
SET studName=:studname,
studCourse=:studcourse,
studAddress=:studaddress,
studGender=:studgender,
studPic=:studpic
WHERE studID=:studid');
$stmt->bindParam(':studname',$studname);
$stmt->bindParam(':studcourse',$studcourse);
$stmt->bindParam(':studpic',$studpic);
$stmt->bindParam(':studid',$studid);
if($stmt->execute()){
</code></pre>
| <php><mysql> | 2016-09-26 08:58:31 | LQ_CLOSE |
39,698,628 | How to give editext with label (in editext) as front of edittextbox | How to give editext with label (in editext) as front of edittextbox[enter image description here][1]
[1]: http://i.stack.imgur.com/lJ1Mb.jpg | <android><android-edittext> | 2016-09-26 09:01:39 | LQ_EDIT |
39,698,675 | can't remove parameter using javascript | <p>i have a url like this</p>
<pre><code>test.html?dir=asc&end_date=2016-09-23&order=created_at&start_date=2016-08-14
</code></pre>
<p>i want to remove the parameter using the following javascript</p>
<pre><code>function removeParam(uri) {
uri = uri.replace(/([&\?]start_date=*$|start_date=*&|[?&]start_date=(?=#))/, '');
return uri.replace(/([&\?]end_date=*$|end_date=*&|[?&]end_date=(?=#))/, '');
}
</code></pre>
<p>but it didn't work, anyone know what's wrong with that?</p>
| <javascript><regex> | 2016-09-26 09:04:17 | LQ_CLOSE |
39,699,107 | Spark RDD to DataFrame python | <p>I am trying to convert the Spark RDD to a DataFrame. I have seen the documentation and example where the scheme is passed to
<code>sqlContext.CreateDataFrame(rdd,schema)</code> function. </p>
<p>But I have 38 columns or fields and this will increase further. If I manually give the schema specifying each field information, that it going to be so tedious job.</p>
<p>Is there any other way to specify the schema without knowing the information of the columns prior.</p>
| <python><apache-spark><pyspark><spark-dataframe> | 2016-09-26 09:24:49 | HQ |
39,699,308 | Can't call a variable inside os.system method in Python | <pre><code>ENV=raw_input("Enter Environment (QA/Prod):")
print(ENV)
os.system('aws ec2 describe-instances --filters "Name=tag:Environment,Values=ENV" "Name=instance-state-code, Values=16" > FilteredOP')
</code></pre>
<p>Hi,
I am quite noob to Python. Here,
I cannot able to call ENV variable in os.system command. Is there anything wrong with the syntax. </p>
| <python><python-2.7> | 2016-09-26 09:35:16 | LQ_CLOSE |
39,699,354 | How to check localhost (im using asp sql server) website to android phone | I need to check my website on my android phone , i wonder how can i connect it through localhost. need help please. thank you. | <android><asp.net><sql-server><localhost> | 2016-09-26 09:37:25 | LQ_EDIT |
39,699,421 | I want Merge some js codes | please any one can help me to merge these js codes in one working java script code
https://raw.githubusercontent.com/scIslam/js/master/11
I think it has the same properties and merge is not impossible but I do not know very well for Java scripts .. & ty for help me | <javascript> | 2016-09-26 09:40:11 | LQ_EDIT |
39,699,715 | python:The word in List can't be removed | [As you can see ,i'm trying to delete the word in a list whose length is 1 or 2 ,but "P" and "ye" can't be find and removed!][1]
[the result of mine][2]
[1]: http://i.stack.imgur.com/7kkKL.png
[2]: http://i.stack.imgur.com/0EEIe.png | <python-2.7> | 2016-09-26 09:55:03 | LQ_EDIT |
39,700,184 | git squash commits while retaining author's info | <p>My coworker (let's call him John here) and I work on a feature. and our working branch look like the following</p>
<pre><code>--o--o--o # this is develop branch
\ o--o--o # this is John's branch
\ / \
o----o--o--o--o--o--o # this is our cowork branch
\ /
o--o--o--o--o--o # this is my branch
</code></pre>
<p>We've finished our work and are ready to merge our cowork to develop branch.</p>
<p>At this point, there are a lot of commits in the cowork branch, which is not expected to be seen by other developers. So I want to squash those commits into one commit.</p>
<p>But after squashing (resolving some conflicts), I've found that the author info all direct to me, there is no John's info.</p>
<p>So my question here is that is there some way to retain both John's and my info while combining those commits together?</p>
| <git> | 2016-09-26 10:16:27 | HQ |
39,700,622 | Kibana: pie chart slices based on substring of a field | <p>I'm trying to create a pie chart visualization that will display the top 10 incoming requests.
I have a search query that filters only the incoming requests which have a field called messages which looks like the following:
"Incoming request /api/someaction".
How do I do the aggregation based on the /api/someaction part rather on the entire string (because then "Incoming" is counted as a term".</p>
<p>Or...can I create custom field which are, for example, a substring of another field?</p>
<p>Thanks</p>
| <elasticsearch><kibana> | 2016-09-26 10:37:35 | HQ |
39,700,624 | Had a confusion with dropdownlist | <p>Hi everyone one making an work hours. Which my boss wants me to create two dropdownlist one is hours of the day(1,2,3) and one is "00/15/30/45" . and radio button for AM PM. My problem is what is "00/15/30/45" means? What datetime format it is? O.o</p>
<p>-newbie junior programmer</p>
| <c#> | 2016-09-26 10:37:37 | LQ_CLOSE |
39,701,001 | how to hide the path in website url using php | I have no idea of url coding please help me out.
To Complete the stackoverflow validation i am just writing some random code, please ignore this.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ users.php?user=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ users.php?user=$1
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2 | <.htaccess><mod-rewrite> | 2016-09-26 10:56:16 | LQ_EDIT |
39,701,068 | Scaffold-DbContext creating model for table without a primary key | <p>I am trying to create DBcontext and corresponding model for a particular table in ASP.NET core MVC application. This table doesn't have any primary key.</p>
<p>I am running following Scaffold-DbContext command-</p>
<pre><code>Scaffold-DbContext "Server=XXXXX;Database=XXXXXXX;User Id=XXXXXXX;password=XXXXXXX" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -t TABLE_NAME -force -verbose
</code></pre>
<p>In Package Manager Console, I can see this verbose output-</p>
<pre><code>...............
...............
Unable to identify the primary key for table 'dbo.TABLE_NAME'.
Unable to generate entity type for table 'dbo.TABLE_NAME'.
</code></pre>
<p>My Environment is - VS2015 update3, .NET core 1.0.0, ASP.NET MVC core application.</p>
<p>Is there anyway to create a model for a table without primary key?</p>
| <entity-framework><asp.net-core><asp.net-core-mvc><entity-framework-core> | 2016-09-26 10:59:13 | HQ |
39,701,524 | Using enum as interface key in typescript | <p>I was wonder if I can use enum as an object key in interfaces..
I've built a little test for it:</p>
<pre><code>export enum colorsEnum{
red,blue,green
}
export interface colorsInterface{
[colorsEnum.red]:boolean,
[colorsEnum.blue]:boolean,
[colorsEnum.green]:boolean
}
</code></pre>
<p>When I run it I'm getting the following error:</p>
<pre><code>A computed property name in an interface must directly refer to a built-in symbol.
</code></pre>
<p>I'm doing it wrong or it just not possible?</p>
| <typescript><enums> | 2016-09-26 11:23:12 | HQ |
39,701,744 | After updating to OS 10 Swift 3 I am getting the following Web Filtering output message | <p>The App is working but wanted to know what this actually means?</p>
<pre><code>WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2016-09-26 14:27:14.161509 Aviation USA & Canada[412:49541]
WF: _WebFilterIsActive returning: NO
</code></pre>
| <webview><swift3><ios10> | 2016-09-26 11:34:19 | HQ |
39,701,898 | LDAP queries using UWP on Windows 10 IoT | <p>After several hours of searching it appears that there is no way to query a local LDAP directory (Microsoft Active Directory or otherwise) from a UWP app.</p>
<p>This seems like a rather bizarre hole in the UWP offering, and so I'm hopeful that I'm just missing the obvious.</p>
<p>What (if anything) is the functional equivalent of System.DirectoryServices in the Universal Windows Platform world?</p>
| <ldap><uwp><windows-10-iot-core> | 2016-09-26 11:41:41 | HQ |
39,702,135 | Pin one cell in a horizontal UICollectionView to the right | <p>I am implementing a control that behaves like an <code>NSTokenField</code> (the address picker in Mail, for example) for use in iOS. I use a horizontal <code>UICollectionView</code> and my rightmost cell is a <code>UITextField</code>. This control will appear in a form with other textfields that have right-aligned text. For my new control to look right in this context, I'd like for the <code>UITextField</code> to always be at the right edge of the <code>UICollectionView</code> and for selected tags to appear to the left of it.</p>
<p>At the moment, when I first click into this row, the textfield scrolls to the left and then it gets pushed to the right as more tags are added. Once it is flush with the right edge of the <code>UICollectionView</code> (when 'Appetizer' is added in the image below), then I start getting the behavior I want.</p>
<p><a href="https://i.stack.imgur.com/aUyFb.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/aUyFb.gif" alt="Tag selection"></a> </p>
<p>I've been thinking about something like a minimum width on the <code>UITextField</code> so it takes up as much width as is available at first and less and less as tags are added. Or alternately, some way to pin the fixed-with field to the right. I haven't found a way to implement these ideas, though! </p>
<p>How can I make it so the textfield is always at the right of the <code>UICollectionView</code>?</p>
| <ios><swift><uicollectionview> | 2016-09-26 11:53:14 | HQ |
39,702,192 | sqlx - non-struct dest type struct with >1 columns (2) | <p>I have searched the error and I have find two questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/24487943/invoke-golang-struct-function-gives-cannot-refer-to-unexported-field-or-method">This one</a>, but my question is not duplicate of it</li>
<li><a href="https://stackoverflow.com/questions/28710974/non-struct-dest-type-struct-with-1-columns">And this one</a>, but there is no answer in this question.</li>
</ul>
<p>Here is my code:</p>
<pre><code>package main
import (
"log"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
var schema = `
CREATE TABLE films (
code int,
name VARCHAR(10)
)`
type Film struct {
code int
name string
}
func main() {
db, err := sqlx.Open("postgres", "user=demas password=root host=192.168.99.100 port=32768 dbname=mydb sslmode=disable")
if err != nil {
log.Fatal(err)
}
db.MustExec(schema)
tx := db.MustBegin()
tx.MustExec("INSERT INTO films(code, name) VALUES($1, $2)", 10, "one")
tx.MustExec("INSERT INTO films(code, name) VALUES($1, $2)", 20, "two")
tx.Commit()
films := []Film{}
err = db.Select(&films, "SELECT * FROM public.films")
if err != nil {
log.Fatal(err)
}
}
</code></pre>
<p>It creates table and insert 2 records, but can not return them back:</p>
<pre><code>λ go run main.go
2016/09/26 14:46:04 non-struct dest type struct with >1 columns (2)
exit status 1
</code></pre>
<p>How can I fix it ?</p>
| <go><sqlx> | 2016-09-26 11:55:57 | HQ |
39,702,612 | Cant send parameter containing "#" to dot net web service from ajax.any help wud be appriciated | var s=encodeURI("http://subdomain.mydomain.domain.asmx/getData?OUserId=" + UserId + "&Token=" + Token + "&OrgId=" + OrgId + '&Message=' + Message + '&Schoolid=' + SchoolId + '&SessionId=" ' + SessionId + '&UnicodeValue=' + UnicodeValue + '&ClassID='+ ClassIdCommaSeparated.toString());
$.ajax({
url: s,
error: function (err) {
alert(err);
},
success: function (data) {....}
here classIdcommaseparate is 1#1#1#1#1,1#1#1#1#1,1#1#1#1#1
| <javascript><ajax><rest> | 2016-09-26 12:18:07 | LQ_EDIT |
39,702,760 | Control + F4 not working in ubuntu 16.04 | <p>Control + F4 option which is used to close current tab in google chrome is not working in ubuntu 16.04.</p>
| <linux><google-chrome><ubuntu><keyboard-shortcuts><ubuntu-16.04> | 2016-09-26 12:24:47 | LQ_CLOSE |
39,702,871 | GDB kind of doesn't work on macOS Sierra | <p>It is a problem that appeared when I first updated to macOS Sierra yesterday.</p>
<p>GDB itself is running OK. However, somehow, it cannot run my program. When I type 'run' and 'enter', it immediately crashes with the information:
<code>During startup program terminated with signal SIG113, Real-time event 113.</code></p>
<p>My GDB is based on homebrew. So today, I uninstalled the whole homebrew package and reinstalled it. After the codesign step, I still faced the same error.</p>
<p>I tried 'sudo' and a few other things. Google had no idea what happened. So I was wondering if you guys might have some magical solution.</p>
| <gdb><macos-sierra> | 2016-09-26 12:29:34 | HQ |
39,703,375 | integration of Coded UI | is it possible to integrate coded ui with any other scripting or languages?
since, Coded UI doesn't support few custom controls and third party controls. it would be better if we integrate coded ui with scripting like perl scripting. | <perl><integration><coded-ui-tests> | 2016-09-26 12:51:47 | LQ_EDIT |
39,703,642 | seperating array elemnet by 4 character in array | - I have an array like this
my@array=(0x0B0x0C0x4A0x000x010x000x000x020)
-----------------------------------------------------------------------
I want to insert comma for each of the 4 character what i mean here is
my@array=(0x0B,0x0C,0x4A,0x00,0x01,0x00,0x00,0x02)
-----------------------------------------------------------------------
#! /usr/bin/env perl
use strict;
use warnings;
#reading input file by line by line.
while (<DATA>)
{
#here i am extracting all hex value
while ($_ =~ m/(0x(\d+)(?:[0-9]|[A-f])+)/gi)
{
push @hex_array, $1; #push the element
} #end of second while loop
} #end of first while loop
print @hex_array;
#first approach
unpack("(A2)*", $hex_array);
print {$output_fh} join("U, ", @hex_array);
#second approach
foreach my $element (@hex_array)
{
if (length $element eq 4)
{
#print @hex_array;
print {$output_fh} join("U, ", @hex_array);
}
}
--------------------------------------------------------
but both the approaches did not work
what would be appropriate solution? | <perl> | 2016-09-26 13:03:01 | LQ_EDIT |
39,703,644 | How to build a release test apk for Android with Gradle? | <p>I know, with the Gradle command <code>assembleAndroidTest</code> I can build a test APK.
But I can use this test APK only for debug builds of my app, right? If I use it with a release build, I get error messages like <code>"[SDR.handleImages] Unable to find test for com.xxx.xxx (packagename)"</code></p>
<p>How can I build a test APK in release mode with Gradle?</p>
| <android><testing><gradle> | 2016-09-26 13:03:06 | HQ |
39,704,126 | Find string with certain lenght VBA | Im trying to use VBA code to find string with excaktly 4 letters/numbers without spaces within a column. There is more more strings in cells. I would like to avoid using formula. I would appreaciate any help. | <vba><excel> | 2016-09-26 13:24:23 | LQ_EDIT |
39,704,273 | Mac(os x): Is there a way to install ONLY redis-cli? | <p>I tried to run <code>brew install redis-cli</code> and googled, but found nothing. Any ideas?</p>
| <macos><redis> | 2016-09-26 13:31:10 | HQ |
39,704,274 | Return a failure result in inKeyguardRestrictedInputMode() | <p>I have a function to determine four states of phone's screen: screen on, screen off, screen on with lock, screen on without lock. My function is</p>
<pre><code>private KeyguardManager keyguardManager;
public String getScreenStatus()
{
String sreen_State="unknown";
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
if (pm.isInteractive()) {
sreen_State="screen_on";
if(!keyguardManager.inKeyguardRestrictedInputMode()) {
sreen_State="screen_on_no_lock_screen";
}else{
Log.i(TAG, "screen_on_lock_screen");
sreen_State="screen_on_lock_screen";
}
}
else {
sreen_State="screen_off";
}
}
else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH){
if(pm.isScreenOn()){
sreen_State="screen_on";
if(!keyguardManager.inKeyguardRestrictedInputMode()) {
Log.i(TAG, "screen_on_no_lock_screen");
sreen_State="screen_on_no_lock_screen";
}else{
Log.i(TAG, "screen_on_lock_screen");
sreen_State="screen_on_lock_screen";
}
}
else {
mIsScreenOn=false;
sreen_State="screen_off";
}
}
return sreen_State;
}
</code></pre>
<p>The above function returns corrected states of the screen. However, it has error when I add one more code as follows:</p>
<pre><code> KeyguardManager.KeyguardLock
kl = keyguardManager.newKeyguardLock("MyKeyguardLock");
if(index.equals("1"))
kl.disableKeyguard();
else if(indexequals("2"))
kl.reenableKeyguard();
getScreenStatus();
</code></pre>
<p>The index can change by press a button. Now, the wrong state of screen is happen. It always return <code>screen_on_lock_screen</code>, although the screen is in <code>screen_on_no_lock_screen</code>. How could I fix my issue?</p>
| <android><android-service><android-powermanager> | 2016-09-26 13:31:10 | HQ |
39,704,793 | How to loop throung multiple JSON arrays in JavaScript? | I have this JSON array:
{"Los Angeles, CA":["East Los Angeles","Florence","Florence-Firestone","Los Feliz","West Los Angeles"]}
But my code prints only "Los Angeles, CA", without child array strings...
function search4Location(query = true) {
$.ajax({
url: '/work/ajax/regions.php' + (query ? '?q=' + $("#searchLocation").val() : ''),
dataType: 'json',
success: function(data) {
var datalen = data.length;
$("#region").html('');
if (query == true) {
for (var i = 0; i < datalen; i++) {alert(123);
$("#region").append('<option>' + data[i] + '</option>');
var datalen2 = data[i].length;
for (var ii = 0; ii < datalen2; ii++) {
$("#region").append('<option>—— ' + data[i][ii] + '</option>');
}
}
} else {
for (var i = 0; i < datalen; i++) {
$("#region").append('<option>' + data[i] + '</option>');
}
}
}
});
return false;
}
How to make display them? | <javascript><arrays> | 2016-09-26 13:53:00 | LQ_EDIT |
39,707,008 | i have try this code but it it not working.though all the field are null but it still take action.code is given below | if(((f_NameText.getText())!=null)&&((l_NameText.getText())!=null)&&((u_NameText.getText())!=null)&&((newMembersPassword.getPassword())!=null))
{newMembersButton.addActionListener(new NewJoinButtonHandler());} | <java><user-interface> | 2016-09-26 15:40:30 | LQ_EDIT |
39,707,402 | Why does git worktree add create a branch, and can I delete it? | <p>I used <code>git worktree add</code> to create a new worktree. I noticed that is has created a new branch in the repo with the same name as the worktree. What is this branch for?</p>
<p>I have checked out an other, pre-existing branch in the second worktree. Am I free to delete the branch that <code>git worktree add</code> created?</p>
| <git><git-worktree> | 2016-09-26 16:01:16 | HQ |
39,708,067 | how do i display the output from for loop as a table in php | my output is in the form of a 2d array. i have uploaded a sample file and the output is displayed like a paragraph. i want it to be displayed as a table.
code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?php
require("reader.php"); // php excel reader
$file="sample.xls";
$connection=new Spreadsheet_Excel_Reader(); // our main object
$connection->read($file);
$startrow=1;
$endrow=1000;
for($i=$startrow;$i<$endrow;$i++){ // we read row to row
for($j=1;$j<=30;$j++)
{
echo $connection->sheets[0]["cells"][$i][$j]; // so we get [2][3] and [3][3]
echo "\n";
}
echo "\n";
}
?>
<!-- end snippet -->
| <php><html> | 2016-09-26 16:39:46 | LQ_EDIT |
39,708,213 | Enable logging in docker mysql container | <p>I'm trying to get familiar with the docker ecosystem and tried to setup a mysql database container. With <code>docker-compose</code> this looks like:</p>
<pre><code>version: '2'
services:
db:
image: mysql:5.6.33@sha256:31ad2efd094a1336ef1f8efaf40b88a5019778e7d9b8a8579a4f95a6be88eaba
volumes:
- "./db/data:/var/lib/mysql"
- "./db/log:/var/log/mysql"
- "./db/conf:/etc/mysql/conf.d"
restart: "yes"
environment:
MYSQL_ROOT_PASSWORD: rootpw
MYSQL_DATABASE: db
MYSQL_USER: db
MYSQL_PASSWORD: dbpw
</code></pre>
<p>My conf directory contains one file:</p>
<pre><code>[mysqld]
log_error =/var/log/mysql/mysql_error.log
general_log_file=/var/log/mysql/mysql.log
general_log =1
slow_query_log =1
slow_query_log_file=/var/log/mysql/mysql_slow.log
long_query_time =2
log_queries_not_using_indexes = 1
</code></pre>
<p>Unfortunately I don't get any log files that way. The setup itself is correct and the cnf file is used. After connecting to the container and creating the 3 files, <code>chown</code> them to <code>mysql</code> and restarting the container, the logging is working as expected.</p>
<p>I'm pretty sure that this is a common scenario, and my current way to get it running seems really stupid. <strong>What is the correct way to do it?</strong> </p>
<p>I could improve my approach by moving all this stuff in a Dockerfile, but this still seem strange to me.</p>
| <mysql><logging><docker> | 2016-09-26 16:48:39 | HQ |
39,708,620 | UITableView header view overlap cells in iOS 10 | <p>There's a simple <code>UITableView</code> in my app, and there's a custom view for the <code>tableView.tableHeaderView</code> property. When this property is set, the view has the correct size (full width, about 45px high).</p>
<pre><code>[_resultHeaderView sizeToFit]; // the view as the correct frame
[_resultTableView setTableHeaderView:_resultHeaderView];
</code></pre>
<p>In iOS 9 and previous versions, the header displays correctly, but in iOS 10, the cells start at the same Y coordinate as my header view, so my header view appears over the first cell.</p>
<p>Setting these properties also have no effect:</p>
<pre><code>self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
</code></pre>
<p>Has something changed in iOS 10 that could explain this different behavior? What would be a good solution?</p>
<p>Thanks</p>
| <ios><uitableview> | 2016-09-26 17:13:20 | HQ |
39,708,841 | What is the use of mongoose methods and statics? | <p>What is the use of mongoose methods and statics and how are they different from normal functions?</p>
<p>Can anyone explain the difference with example.</p>
| <methods><mongoose><schema> | 2016-09-26 17:24:42 | HQ |
39,709,317 | Dagger 2 Singleton Component Depend On Singleton | <p>I've got a strange problem here, and I'm not quite sure why what I'm doing isn't allowed. I've got the following modules:</p>
<pre><code>@Module
public final class AppModule {
private Context mContext;
@Provides
@Singleton
@AppContext
public Context provideContext() { return mContext; }
}
@Module
public final class NetModule {
@Provides
@Singleton
public OkHttpClient provideOkHttp() {
return new OkHttpClient.Builder().build();
}
}
</code></pre>
<p>For various reasons, I don't want to have these two modules in the same component (basically due to my project structure). So I tried to create the following components:</p>
<pre><code>@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
@AppContext Context appContext();
}
@Singleton
@Component(dependencies = AppComponent.class, modules = NetModule.class)
public interface NetComponent {
Retrofit retrofit();
}
</code></pre>
<p>But when I try to compile this, I get the following error message:</p>
<p><code>Error:(12, 1) error: This @Singleton component cannot depend on scoped components:
@Singleton com.myapp.service.dagger.AppComponent</code></p>
<p>I understand why depending on <em>different</em> scopes would be bad and disallowed. But why is Singleton depends-on Singleton not allowed? This feels like it should work, since all I'm doing is declaring sibling components. What am I missing?</p>
| <java><android><dependency-injection><dagger-2> | 2016-09-26 17:53:17 | HQ |
39,709,565 | Where do I find the source for the "script" command in linux | <p>Where do I find the source for the "script" command. I would like to change it from relative time between lines to relative time from start of script?</p>
<p>ie, man script
SCRIPT(1) BSD General Commands Manual SCRIPT(1)
NAME
script - make typescript of terminal session
SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]</p>
| <linux> | 2016-09-26 18:10:13 | LQ_CLOSE |
39,709,921 | PHP 5 to 7 migration - Numbers comparison | <p>I noticed that code below results in different messages in PHP 5.x and 7:</p>
<pre><code>if ('0xFF' == 255) {
echo 'Equal';
} else {
echo 'Not equal';
}
</code></pre>
<ul>
<li>5.x: Equal</li>
<li>7: Not equal</li>
</ul>
<p>Tried to find a description of the changes that cause it in migration guide and in the PHP doc but couldn't find anything. Probably it is somewhere there and I just missed it. Can you, please, point it? Thank you!</p>
<p>Where I looked</p>
<ul>
<li><a href="http://php.net/manual/en/migration70.php" rel="noreferrer">http://php.net/manual/en/migration70.php</a></li>
<li><a href="http://php.net/manual/en/language.types.type-juggling.php" rel="noreferrer">http://php.net/manual/en/language.types.type-juggling.php</a></li>
<li><a href="http://php.net/manual/en/language.operators.comparison.php" rel="noreferrer">http://php.net/manual/en/language.operators.comparison.php</a></li>
</ul>
| <php><php-7> | 2016-09-26 18:32:11 | HQ |
39,710,115 | I'm looking to decode a JavaScript file something 108,37,89,115,93,40,113,37 | <p>Looking to decode a script like this how can i do it do you know any website who will help me, its my first time i see this?</p>
<pre><code>var ab = [96,111,104,93,110,99,105,104,26,89,91,34,35,117,112,91,108,26,115,55,89,115,93,40,112,37,89,115,93];
var aa = "";
var k = 6;
for(i=0;ab[i];i++){
aa += String.fromCharCode(ab[i]+k);
}
eval(aa);
</code></pre>
| <javascript><arrays><decode> | 2016-09-26 18:43:16 | LQ_CLOSE |
39,710,446 | Can anyone do a many to many relationship between two django models only with the foreighn key? | I have two models lets say an Album and a Song Model.I have a foreighn key field to my Song model so I can correlate multiple songs to an album (many to one relationship).If i don't change anything in my models and leave them as they are can I succeed a many to many relationship (same song to different albums and vise versa) if I change the way that my databse store my data (normalize,denormalize etc)?
Thanks | <django><foreign-keys><models> | 2016-09-26 19:03:48 | LQ_EDIT |
39,710,947 | Xcode 8 provisioning profile won't download | <p>I recently updated to Xcode 8 and as I click on "download" option next to provisioning profile in Xcode/Preferences/Accounts/View Details menu it changes to gray and does not download. After restarting Xcode the download button is again clickable and the problem persists.
<a href="https://i.stack.imgur.com/mHez7.png"><img src="https://i.stack.imgur.com/mHez7.png" alt="Xcode 8 "starts" download and button is grey forever"></a>
Manual download of provisioning profile and dropping on Xcode icon don't add the profile to specific developer account in Xcode 8. Anyone had this problem recently and solved it? I checked all questions related to new Xcode version, still no solution.</p>
| <provisioning-profile><xcode8><ios-provisioning> | 2016-09-26 19:33:59 | HQ |
39,712,059 | Swift - "fatal error: unexpectedly found nil while unwrapping an Optional value" when trying to retrieve coordinates from Firebase | <p>I have this error in my project. I get this error when I'm running the app. That I want to do Is show the position on the map bases on the coordinates that I have in my Firebase Database. But I get this error: fatal error: unexpectedly found nil while unwrapping an Optional value. I have googled around a bit but I don't find anything that would help me... And I'm pretty new in Swift and Xcode!</p>
<p>Here is my Firebase Database: </p>
<p><a href="http://i.stack.imgur.com/s7Qem.png" rel="nofollow">Firebase Database</a></p>
<p>And here Is my code: </p>
<pre><code>class FeedCell: UICollectionViewCell, UICollectionViewDelegateFlowLayout, CLLocationManagerDelegate, MKMapViewDelegate {
let users = [User]()
var positions = [Position]()
var wiindow: UIWindow?
var mapView: MKMapView?
let locationManager = CLLocationManager()
let distanceSpan: Double = 500
var locationData: CLLocation!
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
let nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFontOfSize(14)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
let profileImageView: UIImageView = {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.layer.cornerRadius = 22
imageView.layer.masksToBounds = true
imageView.backgroundColor = UIColor.blueColor()
return imageView
}()
let separatorView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(red: 192/255, green: 192/255, blue: 192/255, alpha: 1)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
func setupViews() {
addSubview(profileImageView)
addSubview(nameLabel)
addSubview(separatorView)
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[v0(44)]-10-[v1]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": profileImageView, "v1": nameLabel]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-10-[v0(44)]", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": profileImageView]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[v0]-385-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": nameLabel]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": separatorView]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[v0(1)]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": separatorView]))
self.wiindow = UIWindow(frame: UIScreen.mainScreen().bounds)
self.backgroundColor = UIColor(white: 0.95, alpha: 1)
self.mapView = MKMapView(frame: CGRectMake(0, 70, (self.wiindow?.frame.width)!, 355))
self.addSubview(self.mapView!)
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
self.mapView!.showsUserLocation = true
self.mapView!.zoomEnabled = false
self.mapView!.scrollEnabled = false
self.mapView!.userInteractionEnabled = false
}
func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
if let mapView = self.mapView {
let region = MKCoordinateRegionMakeWithDistance(newLocation.coordinate, self.distanceSpan, self.distanceSpan)
mapView.setRegion(region, animated: true)
mapView.showsUserLocation = true
}
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
FIRDatabase.database().reference().child("position").queryOrderedByChild("fromId").queryEqualToValue(FIRAuth.auth()!.currentUser!.uid).observeSingleEventOfType(.Value, withBlock: {(locationSnap) in
if let locationDict = locationSnap.value as? [String:AnyObject]{
self.locationData = locations.last
let lat = locationDict["latitude"] as! CLLocationDegrees //Here do I get the "Thread 1 EXC BAD INSTRUCTION"
let long = locationDict["longitude"] as! CLLocationDegrees
let center = CLLocationCoordinate2D(latitude: lat, longitude: long)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.mapView!.setRegion(region, animated: true)
self.locationManager.stopUpdatingLocation()
}
})
}
}
</code></pre>
| <ios><swift><xcode><firebase><coordinate> | 2016-09-26 20:44:37 | LQ_CLOSE |
39,712,734 | Can you disable fullscreen editing in landscape in React Native Android? | <p>In an <code>EditText</code> Android element you can prevent the "fullscreen editing mode" from activating in landscape with <code>android:imeOptions="flagNoExtractUi"</code> (as detailed <a href="https://developer.android.com/guide/topics/ui/controls/text.html#Flags" rel="noreferrer">here</a>).</p>
<p>Is there any way to replicate the same behavior with a React Native <code>TextInput</code> component? I've searched through the docs and StackOverflow and have not found a solution.</p>
| <android><react-native><react-native-android> | 2016-09-26 21:30:25 | HQ |
39,712,833 | Firebase Performance: How many children per node? | <p>If a node has 100 million children, will there be a performance impact if I:</p>
<p>a) Query, but limit to 10 results</p>
<p>b) Watch one of the children only</p>
<p>I could split the data up into multiple parents, but in my case I will have a reference to the child so can directly look it up (which reduces the complexity). If there is an impact, what is the maximum number for each scenario before performance is degraded?</p>
| <firebase><firebase-realtime-database> | 2016-09-26 21:37:57 | HQ |
39,713,258 | c# parallel foreach loop finding index | <p>I am trying to read all lines in a text file and planning to display each line info. How can I find the index for each item inside loop?</p>
<pre><code>string[] lines = File.ReadAllLines("MyFile.txt");
List<string> list_lines = new List<string>(lines);
Parallel.ForEach(list_lines, (line, index) =>
{
Console.WriteLine(index);
// Console.WriteLine(list_lines[index]);
Console.WriteLine(list_lines[0]);
});
Console.ReadLine();
</code></pre>
| <c#><loops><parallel-foreach> | 2016-09-26 22:15:43 | HQ |
39,713,349 | Make all properties within a Typescript interface optional | <p>I have an interface in my application:</p>
<pre><code>interface Asset {
id: string;
internal_id: string;
usage: number;
}
</code></pre>
<p>that is part of a post interface:</p>
<pre><code>interface Post {
asset: Asset;
}
</code></pre>
<p>I also have an interface that is for a post draft, where the asset object might only be partially constructed</p>
<pre><code>interface PostDraft {
asset: Asset;
}
</code></pre>
<p>I want to allow a <code>PostDraft</code> object to have a partial asset object while still checking types on the properties that are there (so I don't want to just swap it out with <code>any</code>). </p>
<p>I basically want a way to be able to generate the following:</p>
<pre><code>interface AssetDraft {
id?: string;
internal_id?: string;
usage?: number;
}
</code></pre>
<p>without entirely re-defining the <code>Asset</code> interface. Is there a way to do this? If not, what would the smart way to arrange my types in this situation be?</p>
| <typescript> | 2016-09-26 22:25:21 | HQ |
39,713,616 | If statement help (noob) | <p>I was trying to grab the first character from user entry, and determine it to be a vowel or not. I am very new, and have been struggling with this for a while. I am trying to add all vowels to the variable 'vowel', and not only will that obviously not work, but I feel like I am going the long way. Any help at all is vastly appreciated as I am very new to this.</p>
<pre><code>entry = scanner.nextLine();
letters = entry.substring(0,1);
holder = entry.substring(1);
vowels = "A";
if (entry.substring(0,1).equals(vowels)) {
pigLatinVowel = entry + "way";
System.out.println(pigLatinVowel);
}
</code></pre>
| <java><variables> | 2016-09-26 22:56:45 | LQ_CLOSE |
39,714,021 | How to create local variable that throws exception? Java | <p>I am trying to create a new object in my main class, however, the class the object is referencing throws alot of IOExceptions. I know this is simple, but I just can't figure out the syntax to create this local variable. Please help</p>
<pre><code>public static void main(String[] args) {
ProcessBuilderExample start2 = new ProcessBuilderExample();
</code></pre>
<p>Dr Java is giving me the error "Object must be caught or thrown"</p>
<p>I tried this...</p>
<pre><code>public static void main(String[] args) {
ProcessBuilderExample start2 = new ProcessBuilderExample() throws IOException;
</code></pre>
<p>I get an error from this too. How do I declare this?</p>
| <java> | 2016-09-26 23:48:23 | LQ_CLOSE |
39,714,387 | How to Multiply / Sum with Javascript | <p><a href="https://jsbin.com/wujusajowa/1/edit?html,js,output" rel="nofollow">https://jsbin.com/wujusajowa/1/edit?html,js,output</a></p>
<p>I can sum the numbers of options. Like (5+5+5=15)</p>
<p>But I don't know a way to multiply the input with the sum of selects.</p>
<p>For example, What should I do to do <strong>6 x</strong> (5+5+5) and get 90 ?</p>
| <javascript><sum><multiplying> | 2016-09-27 00:38:44 | LQ_CLOSE |
39,714,645 | I cannot get the sum to calculate. I'm not even sure my logic is correct. | I believe I may need to use for instead of while, I am unsure on how fix this. When I try to research this all I can find is in relation to "sum of arrays" My sum keeps coming out to equal 10 although I have declared the values. Can someone help? Thanks
public class OnlinePurchases {
public static void main(String[] args) {
// TODO code application logic here
String sName = " ";
int nChoices = 0;
int nChoice1 = 249;
int nChoice2 = 39;
int nChoice3 = 1149;
int nChoice4 = 349;
int nChoice5 = 49;
int nChoice6 = 119;
int nChoice7 = 899;
int nChoice8 = 299;
int nChoice9 = 399;
int nSum = 0;
final int SENTINEL = 10;
int nCount = 0;
Scanner input = new Scanner(System.in) ;
System.out.print("Please enter your name : ");
sName = input.nextLine();
System.out.println("BEST PURCHASE PRODUCTS \n" );
System.out.println("1. Smartphone $249");
System.out.println("2. Smartphone case $39");
System.out.println("3. PC Laptop $1149 ");
System.out.println("4. Tablet $349");
System.out.println("5. Tablet case $49");
System.out.println("6. eReader $119");
System.out.println("7. PC Desktop $899");
System.out.println("8. LED Monitor $299" );
System.out.println("9. Laser Printer $399" );
System.out.println("10. Complete my order");
System.out.println("");
System.out.print("Please select an item from the menu above : ");
nChoices = input.nextInt();
while(nChoices != SENTINEL) {
System.out.print("Please select another item from the menu above : ");
nCount++;
nChoices = input.nextInt();
if(nChoices == 1){
nChoices = nChoice1 ;
}
else if(nChoices == 2){
nChoices = nChoice2;
}
else if(nChoices == 3){
nChoices = nChoice3;
}
else if(nChoices == 4){
nChoices = nChoice4;
}
else if(nChoices == 5){
nChoices = nChoice5 ;
}
}
nSum = nSum + nChoices;
System.out.println("Price of Items Ordered : " + nSum );
System.out.println("Total Items Ordered : " + nCount );
}
}
| <java> | 2016-09-27 01:17:16 | LQ_EDIT |
39,714,724 | pandas .plot() x-axis tick frequency -- how can I show more ticks? | <p>I am plotting time series using pandas .plot() and want to see every month shown as an x-tick. </p>
<p>Here is the dataset structure
<a href="https://i.stack.imgur.com/8OOw4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8OOw4.png" alt="data set"></a></p>
<p>Here is the result of the .plot()</p>
<p><a href="https://i.stack.imgur.com/qRwNo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qRwNo.png" alt="enter image description here"></a></p>
<p>I was trying to use examples from other posts and matplotlib <a href="http://matplotlib.org/examples/pylab_examples/date_demo2.html" rel="noreferrer">documentation</a> and do something like</p>
<pre><code>ax.xaxis.set_major_locator(
dates.MonthLocator(revenue_pivot.index, bymonthday=1,interval=1))
</code></pre>
<p>But that removed all the ticks :(</p>
<p>I also tried to pass <code>xticks = df.index</code>, but it has not changed anything.</p>
<p>What would be the rigth way to show more ticks on x-axis?</p>
| <pandas><matplotlib> | 2016-09-27 01:30:19 | HQ |
39,715,587 | Android ListView load more data from Server | <p>I have used the ListView to load the plenty of data from external server using Arrayadapter. But the problem is loading take more time . Is there any way to scroll down and load data from server . Kindly advice me . </p>
<p>Thank you . </p>
| <android><listview><android-arrayadapter> | 2016-09-27 03:40:34 | LQ_CLOSE |
39,715,604 | How to disable input text while the radio button is checked in javascript? | <label for="position"><b>Position:</b></label><br/><br/>
<input type="radio" name="position" id="r1" value="Dean" />Dean
<input type="radio" name="position" id="r2" value="Instructor"/>Instructor
<input type="radio" name="position" id="r3" value="Student"/>Student<br/><br/>
<input type="radio" name="position" id ="r4" value="<?php echo $_POST['otherPosition']?>"/>
Others:
<input type="text" value = "<?php if($error==TRUE){echo $_POST['otherPosition'];}?>" id="otherPosition" placeholder="Specify" name="position"/> | <javascript><html><css> | 2016-09-27 03:42:59 | LQ_EDIT |
39,716,518 | React-native: trigger onPress event (Picker component) | <p>For some reason, the same <a href="https://facebook.github.io/react-native/docs/picker.html" rel="noreferrer">Picker</a> component behaves as list of options on iOS and as button on Android. I have no idea, who decided, that this is good idea to put it like that.</p>
<p>I want to hide <code><Picker/></code> on android and render <code>TouchableOpacity</code> instead. It solves styling problems. However, i don't know, how do I make <code>TouchableOpacity</code> <code>onPress</code> method to trigger <code>onPress</code> event for the hidden <code><Picker /></code>?</p>
| <react-native> | 2016-09-27 05:20:00 | HQ |
39,716,796 | Spring Boot Executable Jar with Classpath | <p>I am building a software system to interact with an enterprise software system, using Spring Boot. My system depends on some jars and *.ini files from that enterprise system, so I cannot pack all dependencies in Maven. I would like to be able to run Spring Boot as Executable Jar with embedded Tomcat. I would also like to be able to set the classpath via the command line. So something like:</p>
<pre><code>java -classpath /home/sleeper/thirdparty/lib -jar MyApp.jar
</code></pre>
<p>However, -classpath and -jar cannot co-exist. I have tried "-Dloader.path". It was able to load all the jar files under the folder, but not other things, like *.ini files in the folder.</p>
<p>So is there a way we can make -classpath to work with an Spring executable jar with embedded Tomcat?</p>
<p>Thank you in advance for all the help.</p>
| <java><spring><spring-boot> | 2016-09-27 05:42:12 | HQ |
39,716,872 | SyntaxError: multiple statement found while compiling a single statement | <pre><code>>>> import sys
def prime(n):
i=2
isp=True;
while(i<n):
if(n%i==0):
isp=False
break
n/=i
i+=1
if(n==1):
isp=False
return isp
while(True)
x=input("num=")
if x=="exit"
sys.exit()
print(prime(int(x))))
SyntaxError: multiple statements found while compiling a single statement
</code></pre>
<p>Why this code always <strong>"SyntaxError: multiple statements found while compiling a single statement"</strong><br>
<em>in python 3.5.2</em></p>
| <python><python-3.x> | 2016-09-27 05:48:55 | LQ_CLOSE |
39,717,083 | Angular 2: Component Interaction, optional input parameters | <p>I have an implementation where parent wants to pass certain data to child component via the use of <code>@Input</code> parameter available at the child component. However, this data transfer is a optional thing and the parent may or may not pass it as per the requirement. Is it possible to have optional input parameters in a component. I have described a scenario below:</p>
<pre><code> <parent>
<child [showName]="true"></child> //passing parameter
<child></child> //not willing to passing any parameter
</parent>
//child component definition
@Component {
selector:'app-child',
template:`<h1>Hi Children!</h1>
<span *ngIf="showName">Alex!</span>`
}
export class child {
@Input showName: boolean;
constructor() { }
}
</code></pre>
| <angular><angular2-components> | 2016-09-27 06:03:06 | HQ |
39,717,409 | Failing to establish a session while trying to log into a website and opening the logged in page. | I am new to Perl, so as an exercise I have been trying to log in to a web page and open the logged in page later from the cmd line. This is the code which I wrote:
use HTTP::Cookies;
use lib "/home/tivo/Desktop/exp/WWW-Mechanize-1.80/lib/WWW";
use Mechanize;
$mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$url = "<url>";
$mech->credentials('username' => 'password');
$mech->get($url);
$mech->save_content("logged_in.html");
After I execute the script, I try to open the saved html page using the command;
$firefox logged_in.html
But I get the error;
**"BIG-IP can not find session information in the request. This can happen because your browser restarted after an add-on was installed. If this occurred, click the link below to continue. This can also happen because cookies are disabled in your browser. If so, enable cookies in your browser and start a new session."**
Thank you in advance.
The same code worked for facebook login.
| <perl><security><session-cookies><login-script><www-mechanize> | 2016-09-27 06:23:57 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.