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 |
|---|---|---|---|---|---|
34,579,243 | how to do this on bootstrap | <p>I am new in using bootstrap and I want to know how to do this in desktop size:</p>
<pre><code> -----------------------
| table1 | table2 |
----------- |
| table3 | |
----------- |
| table4 | |
-----------------------
</code></pre>
<p>Glad if you would help me.</p>
| <css><html> | 2016-01-03 17:11:23 | LQ_CLOSE |
34,579,676 | How to sum all the numbers that I entered in the console | So my code looks like this
<import java.util.Scanner;
public class homework3 {
public static void main(String[] args) {
System.out.println("Enter a positive number: ");
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
int y = 1;
int sum = 0;
int e = 2;
while (e <=i ) {
System.out.print(" " + e);
e += 2;
}
}
}
>
I'm trying to sum all of the numbers that go up to the number that's entered. | <java> | 2016-01-03 17:55:47 | LQ_EDIT |
34,579,839 | Any chance to minify this snippet of code? | Any chance to minify the snippet of code below? Something like `if (!$('body#pagina_blog_1 **TO** body#pagina_blog_10).length)....`
On-line javascript minifires tools do not help...
jQuery(function($){
if (!$('body#pagina_blog_1, body#pagina_blog_2, body#pagina_blog_3, body#pagina_blog_4, body#pagina_blog_5, body#pagina_blog_6, body#pagina_blog_7, body#pagina_blog_8, body#pagina_blog_9, body#pagina_blog_10).length) return;
// do stuff
}); | <javascript><jquery> | 2016-01-03 18:10:56 | LQ_EDIT |
34,580,136 | Facebook App Login: How to control expiration date of an image URL I got? | <p>I'm developing an app, which uses the facebook login. After login the user must set additional informations and a profile picture, with the picture being provided from that logged in facebook account as well. Now the whole account details, including the URL to that profile picture, are saved in my database.</p>
<p>To my surprise the profile picture has suddenly stopped working. Opening it's URL in a browser gives me this message "URL signature expired"</p>
<p><a href="https://scontent.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p720x720/10846350_10204966809307370_2779189783437306470_n.jpg?oh=245bbada6c23f280a1e531e724be85ed&oe=56894D69" rel="noreferrer">https://scontent.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p720x720/10846350_10204966809307370_2779189783437306470_n.jpg?oh=245bbada6c23f280a1e531e724be85ed&oe=56894D69</a></p>
<p>Downloading those photos and save them to my own server is not really an option for me. Is there anything I can do to make that URL durable?</p>
| <facebook><facebook-graph-api> | 2016-01-03 18:37:32 | HQ |
34,580,150 | How to print the following with php[preferred] or javaScript? | <p>So i was asked the following question in an interview. I was able to print the whole xxx thing. but it was not diagonal like the below one. I think it meant to have spaces prints through a loop. Can Someone please help me with this.</p>
<p>How to print the following using php or javascript?? Php would be preferred.</p>
<pre><code> xx
xxxx
xxxxxx
xxxxxxxx
xxxxxxxxxx
</code></pre>
<p>what i was able to get was</p>
<pre><code>xx
xxxx
xxxxxx
xxxxxxxx
xxxxxxxxxx
</code></pre>
<p>through php for loop.</p>
| <javascript><php> | 2016-01-03 18:38:55 | LQ_CLOSE |
34,580,166 | What codes can I use in order to make music from parse I uploaded play shuffled for an app created by Xcode in swift language? | This is what I have so far...
let query = PFQuery(className: "Genres")
//Find objects in the background
query.findObjectsInBackgroundWithBlock({
//store objects in an array
(objectsArray :[PFObject]?, error: NSError?) -> Void in
let objectIDs = objectsArray
// objects being added to array
for i in 0...objectIDs!.count-1{
// add a new element in the array
self.iDArray.append(objectIDs![i].valueForKey("objectId") as! String)
//store song name in song array
self.NameArray.append(objectIDs![i].valueForKey("SongName")as! String)
self.tableView.reloadData()
NSLog("\(objectIDs)")
}
})
}
func grabSong () {
let songQuery = PFQuery(className: "Genres")
songQuery.getObjectInBackgroundWithId(iDArray[SelectedSongNumber], block: {
(object: PFObject?, error : NSError?) -> Void in
if let audioFile = object?["SongFile"] as? PFFile {
let audioFileUrlString: String = (audioFile.url)!
let audioFileUrl = NSURL(string: audioFileUrlString)!
AudioPlayer = AVPlayer(URL: audioFileUrl)
AudioPlayer.play()
}
})
}
| <ios><arrays><swift><parse-platform><shuffle> | 2016-01-03 18:40:45 | LQ_EDIT |
34,580,415 | Cross Domain Image upload Angular+laravel | <p>I have been struggling with image upload on server. I am using <a href="https://github.com/danialfarid/ng-file-upload">ngFileUpload</a> on front end. But I always get </p>
<p>"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource"</p>
<p>Angular Code for file Upload : </p>
<pre><code> var uploadFile = function (file) {
if (file) {
if (!file.$error) {
Upload.upload({
url: baseUrl+'upload',
file: file
}).progress(function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
//console.log(evt.total);
}).success(function (data, status, headers, config) {
$timeout(function() {
console.log(data);
console.log(status);
if(status==200)
{
logo_path = data.logo_path;
}
});
});
}
}
};
</code></pre>
<p>On Laravel i have configured CORS like this : </p>
<pre><code>public function handle($request, Closure $next)
{
header("Access-Control-Allow-Origin: http://localhost:8001/");
// ALLOW OPTIONS METHOD
$headers = [
'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
'Access-Control-Allow-Headers'=> 'Content-Type, X-Auth-Token, Origin'
];
if($request->getMethod() == "OPTIONS") {
// The client-side application can set only headers allowed in Access-Control-Allow-Headers
return Response::make('OK', 200, $headers);
}
$response = $next($request);
foreach($headers as $key => $value)
$response->header($key, $value);
return $response;
}
</code></pre>
<p>The Normal cross domain POST request works fine. i.e $http.post(). I have tried many different variations of headers on angular but none helps. Also the OPTIONS request returns 200 OK but still preflight response failure message is displayed. Can anyone help me with how to further debug this issue?</p>
| <angularjs><laravel-5><cors><ng-file-upload> | 2016-01-03 19:04:10 | HQ |
34,581,270 | Understanding JavaScript Object(value) | <p>I understand that the following code wraps a number into an object:</p>
<pre><code>var x = Object(5);
</code></pre>
<p>I therefore expect and understand the following:</p>
<pre><code>alert(x == 5); //true
alert(x === 5); //false
</code></pre>
<p>However, I also understand that an object is a list of <strong>key/value pairs</strong>. So I would have expected the following to be different:</p>
<pre><code>alert(JSON.stringify(5)); //5
alert(JSON.stringify(x)); //5
</code></pre>
<p>What does the structure of x look like? And why does it not appear to be in key/value pair format?</p>
| <javascript> | 2016-01-03 20:31:45 | HQ |
34,581,961 | Android how to notify, when viewpager loads pages? | I have implemented viewpager autoscroll. But this triggers much earlier, even before the page loads/visible to user.
I want to start the autoscroll, after all the pages visible to user. Please suggest how to handle the notification, when pages visible?
Cheers
AP | <android><android-viewpager> | 2016-01-03 21:45:06 | LQ_EDIT |
34,583,073 | Angular 2 Errors and Typescript - how to debug? | <p>I've just started a project to learn Angular2 and Typescript+Javascript. I come from a Java background and my approach to debugging projects is usually a combination of stack traces, compile errors, and - on larger projects - lots of test cases. However, much of this doesn't seem to directly translate to the world of web-dev; particularly debugging my code that's interacting with Angular2's libraries.</p>
<p>Could anyone suggest any approaches that I can take to debug code working with Angular2? Specifically; how can I see what parts of my HTML/TS is causing issues? I've checked the console, from which I can see that I've broken Angular2, but it doesn't seem much more informative from that.</p>
<p>Just to clarify; I don't want help for this specific instance. I'd like to learn how to diagnose+fix these problems myself.</p>
| <debugging><web><typescript><angular> | 2016-01-03 23:59:48 | HQ |
34,583,224 | What is the right command to convert an mp3 file to the required codec version (MPEG version 2) and bit rate (48 kbps) for Amazon Alexa SSML? | <p>I am trying to convert an mp3 file to the format expected by the audio tag in the Amazon Alexa SSML markup language as described here: <a href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference">https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference</a></p>
<p>The documentation recommends using <a href="https://www.ffmpeg.org/ffmpeg.html">https://www.ffmpeg.org/ffmpeg.html</a></p>
<p>I tried this command but can't find the right codec to use:
<code>ffmpeg -y -i input.mp3 -ar 44100 -ab 48k -codec:a mpeg2 -ac 1 output.mp3</code></p>
<p>I know I need to convert the file because Alexa fails with the following error: <code>The audio is not of a supported MPEG version</code></p>
| <ffmpeg><alexa-skills-kit> | 2016-01-04 00:25:13 | HQ |
34,583,637 | Will the following code removes a relationship by setting the foreign key to 0? | I have a question about entity framework.
Will the following code removes a relationship by setting the foreign key to 0?
entity.relationEntityID = 0; | <c#><entity-framework> | 2016-01-04 01:35:47 | LQ_EDIT |
34,583,717 | Authentication (Passport) enough for security with Node js backend server? | <p>Is PassportJS using Facebook Authentication enough for an iOS backend with Node JS?</p>
<p>I have the toobusy package as well to decline requests when things get to busy (I'm guessing it would be good for DDOSes).</p>
<p>I'm thinking of using nginx as a reverse proxy to my Node.JS server as well.</p>
<p>What are some more security measures that can scale? Some advice and tips? Anything security related that I should be concerned about that PassportJS's authenticated session can't handle?</p>
| <ios><node.js><facebook><security><backend> | 2016-01-04 01:51:18 | HQ |
34,583,796 | Android @Intdef for flags how to use it | <p>I am not clear how to use @Intdef when making it a flag like this:</p>
<pre><code>@IntDef(
flag = true
value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
</code></pre>
<p>this example is straight from the <a href="http://developer.android.com/reference/android/support/annotation/IntDef.html" rel="noreferrer">docs</a>. What does this actually mean ? does it mean all of them are initially set to true ? if i do a "or" on the following:</p>
<pre><code>NAVIGATION_MODE_STANDARD | NAVIGATION_MODE_LIST
</code></pre>
<p>what does it mean ...im a little confused whats happening here. </p>
| <android><android-annotations> | 2016-01-04 02:05:29 | HQ |
34,584,356 | Add a Foreign Key in PgAdmin | <p>I have <code>studidtemplates</code> table below:</p>
<p><a href="https://i.stack.imgur.com/fSHCa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fSHCa.png" alt="enter image description here"></a></p>
<p><code>template_id</code> is the primary_key</p>
<p><a href="https://i.stack.imgur.com/JQ9vn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JQ9vn.png" alt="enter image description here"></a></p>
<p>I want to create a new table referencing <code>template_id</code> as a <code>foreign key</code>. It is named <code>studidtemplatetextelements</code>. See image below:</p>
<p><a href="https://i.stack.imgur.com/WNCk0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WNCk0.png" alt="enter image description here"></a></p>
<p>I created a column <code>template_id</code> in the second table and want to make it a foreign key referencing <code>template_id</code> in <code>studidtemplates</code> table. I did it by clicking the button in the <code>Constraints</code> tab,pointed by an arrow in the image below.</p>
<p><a href="https://i.stack.imgur.com/S2Gsh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S2Gsh.png" alt="enter image description here"></a></p>
<p>I notice something different. In 'Referencing' option there's no <code>template_id</code> option available. See image below:</p>
<p><a href="https://i.stack.imgur.com/gCkBf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gCkBf.png" alt="enter image description here"></a></p>
<p>Where am I missing?</p>
| <postgresql><foreign-keys><foreign-key-relationship><pgadmin> | 2016-01-04 03:36:13 | HQ |
34,584,578 | TypeScript + ES6 Map + Index signature of object type implicitly has an 'any' type | <p>I have the following code in TypeScript:</p>
<pre><code>export class Config
{
private options = new Map<string, string>();
constructor() {
}
public getOption(name: string): string {
return this.options[name]; // <-- This line causes the error.
}
}
</code></pre>
<p>And the compiler is giving me this error:</p>
<p><code>Error:(10, 16) TS7017: Index signature of object type implicitly has an 'any' type.</code></p>
<p>The Map is 'possible' through es6-shim. I am not quite sure what is going on here. Actually this Map confuses me a little. Map is supposed to come from es6-shim which is supposed to implement es6 functionality. But es6 doesn't have static types, right? So, why the Map expects the key/value types as generic arguments? I have seen some people adding a 'noImplicitAny' flag but I want to solve the problem, not ignore it.</p>
<p>Thank you.</p>
| <typescript><ecmascript-6><es6-shim> | 2016-01-04 04:12:47 | HQ |
34,585,362 | How to Type Cast null as Bool in C#? | <p>I'm having one null-able bool (<code>bool?</code>) variable, it holds a value null. One more variable of type pure <code>bool</code>, I tried to convert the null-able bool to bool. But I faced an error "<strong>Nullable object must have a value.</strong>"</p>
<p>My C# Code is </p>
<pre><code>bool? x = (bool?) null;
bool y = (bool)x;
</code></pre>
| <c#><casting><boolean><nullable> | 2016-01-04 05:48:35 | HQ |
34,585,453 | How to bind raw html in Angular2 | <p>I use Angular 2.0.0-beta.0 and I want to create and bind some simple HTML directly. Is is possible and how?</p>
<p>I tried to use</p>
<pre><code>{{myField}}
</code></pre>
<p>but the text in myField will get escaped.</p>
<p>For Angular 1.x i found hits for ng-bind-html, but this seems not be supported in 2.x</p>
<p>thx
Frank </p>
| <angular> | 2016-01-04 05:58:57 | HQ |
34,585,896 | the \b flag not working in javascript regrex | I am new to regular expressions and basically just playing around with them in my brower console , using MDN as a referance , i tried the below regrex:
/\bg/g.test('me building and him')
even if i try `/\bg/g` , i still get false, WHY ?
The MDN definition says the following for `\b`:
> Matches a zero-width word boundary, such as between a letter and a
> space. (Not to be confused with [\b])
>
> For example, /\bno/ matches the "no" in "at noon"; /ly\b/ matches the
> "ly" in "possibly yesterday".
So why is the `g` at the end of building not being matched ? , can anybody explain ? | <javascript><regex> | 2016-01-04 06:38:35 | LQ_EDIT |
34,586,069 | ValueError: Series lengths must match to compare when matching dates in Pandas | <p>I apologize in advance for asking such a basic question but I am stumped.</p>
<p>This is a very simple, dummy example. I'm having some issue matching dates in Pandas and I can't figure out why.</p>
<pre><code>df = pd.DataFrame([[1,'2016-01-01'],
[2,'2016-01-01'],
[3,'2016-01-02'],
[4,'2016-01-03']],
columns=['ID', 'Date'])
df['Date'] = df['Date'].astype('datetime64')
</code></pre>
<p>Say I want to match row 1 in the above df.<br>
I know beforehand that I want to match ID <code>1</code>.<br>
And I know the date I want as well, and as a matter of fact, I'll extract that date directly from row 1 of the df to make it bulletproof.</p>
<pre><code>some_id = 1
some_date = df.iloc[1:2]['Date'] # gives 2016-01-01
</code></pre>
<p>So why doesn't this line work to return me row 1??</p>
<pre><code>df[(df['ID']==some_id) & (df['Date'] == some_date)]
</code></pre>
<p>Instead I get
<code>ValueError: Series lengths must match to compare</code><br>
which I understand, and makes sense...but leaves me wondering...how else can I compare dates in pandas if I can't compare one to many?</p>
| <python><pandas> | 2016-01-04 06:52:47 | HQ |
34,586,576 | How to install cakephp3.1.6 on LAMP | I want to install cakephp3 on ubuntu14.0.4 in lamp. I put cakephp3 folder in /var/WWW/ path. When I entered `localhost/cakephp3/`in browser, something is not shown and no error is not.
what should i do??? please help me... | <php><ubuntu><cakephp><lamp><cakephp-3.x> | 2016-01-04 07:36:15 | LQ_EDIT |
34,586,698 | show alertdialog but cover the actionbar | I'm new in android and I try using alertdialog but always cover the actionbar.
how can doing something like dropdown menu like the picture shown?
I[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/dX4lF.png | <android> | 2016-01-04 07:45:17 | LQ_EDIT |
34,586,997 | SQL Update error. Instead of updating, its adding. | //for some reason it won't update, instead it will add the new data.
I am a beginner, and I have hard time trying to find out the error.
Thank you for the help.
//Read function was working very properly and insert works just fine as well. Its just the update that doesnt work properly, or inserts instead of updating the query or data.
<?php include "db.php"; ?>
<?php include "functions.php" ?>
<?php
if(isset($_POST['submit']))
{$username = $_POST['username'];
$password = $_POST['password'];
$id = $_POST['id'];
$querys = "UPDATE users SET ";
$querys .= "username = '$username', ";
$querys .= "password = '$password' ";
$querys .= "WHERE id = $id ";
$result = mysqli_query($connection, $querys);
if(!$result)
{
die('Query FAILED'. mysqli_error($connection));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css
">
</head>
<body>
<div class="container">
<div class="col-xs-6">
<form action="login_create.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" name="username" class="form-control">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<select name="id" id="">
<?php
showAllData();
?>
</select>
</div>
<input class="btn btn-primary"
type="submit" name="submit" value="Update">
</form>
</div>
</div>
</body>
</html> | <php><mysql> | 2016-01-04 08:13:15 | LQ_EDIT |
34,587,067 | Change color of react-big-calendar events | <p>I need to make a calendar with events and I decided to use <a href="http://intljusticemission.github.io/react-big-calendar/examples/index.html" rel="noreferrer">react-big-calendar</a>. But I need to make events of different colors. So each event will have some category and each category has corresponding color. How can I change the color of the event with react? <a href="https://i.stack.imgur.com/vtw4o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vtw4o.png" alt="react-big-calendar same color example"></a></p>
<p>Result should look something like this <a href="https://i.stack.imgur.com/9iKRo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9iKRo.png" alt="react-big-calendar different colors example"></a></p>
| <javascript><reactjs><calendar> | 2016-01-04 08:19:27 | HQ |
34,587,121 | Who designed monokai color scheme? | <p>I am in love with Monokai color scheme. Did the makers of Sublime Text designed it or is it in use before sublime text arrived? </p>
<p>The second part of the question is that can I freely copy it for my own editor. Does anybody holds copyright over it? </p>
| <sublimetext2><color-scheme> | 2016-01-04 08:24:21 | LQ_CLOSE |
34,587,254 | Accessing multiple controllers with same request mapping | <p>Please find my HomeController and DemoController</p>
<pre><code>class HomeController{
@RequestMapping(value="index")
public void home(){
}
}
class DemoController{
@RequestMapping(value="index")
public void demo(){
}
}
</code></pre>
<p>when I try to send a request to index, which one will get executed?
I wanted to know how can we have same request mapping value for multiple controllers</p>
| <spring><spring-mvc> | 2016-01-04 08:34:10 | HQ |
34,587,273 | android logcat logs chatty module line expire message | <p>I am getting lots of this kind of logcat messages related to my application.</p>
<p><code>11-19 19:04:23.872 3327 3440 I chatty : uid=10085 com.xxxx.yyy expire 18 lines</code></p>
<p>What are these log messages? Am I missing my actual application logcat logs here?</p>
| <android><logcat><android-logcat> | 2016-01-04 08:35:51 | HQ |
34,587,573 | Why do we use print statements while defining a function in python? Does it help in debugging? | <p>I am learning python programming and I read somewhere that many a times we use return statement without any output for the purpose of seeing the side effects. Could you explain why is that so? For eg.</p>
<pre><code>def sum(a, b)
print "enter sum!"
print "a is", a
a = a + b
print "a is", a
print sum(2, 123)
</code></pre>
<p>What is the necessity of writing a print statement here?</p>
| <python><debugging> | 2016-01-04 08:59:54 | LQ_CLOSE |
34,588,057 | Why does Shake recommend disabling idle garbage collection? | <p>In the Shake documentation it recommends compiling using the flag <code>-with-rtsopts=-I0</code> to disable idle garbage collection. Why does Shake recommend that?</p>
| <haskell><shake-build-system> | 2016-01-04 09:29:46 | HQ |
34,588,728 | Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)' | Getting an error NSInvalidArgumentException', reason: 'Invalid type in JSON write . I hope this error when i post image data string in Request.Please help
let imageData : NSData!
imageData = UIImagePNGRepresentation(first.image!)!
let base64String = imageData.base64EncodedDataWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
requestObject["pimage1"] = base64String
let jsonData = try! NSJSONSerialization.dataWithJSONObject(params, options: .PrettyPrinted)
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)' | <ios><swift> | 2016-01-04 10:10:18 | LQ_EDIT |
34,588,857 | SAML Signing Certificate - Which SSL Certificate Type? | <p>We're currently developing an SSL solution using SAML 2.0, and until now, have been using self signed certificates for signing the XML requests.</p>
<p>However, as we move to production, we want to use a certificate from a certificate authority. But I'm not really sure what type of certificate to purchase as they are all website centric. For example, single domain, wildcard domain, etc.</p>
<p>For example, have been looking at these:
<a href="https://www.123-reg.co.uk/ssl-certificates/" rel="noreferrer">https://www.123-reg.co.uk/ssl-certificates/</a></p>
<p>I'm fairly knowledgeable when it comes to purchasing SSL certificates for a website. However, as the certificate is just going to be use for signing SAML requests, does it matter which type is purchased? Surely whether it supports a single domain or wildcard domain is irrelevant?</p>
| <ssl><ssl-certificate><saml><saml-2.0> | 2016-01-04 10:16:37 | HQ |
34,588,887 | Firefox rendering my images as the wrong color - but fine in other browsers | <p>I have built a website however I am having problems with the png's in firefox as it is rendering the images as the wrong color. When I inspect the element in dev tool on firefox the images display as the right color which is what I don't understand.</p>
<p>Could someone help </p>
<p>www.forestroad.co.uk</p>
| <html><css><firefox><browser> | 2016-01-04 10:18:03 | LQ_CLOSE |
34,589,023 | Undefined index: category_icon_code in line 257 | <p>Hello I am getting Notice Undefined index: in line number 257.
Please help.
Here is code for line number 257.</p>
<pre><code>$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
global $postID;
$current++;
$category = get_the_category();
$tag = get_cat_ID( $category[0]->name );
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
if (isset($tag_extra_fields[$tag])) {
$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
$your_image_url = $tag_extra_fields[$tag]['your_image_url'];
}
if (empty($category_icon_code) || empty($category_icon_color) || empty($your_image_url)) {
$tag = $category[0]->category_parent;
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
if (isset($tag_extra_fields[$tag])) {
if (empty($category_icon_code)){
$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
}
if (empty($category_icon_color)){
$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
}
if (empty($your_image_url)){
$your_image_url = $tag_extra_fields[$tag]['your_image_url'];
}
}
}
?>
</code></pre>
<p>I am getting undefined index for these.</p>
<pre><code>$category_icon_code
$category_icon_color
$your_image_url
</code></pre>
<p>Thanks in advance.</p>
| <php><indexing><undefined> | 2016-01-04 10:25:46 | LQ_CLOSE |
34,589,033 | Trying to get property of non-object in yii | <p>I'm using yii framework and I'm new in yii and can't understand the problem in this code, it is giving error in this code and I just attached the image of my code</p>
<p><a href="https://i.stack.imgur.com/ZTANB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZTANB.png" alt="image1"></a></p>
<p>and when I just try to <code>echo '<pre>';print_r($role);echo '</pre>';</code> it just print code like this</p>
<p><a href="https://i.stack.imgur.com/Upc7A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Upc7A.png" alt="image2"></a></p>
<p>can't understand why this is giving error.</p>
| <php><mysql><yii> | 2016-01-04 10:26:20 | LQ_CLOSE |
34,589,215 | How to remove edge between two vertices? | <p>I want to remove edge between two vertices, so my code in java tinkerpop3 as below</p>
<pre><code>private void removeEdgeOfTwoVertices(Vertex fromV, Vertex toV,String edgeLabel,GraphTraversalSource g){
if(g.V(toV).inE(edgeLabel).bothV().hasId(fromV.id()).hasNext()){
List<Edge> edgeList = g.V(toV).inE(edgeLabel).toList();
for (Edge edge:edgeList){
if(edge.outVertex().id().equals(fromV.id())) {
TitanGraph().tx();
edge.remove();
TitanGraph().tx().commit();
return;//Remove edge ok, now return.
}
}
}
}
</code></pre>
<p>Is there a simpler way to remove edge between two vertices by a direct query to that edge and remove it? Thank for your help.</p>
| <titan><gremlin><tinkerpop3> | 2016-01-04 10:36:27 | HQ |
34,589,908 | Using array values in images? | <p>I have a some pictures with values of 1 - 10 E.G. img1.png, img2.png etc.</p>
<p>I also have some code that returns a number. What I would like is to have the returned number append an image.
My code is below and I can't get it to work properly. without the image it returns a normal number, but with it I get a blank return.</p>
<pre><code>$("#ext-row").append("<div class='container returnedInfo'><div class='col-md-2 wordValue'> <img src'/Content/Images/img'" + items[i].WordScore + ".png</div>
</code></pre>
<p>Hope this makes sense</p>
<p>Thanks</p>
| <javascript><jquery><html><image><append> | 2016-01-04 11:16:45 | LQ_CLOSE |
34,590,173 | Long and wide data – when to use what? | <p>I'm in the process of compiling data from different data sets into one data set for analysis. I'll be doing data exploration, trying different things to find out what regularities may be hidden in the data, so I don't currently have a specific method in mind. Now I'm wondering if I should compile my data into long or wide format.</p>
<p><strong>Which format should I use, and why?</strong></p>
<p>I understand that data can be reshaped from long to wide or vice versa, but the mere existence of this functionality implies that the need to reshape sometimes arises and this need in turn implies that a specific format might be better suited for a certain task. So when do I need which format, and why?</p>
<p>I'm not asking about performance. That has been covered in other questions.</p>
| <r><reshape><dataformat> | 2016-01-04 11:31:35 | HQ |
34,590,317 | Disable logging for one container in Docker-Compose | <p>I have a web application launched using Docker compose that I want to disable all logging for (or at the very least print it out to syslog instead of a file).</p>
<p>When my web application works it can quickly generate an 11GB log file on startup so this eats up my disk space very fast.</p>
<p>I'm aware that normal docker has <a href="https://www.sumologic.com/2015/04/16/new-docker-logging-drivers/" rel="noreferrer">logging options</a> for its run command but in Docker Compose I use </p>
<blockquote>
<p>Docker-compose up</p>
</blockquote>
<p>in the application folder to start my application. How would I enable this functionality in my case? I'm not seeing a specific case anywhere online.</p>
| <docker><docker-compose> | 2016-01-04 11:39:14 | HQ |
34,590,369 | Formatting a Date String in React Native | <p>I'm trying to format a Date String in React Native.</p>
<p>Ex: 2016-01-04 10:34:23</p>
<p>Following is the code I'm using.</p>
<pre><code>var date = new Date("2016-01-04 10:34:23");
console.log(date);
</code></pre>
<p>My problem is, when I'm emulating this on a iPhone 6S, it'll print Mon <code>Jan 04 2016 10:34:23 GMT+0530 (IST)</code> without any problem. But if I try with the iPhone 5S it prints nothing. And if you try to get the month by using a method like <code>date.getMonth()</code> it'll print <code>"NaN"</code>.</p>
<p>Why is this? What is the workaround?</p>
| <date><react-native> | 2016-01-04 11:41:37 | HQ |
34,590,463 | Java create enum from String | <p>I have enum class </p>
<pre><code>public enum PaymentType {
/**
* This notify type we receive when user make first subscription payment.
*/
SUBSCRIPTION_NEW("subscr_signup"),
/**
* This notify type we receive when user make subscription payment for next
* month.
*/
SUBSCRIPTION_PAYMENT("subscr_payment"),
/**
* This notify type we receive when user cancel subscription from his paypal
* personal account.
*/
SUBSCRIPTION_CANCEL("subscr_cancel"),
/**
* In this case the user cannot change the amount or length of the
* subscription, they can however change the funding source or address
* associated with their account. Those actions will generate the
* subscr_modify IPN that we are receiving.
*/
SUBSCRIPTION_MODIFY("subscr_modify"),
/**
* Means that the subscription has expired, either because the subscriber
* cancelled it or it has a fixed term (implying a fixed number of payments)
* and it has now expired with no further payments being due. It is sent at
* the end of the term, instead of any payment that would otherwise have
* been due on that date.
*/
SUBSCRIPTION_EXPIRED("subscr_eot"),
/** User have no money on card, CVV error, another negative errors. */
SUBSCRIPTION_FAILED("subscr_failed");
private String type;
PaymentType(String type) {
this.type = type;
}
String getType() {
return type;
}
}
</code></pre>
<p>When I try to create enum :</p>
<pre><code>PaymentType type = PaymentType.valueOf("subscr_signup");
</code></pre>
<p>Java throws to me error :</p>
<pre><code>IllegalArgumentException occured : No enum constant models.PaymentType.subscr_signup
</code></pre>
<p>How I can fix this?</p>
| <java><enums> | 2016-01-04 11:46:49 | LQ_CLOSE |
34,591,737 | My program get crazy | <p>I tried to do a program that random 10000 numbers between 0-6 and check how much times every number get ruffle. It's get crazy and print lot's of things. please help me thanks!</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ARR_SIZE 10000
#define NUM_OF_FACES 6
int main()
{
srand(time(NULL));
int arrCube[ARR_SIZE];
int i=0,counter=0,j=0;
for(i = 0; i<ARR_SIZE; i++)
{
arrCube[i] = rand() % NUM_OF_FACES;
}
for(i=0;i<ARR_SIZE;i++)
{
counter=0;
for(j=i+1;j<ARR_SIZE -1;j++)
{
if (arrCube[i]==arrCube[j])
{
counter++;
}
}
printf("%d times %d showed up\n",counter,arrCube[i]);
}
return (0);
}
</code></pre>
<p>Another thing: I know that I can do this program with another array instead the nested loop. someone know?</p>
| <c> | 2016-01-04 12:58:38 | LQ_CLOSE |
34,594,876 | Enterprise Distribution Provisioning Profile Expiration | <p>Our company enterprise provisioning profile is set to expire in a month, <strong>but our distribution certificate is set to expire in a few more years.</strong> What are our options?</p>
<p>Do I need to regenerate a new provisioning profile and create a new build that I have to redistribute?</p>
<p>Or is there a simpler option like just sending out the new provisioning profile I generate? or better yet I don't have to do anything?</p>
<p>Thanks</p>
| <ios><provisioning-profile><enterprise><enterprise-distribution> | 2016-01-04 15:51:31 | HQ |
34,595,322 | Change <p> tag by user input forever | <p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><form action="index.php" method="post">
<input type="text" name="content" style="font-size: 25px" placeholder="Name of content"> //The text for p tag
</form>
<p></p> //display the inputted text above right HERE</code></pre>
</div>
</div>
</p>
<p>Hey,</p>
<p>I need to make simple thing. Make an input on a website, and under it, make a <code><p></code> tag. Whatever user inputs to this label/input, it will write that between the <code><p></code> tag. I know, that there is way in javascript, but i need to make it change forever, that means, when i refresh the page, it will be there, the same message forever. Any way to make it? Better to make it NOT using cross-database systém (in PhP)...</p>
<p>Please help</p>
| <javascript><php><html><css> | 2016-01-04 16:17:21 | LQ_CLOSE |
34,596,292 | Bukkit coding - Where will I put the if.senderHasPermission? | Where will i put the permission line in my plugin command code?
http://pastebin.com/BCLyr0Mn
| <java><minecraft><bukkit> | 2016-01-04 17:12:54 | LQ_EDIT |
34,596,936 | WordPress theme not use after uploading m'y website on server | I uploaded my WordPress project on my 1&1 server and i'm very disapointed because all my modification have disapear. My theme is like Virgin.
Si what can be wrong? Is there something to save before upload my files ?
Thank you | <wordpress><themes> | 2016-01-04 17:54:09 | LQ_EDIT |
34,596,989 | If statement to check array values | <p>I want to display an answer based on what value in an array the user input matches. So I want the if statement to see if what was entered matches any values in the array.</p>
| <python><arrays><if-statement> | 2016-01-04 17:56:48 | LQ_CLOSE |
34,597,186 | Use a different user.email and user.name for Git config based upon remote clone URL | <p>I configure my global <code>~/.gitconfig</code> properties <code>user.name</code> and <code>user.email</code> like this:</p>
<p></p>
<pre><code>git config --global user.email "mkobit@example.com"
git config --global user.name "mkobit"
</code></pre>
<p>This is the default configuration I want for working on personal projects, open source stuff, etc.</p>
<p>When I am working on a project from a specific domain, a corporate domain for example, I am configuring it for each repository when I clone it so that it uses a different <code>user.name</code>/<code>user.email</code>:</p>
<pre><code>git clone ssh://git@git.mycorp.com:1234/groupA/projectA.git
cd projectA
git config user.email "mkobit@mycorp.com"
git config user.name "m.kobit"
</code></pre>
<p>One decent option would be to setup an alias for cloning these kinds of repositories:</p>
<pre><code>git config --global alias.clonecorp 'clone \
-c user.name="m.kobit" -c user.email="mkobit@mycorp.com"'
git clonecorp ssh://git@git.mycorp.com:1234/groupA/projectA.git
</code></pre>
<p>Both of these can be error prone because they both depend on me being smart and following the right steps. Evidence shows that this is near-guaranteed for me to screw-up sometime.</p>
<p>Is there a way to configure Git such that repositories from a certain domain (the <code>mycorp.com</code> in this example) will be configured a certain way? </p>
| <git> | 2016-01-04 18:10:12 | HQ |
34,597,229 | google maps API for C# | <p>im really new in to using APIs so after looking on google maps Api page im not sure if there are APIs designed to be used for C#. I dont need a google maps to be show on my app all i need to know if i can use the google maps API on C#.
<a href="https://developers.google.com/maps/documentation/directions/" rel="noreferrer">This is the one i will like to use</a></p>
<p>Ive look for it on many places but all i could find was alternatives to using Gmaps but thats not what i want.</p>
<p>¿It is possible to use it?</p>
| <c#><google-maps><google-maps-api-3> | 2016-01-04 18:13:04 | HQ |
34,597,926 | converting daily stock data to weekly-based via pandas in Python | <p>I've got a <code>DataFrame</code> storing daily-based data which is as below:</p>
<pre><code>Date Open High Low Close Volume
2010-01-04 38.660000 39.299999 38.509998 39.279999 1293400
2010-01-05 39.389999 39.520000 39.029999 39.430000 1261400
2010-01-06 39.549999 40.700001 39.020000 40.250000 1879800
2010-01-07 40.090000 40.349998 39.910000 40.090000 836400
2010-01-08 40.139999 40.310001 39.720001 40.290001 654600
2010-01-11 40.209999 40.520000 40.040001 40.290001 963600
2010-01-12 40.160000 40.340000 39.279999 39.980000 1012800
2010-01-13 39.930000 40.669998 39.709999 40.560001 1773400
2010-01-14 40.490002 40.970001 40.189999 40.520000 1240600
2010-01-15 40.570000 40.939999 40.099998 40.450001 1244200
</code></pre>
<p>What I intend to do is to merge it into weekly-based data. After grouping:</p>
<ol>
<li>the <strong>Date</strong> should be every Monday (at this point, holidays scenario should be considered when Monday is not a trading day, we should apply the first trading day in current week as the Date).</li>
<li><strong>Open</strong> should be Monday's (or the first trading day of current week) Open.</li>
<li><strong>Close</strong> should be Friday's (or the last trading day of current week) Close.</li>
<li><strong>High</strong> should be the highest High of trading days in current week.</li>
<li><strong>Low</strong> should be the lowest Low of trading days in current week.</li>
<li><strong>Volumn</strong> should be the sum of all Volumes of trading days in current week.</li>
</ol>
<p>which should look like this:</p>
<pre><code>Date Open High Low Close Volume
2010-01-04 38.660000 40.700001 38.509998 40.290001 5925600
2010-01-11 40.209999 40.970001 39.279999 40.450001 6234600
</code></pre>
<p>Currently, my code snippet is as below, which function should I use to mapping daily-based data to the expected weekly-based data? Many thanks!</p>
<pre><code>import pandas_datareader.data as web
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2016, 12, 31)
f = web.DataReader("MNST", "yahoo", start, end, session=session)
print f
</code></pre>
| <python><pandas><yahoo-finance> | 2016-01-04 18:56:43 | HQ |
34,597,950 | Sass and Compass | <p>I started working with compass today. I have created a project using sass (that's atleast what I entered in the cmd).</p>
<p>It made my project, all good. All files are good etc, made them .sass extensions.</p>
<p>File Structure: <a href="http://prntscr.com/9m2i7s" rel="nofollow">http://prntscr.com/9m2i7s</a></p>
<p>But now (here comes the problem), when I try to enter in some sass code, it's giving me an error: <a href="http://prntscr.com/9m2isq" rel="nofollow">http://prntscr.com/9m2isq</a>.</p>
<p>I have already found out what the problem is. The project thinks I'm using scss (where the syntax is without the ';'s and '{ }'s.</p>
<p>I don't mind working with scss instead of sass, but I find it weird. Because it made sass files for me etc.. and now it's wanting me to use scss.</p>
<p>Does anyone know how I would maybe be able to use sass instead of scss?</p>
<p>Kind Regards!</p>
| <css><sass><compass> | 2016-01-04 18:58:08 | LQ_CLOSE |
34,598,268 | Realm Migration doesn't work | <pre><code> let config = Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 1,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
// Nothing to do!
// Realm will automatically detect new properties and removed properties
// And will update the schema on disk automatically
}
})
// Tell Realm to use this new configuration object for the default Realm
Realm.Configuration.defaultConfiguration = config
// Now that we've told Realm how to handle the schema change, opening the file
// will automatically perform the migration
let realm = try! Realm()
</code></pre>
<p>This was put in application(application:didFinishLaunchingWithOptions:)</p>
<p>In my test program, I have changed the fields in my object. I would like to remove everything in the database, and move to the new field types. I've copied the code above from the documentation, but it appears to do nothing. I still get these errors:</p>
<pre><code>fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=0 "Migration is required due to the following errors:
- Property types for 'unit' property do not match. Old type 'string', new type 'int'
- Property 'reps' has been added to latest object model." UserInfo={NSLocalizedDescription=Migration is required due to the following errors:
- Property types for 'unit' property do not match. Old type 'string', new type 'int'
- Property 'reps' has been added to latest object model.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.1.101.15/src/swift/stdlib/public/core/
</code></pre>
<p>Any ideas?</p>
| <ios><swift2><realm> | 2016-01-04 19:20:34 | HQ |
34,598,363 | Get public key from SSH server | <p>I'm looking for this for a long time.</p>
<p>I need to extract and get modulus and exponent from SSH server.</p>
<p>For example, I know, that on server xxx.xxx.xxx.xxx is running ssh (I can connect to this server / ping) but I dont know user name and password so cannot log in.</p>
<p>I need to get modulus and exponent of public RSA key of this server.</p>
<p>I found, that ssh-keyscan can get modulus + exponent (from documentation) but only if ssh-rsa1 is used. If I try to get ssh-rsa(2) public key with ssh-keyscan, I cannot retrieve from output modulus and exponent.</p>
<p>Is it possible ? </p>
| <ssh><certificate><rsa><modulus> | 2016-01-04 19:25:44 | HQ |
34,598,563 | MongoDB Print Pretty with PyMongo | <p>I've looked up print pretty for MongoDB, and i understand how to do it from the shell. What I can't find is how to do it with PyMongo, so that when I run it in eclipse, the output will print pretty instead of all in one line. Here's what I have right now:</p>
<pre><code> cursor = collection.find({})
for document in cursor: print(document)
</code></pre>
<p>This prints everything in my collection, but each document in my collection just prints in one line. How can i change this to get it to print pretty?</p>
| <python><mongodb><printing><pymongo> | 2016-01-04 19:38:42 | HQ |
34,598,719 | TGraphic.Draw(Canvas, Rect) does not work | I need to insert an image into an ImageList. The image is in a descendant of TGraphicControl (see source code below). The insertion seems to work. However, I get only a white rectangle in the ImageList:
function InsertCloudImageIntoImageList(AdvCloudImage1: TAdvCloudImage): Integer;
// TAdvCloudImage = class(TGraphicControl)
// WebPicture is TCloudPicture = class(TGraphic)
var
TempBitmap: TBitmap;
R: TRect;
begin
Result := 0;
TempBitmap := TBitmap.Create;
try
TempBitmap.SetSize(16, 16);
R.Width := 16;
R.Height := 16;
R.Top := 0;
R.Left := 0;
AdvCloudImage1.WebPicture.Draw(TempBitmap.Canvas, R);
Result := Form1.ImageList1.Add(TempBitmap, nil);
finally
TempBitmap.Free;
end;
end;
I suspect the bug is in the drawing on the bitmap canvas? | <delphi><draw><delphi-10-seattle><tcanvas> | 2016-01-04 19:50:37 | LQ_EDIT |
34,599,888 | How do I rename a Google Cloud Platform project? | <p>Is it possible to rename a Google Cloud Platform project? If so, how?</p>
<p>I don't need to change the project ID or number. But I do want to change the project <em>name</em> (the name used by/for humans to identify a cloud platform project).</p>
<p>Thanks for any tips!</p>
| <google-cloud-platform> | 2016-01-04 21:09:56 | HQ |
34,600,130 | How to decrease padding in NumberPicker | <p>How to decrease padding in NumberPicker </p>
<p><a href="https://i.stack.imgur.com/7A7wJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7A7wJ.png" alt="enter image description here"></a> </p>
<p>I want something like it: </p>
<p><a href="https://i.stack.imgur.com/8LT8j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8LT8j.png" alt="enter image description here"></a></p>
| <android><android-number-picker> | 2016-01-04 21:24:52 | HQ |
34,600,544 | Slick Carousel Easing Examples | <p>I am using Slick Carousel (<a href="http://kenwheeler.github.io/slick/" rel="noreferrer">http://kenwheeler.github.io/slick/</a>), but don't know how to incorporate different slide transitions. Does anyone have an example to share?</p>
<p>Here's what I currently have:</p>
<pre><code> $('.slider1').slick({
autoplay:true,
autoplaySpeed: 4500,
arrows:false,
slide:'.slider-pic',
slidesToShow:1,
slidesToScroll:1,
dots:false,
easing: 'easeOutElastic',
responsive: [
{
breakpoint: 1024,
settings: {
dots: false
}
}]
});
</code></pre>
<p>On site - <a href="http://lantecctc.businesscatalyst.com/" rel="noreferrer">http://lantecctc.businesscatalyst.com/</a></p>
| <javascript><slick.js> | 2016-01-04 21:52:42 | HQ |
34,600,932 | npm - EPERM: operation not permitted on Windows | <p>I ran </p>
<pre><code>npm config set prefix /usr/local
</code></pre>
<p>After running that command,
When trying to run any npm commands on Windows OS I keep getting the below. </p>
<pre><code>Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local'
at Error (native)
</code></pre>
<p>Have deleted all files from </p>
<pre><code>C:\Users\<your username>\.config\configstore\
</code></pre>
<p>It did not work.</p>
<p>Any suggestion ?</p>
| <javascript><node.js><npm><bower><npm-install> | 2016-01-04 22:21:24 | HQ |
34,601,532 | Ruby: syntax error, unexpected end-of-input, expecting keyword_end | <p>I am working on some simple ruby exercises and cannot figure out why I am getting the "syntax error, unexpected end-of-input, expecting keyword_end". I keep running over my code and don't see what is wrong, although I am new to ruby.</p>
<pre><code>def SimpleSymbols(str)
spec_char = "+="
alpha = "abcdefghijklmnopqrstuvwxyz"
str.each_char do |i|
if spec_char.include? i
next
else alpha.include? i
if spec_char.include? str[str.index(i) + 1] && if spec_char.include? str[str.index(i) - 1]
next
else
return false
end
end
end
return true
end
SimpleSymbols(STDIN.gets.chomp)
</code></pre>
| <ruby><syntax-error> | 2016-01-04 23:07:52 | LQ_CLOSE |
34,601,554 | Mac spark-shell Error initializing SparkContext | <p>I tried to start spark 1.6.0 (spark-1.6.0-bin-hadoop2.4) on Mac OS Yosemite 10.10.5 using </p>
<pre><code>"./bin/spark-shell".
</code></pre>
<p>It has the error below. I also tried to install different versions of Spark but all have the same error. This is the second time I'm running Spark. My previous run works fine. </p>
<pre><code>log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Using Spark's repl log4j profile: org/apache/spark/log4j-defaults-repl.properties
To adjust logging level use sc.setLogLevel("INFO")
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.6.0
/_/
Using Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79)
Type in expressions to have them evaluated.
Type :help for more information.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1.
16/01/04 13:49:40 ERROR SparkContext: Error initializing SparkContext.
java.net.BindException: Can't assign requested address: Service 'sparkDriver' failed after 16 retries!
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:485)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1089)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:430)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:415)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:903)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:198)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:745)
java.net.BindException: Can't assign requested address: Service 'sparkDriver' failed after 16 retries!
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:485)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1089)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:430)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:415)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:903)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:198)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
at org.apache.spark.sql.SQLContext$.createListenerAndUI(SQLContext.scala:1367)
at org.apache.spark.sql.hive.HiveContext.<init>(HiveContext.scala:101)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.spark.repl.SparkILoop.createSQLContext(SparkILoop.scala:1028)
at $iwC$$iwC.<init>(<console>:15)
at $iwC.<init>(<console>:24)
at <init>(<console>:26)
at .<init>(<console>:30)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
at org.apache.spark.repl.SparkILoopInit$$anonfun$initializeSpark$1.apply(SparkILoopInit.scala:132)
at org.apache.spark.repl.SparkILoopInit$$anonfun$initializeSpark$1.apply(SparkILoopInit.scala:124)
at org.apache.spark.repl.SparkIMain.beQuietDuring(SparkIMain.scala:324)
at org.apache.spark.repl.SparkILoopInit$class.initializeSpark(SparkILoopInit.scala:124)
at org.apache.spark.repl.SparkILoop.initializeSpark(SparkILoop.scala:64)
at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1$$anonfun$apply$mcZ$sp$5.apply$mcV$sp(SparkILoop.scala:974)
at org.apache.spark.repl.SparkILoopInit$class.runThunks(SparkILoopInit.scala:159)
at org.apache.spark.repl.SparkILoop.runThunks(SparkILoop.scala:64)
at org.apache.spark.repl.SparkILoopInit$class.postInitialization(SparkILoopInit.scala:108)
at org.apache.spark.repl.SparkILoop.postInitialization(SparkILoop.scala:64)
at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:991)
at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
at org.apache.spark.repl.Main$.main(Main.scala:31)
at org.apache.spark.repl.Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
<console>:16: error: not found: value sqlContext
import sqlContext.implicits._
^
<console>:16: error: not found: value sqlContext
import sqlContext.sql
</code></pre>
<p>Then I add </p>
<pre><code>export SPARK_LOCAL_IP="127.0.0.1"
</code></pre>
<p>to spark-env.sh, error changes to:</p>
<pre><code> ERROR : No route to host
java.net.ConnectException: No route to host
at java.net.Inet6AddressImpl.isReachable0(Native Method)
at java.net.Inet6AddressImpl.isReachable(Inet6AddressImpl.java:77)
at java.net.InetAddress.isReachable(InetAddress.java:475)
...
<console>:10: error: not found: value sqlContext
import sqlContext.implicits._
^
<console>:10: error: not found: value sqlContext
import sqlContext.sql
</code></pre>
| <apache-spark> | 2016-01-04 23:09:36 | HQ |
34,601,582 | what is the difference between import and const and which is preferred in commonjs | <p>I have noticed a bit of switching between using const and import for referencing libraries in node.js applications using es6 syntax with Babel.</p>
<p>What is the preferred method and what is the difference between using const and import? Assuming you may be importing the same library in many files/components.</p>
<p><strong>const</strong></p>
<pre><code>const React = require('react')
</code></pre>
<p><strong>import</strong></p>
<pre><code>import React from 'react'
</code></pre>
<p>Here are the definitions of each but I am still not sure which to use.</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import">import</a></p>
<p>The import statement is used to import functions, objects or primitives that have been exported from an external module, another script, etc.</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const">const</a></p>
<p>The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned.</p>
| <javascript><node.js><reactjs><babeljs><commonjs> | 2016-01-04 23:12:07 | HQ |
34,603,157 | How to get a text from SearchView? | <p>I need to get a text from SearchView and compare it to strings in my activity's ListView and show a Toast if the word in a SearchView is in my ListView. How do I do that? Here's my working code for the SearchView:</p>
<pre><code>MenuItem ourSearchItem = menu.findItem(R.id.menu_item_search);
SearchView sv = (SearchView) ourSearchItem.getActionView();
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
}
return false;
}
});
</code></pre>
| <android> | 2016-01-05 02:14:04 | HQ |
34,603,355 | Android Device Monitor "data" folder is empty | <p>I have tested creating, inserting and retrieving data into my apps db, and know it works through usage of Log statements. </p>
<p>However, I wish to expedite testing and use the Android Device Monitor. However, though the db exists and data is stored, when accessing below, the <code>data</code> folder is empty:</p>
<p><a href="https://i.stack.imgur.com/2y1zs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2y1zs.png" alt="enter image description here"></a></p>
<p>Why would this be the case? How can this be configured to show the db file and contents?</p>
| <android><sqlite><android-studio> | 2016-01-05 02:40:34 | HQ |
34,603,388 | Should Comparable ever compare to another type? | <p>I'm wondering if there's ever a valid use case for the following:</p>
<pre><code>class Base {}
class A implements Comparable<Base> {
//...
}
</code></pre>
<p>It seems to be a common pattern (see <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html" rel="noreferrer">Collections</a> for a number of examples) to accept a collection of type <code>T</code>, where <code>T extends Comparable<? super T></code>.</p>
<p>But it seems technically impossible to fulfill the contract of <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html#compareTo-T-" rel="noreferrer"><code>compareTo()</code></a> when comparing to a base class, because there's no way to ensure that another class doesn't extend the base with a contradictory comparison. Consider the following example:</p>
<pre><code>class Base {
final int foo;
Base(int foo) {
this.foo = foo;
}
}
class A extends Base implements Comparable<Base> {
A(int foo) {
super(foo);
}
public int compareTo(Base that) {
return Integer.compare(this.foo, that.foo); // sort by foo ascending
}
}
class B extends Base implements Comparable<Base> {
B(int foo) {
super(foo);
}
public int compareTo(Base that) {
return -Integer.compare(this.foo, that.foo); // sort by foo descending
}
}
</code></pre>
<p>We have two classes extending <code>Base</code> using comparisons that don't follow a common rule (if there were a common rule, it would almost certainly be implemented in <code>Base</code>). Yet the following broken sort will compile:</p>
<pre><code>Collections.sort(Arrays.asList(new A(0), new B(1)));
</code></pre>
<p>Wouldn't it be safer to only accept <code>T extends Comparable<T></code>? Or is there some use case that would validate the wildcard?</p>
| <java><comparable> | 2016-01-05 02:43:34 | HQ |
34,603,680 | What is squeeze testing? | <p>In the talk "<a href="http://www.infoq.com/presentations/netflix-operations-devops" rel="noreferrer">Beyond DevOps: How Netflix Bridges the Gap</a>," around 29:10 Josh Evans mentions squeeze testing as something that can help them understand system drift. What is squeeze testing and how is it implemented?</p>
| <testing><architecture><devops> | 2016-01-05 03:22:01 | HQ |
34,603,937 | Print type of variable in python3.5 on django 1.8 | <p>I am having a hard time of determining the type of my variable since I am used on python2 and have just migrated to python3</p>
<pre><code>from django.http import HttpResponse
def myview(request):
x = "Name"
print (x)
print type(x)
return HttpResponse("Example output")
</code></pre>
<p>This code will throw an error because of print type(x). However if you changed that syntax line to type(x). The type does not return an output on the runserver of django.</p>
| <django><python-3.5> | 2016-01-05 03:59:58 | HQ |
34,604,439 | Reference variables and pointers | Is `int &y=x` same as `int y=&x`?
Also in the below code, why is `*s++` giving me some wrong results? I was expecting `*s` value to be 12
Are `s++` and `*s++` the same?
#include <iostream>
using namespace std;
int main()
{
int p=10;
int &q=p; //q is a reference variable to p
//int r=&p; //error: invalid conversion from 'int*' to 'int'
int *s=&p; //valid
q++;
*s++; //here even s++ works, and cout<<*s does not give 12 but some lengthy number
//and cout<<s gives some hexadecimal, I'm guessing thats the address
cout<<p<<endl<<q<<endl<<*s;
}
Output I'm getting:
11
11
6422280 | <c++><variables><pointers> | 2016-01-05 04:58:20 | LQ_EDIT |
34,604,646 | whick keyword can be used to replace "FROM" in sql? | I am trying to bypass a waf ,and whick keyword can be used to replace "FROM" in sql ? | <sql><security><web-application-firewall> | 2016-01-05 05:19:02 | LQ_EDIT |
34,605,166 | Actionscript error :( | im just a beginner at this and i would really appreciate some help :)
This is my code:
import flash.events.MouseEvent;
import flash.display.MovieClip;
var currentButton:MovieClip
button1.addEventListener(MouseEvent.CLICK, mouseClick);
button2.addEventListener(MouseEvent.CLICK, mouseClick);
button3.addEventListener(MouseEvent.CLICK, mouseClick);
button4.addEventListener(MouseEvent.CLICK, mouseClick);
function mouseClick(event:MouseEvent):void {
currentButton.alpha = 1;
currentButton.mouseEnabled = true;
currentButton = event.target as MovieClip;
trace("CLICK");
currentButton.alpha = 0.7;
currentButton.mouseEnabled = false;
}
But i get this error when i click on a button:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/mouseClick()
sorry if i didnt post this question right, im just new here
| <actionscript-3><flash> | 2016-01-05 06:03:07 | LQ_EDIT |
34,605,384 | What is the correct way to put multiple controls inside update panel? | <p>I have one registration form which contains 3 to 4 dropdown controls and 2 datepickers and now when dropdown controls value are selected(selectedindex change are fired)
then i dont want my page to postback.</p>
<p>I have use update panel to stop this behaviour of post like below:</p>
<pre><code><asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%--Update Panel for date picker%>
<asp:UpdatePanel ID="UpdatePanelDatepicker" runat="server">
<ContentTemplate>
<telerik:RadDatePicker ID="rdpDate1" runat="server">
</telerik:RadDatePicker>
</ContentTemplate>
</asp:UpdatePanel>
<%--Update Panel for Dropdown--%>
<asp:UpdatePanel ID="updatepaneldata" runat="server">
<ContentTemplate>
<telerik:RadComboBox ID="ddlCountry" runat="server">
</telerik:RadComboBox>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</code></pre>
<p>So i just wanted to ask that is this correct way to put multiple controls under update panels??</p>
| <c#><asp.net><telerik><updatepanel> | 2016-01-05 06:21:24 | HQ |
34,605,832 | How to Write Json Array to file using jackson | <p>I created a Json file where i wanted to write write java object as Array element. Im using jackson.</p>
<pre><code> try{
String json;
String phyPath = request.getSession().getServletContext().getRealPath("/");
String filepath = phyPath + "resources/" + "data.json";
File file = new File(filepath);
if (!file.exists()) {
System.out.println("pai nai");
file.createNewFile();
}
json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(story);
Files.write(new File(filepath).toPath(), Arrays.asList(json), StandardOpenOption.APPEND);
}
</code></pre>
<p>This is not what i exactly want .it creates data like </p>
<pre><code>{
"storyTitle" : "ttt",
"storyBody" : "tttt",
"storyAuthor" : "tttt"
}
{
"storyTitle" : "a",
"storyBody" : "a",
"storyAuthor" : "a"
}
</code></pre>
<p>I just need to create a Array of Json where i add java object, data should be like this </p>
<pre><code>[{
"storyTitle" : "ttt",
"storyBody" : "tttt",
"storyAuthor" : "tttt"
}
,{
"storyTitle" : "a",
"storyBody" : "a",
"storyAuthor" : "a"
}]
</code></pre>
| <java><json><jackson> | 2016-01-05 06:57:18 | HQ |
34,606,402 | Printing Different Paterns in Single Program | Here User enter X Coordinate, Y coordinate ,Length L,number n. if user enters n
we have to print "stright Line" with (x,y) cordinates, if n=2 print bisecting Lines if n=3 print triangle like.... Here Length purpose is to Print Length of side is equal to L. Is there any solutions for this question please comment because it was asked me for interview? | <c#> | 2016-01-05 07:34:47 | LQ_EDIT |
34,606,570 | $_SERVER['HTTP_REFERER'] and RewriteCond %{HTTP_REFERER} | Some problem.
.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteRule ^page([0-9]+).html$ index.php?page=$1
RewriteRule ^p([0-9]+)-([a-zA-Z0-9_]+).html$ index.php?id_post=$1&title_post=$2
RewriteRule ^([a-zA-Z0-9_\-]+)/page([0-9]+).html$ index.php?mpoint=$1&page=$2 [L]
RewriteRule ^([a-zA-Z0-9_\-]+).html$ index.php?mpoint=$1
RewriteRule ^.*.html$ index.php?mpoint=$1
RewriteCond %{HTTP_REFERER} ^www.example111.com$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^example222.ml$
RewriteRule .* – [F]
index.php
echo $_SERVER['HTTP_REFERER'];
result: http://www.example111.com/xxxx/yyy.html
**Why RewriteCond dont work?** | <apache><.htaccess><mod-rewrite><http-referer> | 2016-01-05 07:46:55 | LQ_EDIT |
34,607,230 | Crashing Pointer Array C++ | <p>Code::Blocks, Win7, C++</p>
<p>Hi, I'm creating an overview project for myself, and an integral part includes doing an Exchange Sort in descending order. I've created a simple trial run to test the concept.</p>
<p>Embarrassingly enough, I can't get past creating the array without the project crashing. This only happens when I create the array with pointers (My project's arrays are pointers, which is why I need this to work). The code compiles fine, but when I run it, I get a Window's notification that "ArrayTest.exe has stopped working"</p>
<p>When I print out each dereferenced value, I get:</p>
<p>"The original order: 1 13 5 7 2 "</p>
<p>When I print out each value's address, I get: </p>
<p>"The original order: 0x28ff08 0x28ffc4 0x760c8cd5 0x6aadab61 0xfffffffe "</p>
<p>The last address showed up when using an array length of 6, and crashes as well. Am I blind to a simple error in my code, or is this a hardware issue?</p>
<pre><code>//filename ArrayTest
#include <iostream>
using namespace std;
int main()
{
int *j[5];
(*j)[0] = 1;
(*j)[1] = 13;
(*j)[2] = 5;
(*j)[3] = 7;
(*j)[4] = 2;
cout << "The original order: ";
for (int i = 0; i < 5; i++)
{
cout << (*j)[i] << " ";
}
return 0;
}
</code></pre>
| <c++><arrays><pointers> | 2016-01-05 08:32:08 | LQ_CLOSE |
34,607,935 | How to work with database in asp.net | I am php web developer .now i want to work with asp.net but it's very difficult for me to work with databases in asp.net.I need some source link from where i can easily learn asp.net.
----------------------------------
-----------------------------------=
| <asp.net> | 2016-01-05 09:14:50 | LQ_EDIT |
34,607,961 | Why am I getting "cannot convert from Dequeu<int> to int" error? | <p>I am currently trying to write my first template class as an assignment for my c++ class, but I don't understand why I keep getting this error:</p>
<pre><code>g++ -c main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12:14: error: cannot convert ‘Dequeu<int>’ to ‘int’ in initialization
int ou = i[0];
</code></pre>
<p>main.cpp:</p>
<pre><code>#include "main.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int main (int args, char ** argc){
Dequeu<int>* i = new Dequeu<int>();
i->push_back (10);
int ou = i[0];
cout<<"i[0]: "<<ou<<endl;
}
</code></pre>
<p>with main.h:</p>
<pre><code>#include "Dequeu.h"
</code></pre>
<p>dequeu.h:</p>
<pre><code>#ifndef MAIN_H
#define MAIN_H
#endif
#include "Node.h"
#include <stddef.h> //NULL
template<typename T>
class Dequeu {
public:
Dequeu(); ~Dequeu();
void push_back(T);
T &operator[] (int i) {
if (i<size && i>=0){
//head?
if (i == 0)
return head->value;
//tail?
if (i == size-1)
return tail->value;
//other:
Node<T>* temp = head;
i--;
while (i != 0 ){
temp = temp->next;
i--;
}
return temp->Value();
}
}
private:
Node<T> * head;
Node<T> * tail;
int size;
};
template<typename T>
Dequeu<T>::Dequeu() {
head->nullify();
tail->nullify();
}
template<typename T>
Dequeu<T>::~Dequeu(){
Node<T>* temp = head;
while (temp->Next() != NULL) {
temp = temp->next;
delete(head);
head=temp;
}
}
template<typename T>
void Dequeu<T>::push_back(T t){
Node<T>* newNode;
newNode->Value(t);
newNode->prev = tail;
tail->next = newNode;
tail = newNode;
if (head == NULL)
head = tail;
size++;
}
</code></pre>
<p>and Node.h:</p>
<pre><code>#include <stddef.h> //NULL
template <typename T>
class Node {
public:
Node<T>* prev;
Node<T>* next;
T value;
Node(); ~Node();
void nullify ();
private:
};
template <typename T>
void Node<T>::nullify() {
this->value = NULL;
this->next = NULL;
this->prev = NULL;}
</code></pre>
<p>The last thing I tried was event just returning <code>this->head->value</code> without checking the input integer in operator[].</p>
<p>The class is not finished yet, so don't wonder why there are only two functions implemented...</p>
<p><strong>Please feel free to tell me how to write this code better if you find something very bad in it</strong>, I am really bad in this.</p>
| <c++><class><templates> | 2016-01-05 09:16:32 | LQ_CLOSE |
34,608,361 | How to reset form validation on submission of the form in ANGULAR 2 | <p>I have to reset my form along with validation. is there any method to reset the state of form from ng-dirty to ng-pristine.</p>
| <angular><angular2-forms> | 2016-01-05 09:38:03 | HQ |
34,608,712 | Dynamicly Button in Android studio | [dynamicly button][1]
[1]: http://i.stack.imgur.com/Nnx4B.png
hey guys, im trying to create an Add button that can create dynamicly button, but i have a problem in
Button mybutton = new Button (this);
i have no idea why "this" can be applied in OnClickListner.
Anyone can help me please ?
Thanks before | <android> | 2016-01-05 09:54:57 | LQ_EDIT |
34,609,572 | Is it possible to set a hostname in a Kubernetes replication controller? | <p>I need to set a static hostname in a Kubernetes replication controller. Docker supports it with some runtime flags, however, Kubernetes replication controllers don't appear to support it.
The environment: OS - CentOS 6.6
Approach to use sysctl to change the variable kernel.hostname does not work for a K8s replication controller. The host name is not changed.
Use:
sysctl kernel.hostname
to read the current hostname, and
sysctl kernel.hostname=NEW_HOSTNAME</p>
<p>Is it possible to set a hostname in a Kubernetes replication controller?</p>
| <kubernetes> | 2016-01-05 10:35:33 | HQ |
34,609,650 | How to split file in windows just like linux | <p>How can we split file in windows system in command prompt based on size. like linux system we use </p>
<pre><code>"split -b 10M filename.xyz new_filename"
</code></pre>
| <windows-7-x64> | 2016-01-05 10:39:12 | HQ |
34,610,133 | xUnit Equivelant of MSTest's Assert.Inconclusive | <p>What is the xUnit equivalent of the following MSTest code:</p>
<pre><code>Assert.Inconclusive("Reason");
</code></pre>
<p>This gives a yellow test result instead of the usual green or red. I want to assert that the test could not be run due to certain conditions and that the test should be re-run after those conditions have been met.</p>
| <unit-testing><mstest><assert><xunit><assertion> | 2016-01-05 11:03:26 | HQ |
34,610,787 | Undefined index | <p>I get Undefined index: image error in this code. Can I know the exact solution? I wanna know workflow from line abc to xyz that I commented in the code using //.Thanks for your help..</p>
<pre><code> <?php session_start();
include("config.php");
if(isset($_SESSION['name']))
{
if(!$_SESSION['name']=='admin')
{
header("Location:login.php?id=You are not authorised to access this page unless you are administrator of this website");
}
}
?>
<?php
$name=$_FILES['image']['name'];
$tmp=$_FILES['image']['tmp_name'];
$err=$_FILES['image']['error'];
}
if($err==0)
{
move_uploaded_file($tmp, $name);
//xyz}
$category=$_POST['category'];
$title=$_POST['title'];
$image=$_FILES["image"]["name"];
$content=$_POST['content'];
}
<?php
$qry=mysql_query("INSERT INTO articles(title,image,content,category)VALUES('$title','$image','$content','$category')");
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
else
{
echo "Article Added Successfully";
}
?>
The form code is here:
<?php
include("config.php");
$sql=mysql_query("select * from category");
if(!$sql)
{
mysql_error();
}
?>
<form action="created_article.php" method="post">
Category:
<select name="category">
<?php
while($row=mysql_fetch_array($sql))
{
echo"<option value='".$row['category']."'>".$row['category']."</option>";
}
?>
</select>
Title:
<input type="text" name="title"/>
Upload Image:
<input type="file" name="image" id="image" />
Contents:
<textarea name="content" cols="100" rows="12" ></textarea>
<input type="submit" name="button" value="Submit" />
</form>
</code></pre>
<p>I need help with these code, I need to make project and I'm stuck here, so please kindly I request for your help,</p>
| <php><undefined-index> | 2016-01-05 11:35:49 | LQ_CLOSE |
34,611,077 | Save me from writing 500 lines of if/else statements in PHP? | I am in a big trouble,
Me and my friend doing a mini project that.How a Person is popular in his city.
**My situation**
How the algorithm should work like
If a person "mark" has 500 friends in his city out of 500,000.
(500/500,000)*50,000 = 5
So 5 in 50,000 people Know him right.
But When friends count increase the 50,000 should decrease
like:-
If "sam" has 1000 friends then
(1000/500,000)*25000 = 5
So 5 in 25000 people know his name
Yes we could implement this in if/else condition
If so then i have to write 500 lines of code.
Is there is a another way to do this in PHP.
Help !
| <php><mysql> | 2016-01-05 11:51:20 | LQ_EDIT |
34,611,358 | get position of marker in google maps | I am trying to get the current position that mean longitude and latitude of the marker. First a marker becomes created at the users location and when the user click on the map the previous one becomes deleted and a new one becomes created at the users clickpoint. I tried it by my own with `var lat1 = markers.position.lat(); var lng1 = markers.position.lng();` but that havent work and I get with this the error message `Uncaught TypeError: Cannot read property 'lat' of undefined`. How can I get the current position of the marker and save it in a variable?
var markers = [];
// This event listener will call addMarker() when the map is clicked.
map.addListener('click', function(event) {
addMarkers(event.latLng);
});
//draw a marker at the position of the user
addMarkers(pos);
// Adds a marker to the map and push to the array.
function addMarkers(location) {
var marker = new google.maps.Marker({
position: location,
map: map
});
markers.push(marker);
}
// Sets the map on all markers in the array.
function setMapOnAll(map) {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
}
// Removes the markers from the map, but keeps them in the array.
function clearMarkers() {
setMapOnAll(null);
}
// Deletes all markers in the array by removing references to them.
function deleteMarkers() {
clearMarkers();
marker = [];
}
| <javascript><google-maps><google-maps-api-3> | 2016-01-05 12:08:31 | LQ_EDIT |
34,611,531 | Element printed shows unexpected value | <p>This is my code. It calls a few functions but nothing that is related to the issue.</p>
<pre><code>int main()
{
srand((unsigned int)time(NULL)); //initializing srand
struct card *deckAr = createDeck(); //creating the struct card deck array
for (int i = 0; i < 100000; i++)
{
shuffleDeck(deckAr);
}
struct card *player1hand = (struct card*)malloc(sizeof(player1hand));
struct card *player2hand = (struct card*)malloc(sizeof(player2hand));
struct card *househand = (struct card*)malloc(sizeof(househand));
player1hand = (struct card*)realloc(player1hand, sizeof(player1hand) * 2);
player1hand[0] = deckAr[0];
player1hand[1] = deckAr[1];
printf("Card 1 %s of %s\n\n", valueName(player1hand[0].suit), suitName(player1hand[0].suit));
printf("Card 2 %s of %s\n\n", valueName(player1hand[1].suit), suitName(player1hand[1].suit));
printf("%s of %s\n", valueName(deckAr[0].value), suitName(deckAr[0].suit));
return 0;
}
</code></pre>
<p>Output:</p>
<pre><code>Card 1 Three of Hearts
Card 2 Three of Hearts
Ten of Hearts
</code></pre>
<p>Since nothing is manipulating deckAr, shouldn't deckAr[0] be the same as player1hand[0]?</p>
| <c> | 2016-01-05 12:17:49 | LQ_CLOSE |
34,612,223 | Eclipse JFrame empty textField error | I'm working on eclipse JFrame and my purpose is calculating regression analysis with 26 variables x and y.But i have a problem with textField. For example; if the user have 10 variables x and y after enter the values the other textFields remains blank because of this frame gives an error like // Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "" // how can ı fix it ? thanks | <java><swing><jtextfield><numberformatexception> | 2016-01-05 12:53:13 | LQ_EDIT |
34,612,816 | Adobe Air application has black bars on iPhone 6 plus | <p>I am having problem with my ios air app, shown in picture bellow. I can not get rid of black bars. Despite I added all launching images:</p>
<p>Any advice would be great help!</p>
<p>Images:</p>
<p><img src="https://i.imgur.com/bT1cOt2.png" alt="launching images"> [1]</p>
<p>Iphone6 plus screen</p>
<p><img src="https://i.imgur.com/11bTbxI.png" alt="screen from iphone"> [2]</p>
| <ios><iphone><actionscript-3><air> | 2016-01-05 13:24:35 | LQ_CLOSE |
34,613,076 | adding delete button to a div | I am going to add a delete button to new items made. this delete button removes the item my-item from the page without affecting others.
I have coded like this but I`m not sure if I`m on the right path.
I`ll be glad if you can help me. :)
<!DOCTYPE HTML>
<html>
<head>
<meta charset = "UTF-8">
<title>Simple Demo</title>
<style>
.my-item{
width:250px;
heigth:180px;
margin:10px;
padding:20px;
background:green;
border:2px solid black;
}
.item-header{
width:150px;
heigth:120px;
margin:5px;
padding:10px;
background:yellow;
border:1px solid black;
}
.item-body{
width:70px;
heigth:50px;
margin:3px;
padding:5px;
background:purple;
border:1px solid black;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("#divButton").click(function(){
$(".my-item").clone().appendTo("body")
});
$("#toggle").click(function(){
if ($(".item-body").is(":visible")){
$(".item-body").slideUp("normal");
}else{
$(".item-body").slideDown("normal");
}
});
$("#deleteButton").click(function(){
$(".my-item").append(".my-item"+ "button class="deleteButton">Delete</button>");
});
});
</script>
</head>
<body>
<div class="my-item">
<div class="item-header">
<h2 id="toggle">Click Me!</h2>
<div class="item-body">My Text!
</div>
</div>
</div>
<button id="divButton">Click!</button>
<button id="deleteButton">Delete!</button>
</body>
</html> | <javascript><jquery> | 2016-01-05 13:37:29 | LQ_EDIT |
34,613,083 | CNAME and TXT record for same subdomain not working | <p>I need to add a TXT record for the subdomain test.domain.com in the zone file. In this zone file there is an existing CNAME for the same subdomain. The two records looking like this:</p>
<pre><code>test IN CNAME asdf.someotherdomain.com.
test IN TXT "Some text i need to add"
</code></pre>
<p>But when I try to save this I get an error:</p>
<pre><code>dns_master_load: :45: test.domain.com: CNAME and other data
zone domain.com/IN: loading from master file failed: CNAME and other data
zone domain.com/IN: not loaded due to errors.
status: FAIL
</code></pre>
<p>It works if I do it with different subdomains, for example:</p>
<pre><code>test IN CNAME asdf.someotherdomain.com.
testing IN TXT "Some text i need to add"
</code></pre>
<p>I'm not exactly the best there is when it comes to DNS. Is it not possible to have the same subdomain in this scenario? Or am I missing something?</p>
<p>The servers are running bind.</p>
| <dns><cname> | 2016-01-05 13:37:57 | HQ |
34,613,353 | When I run it I get indentation Errors in many lines, such as line 6 and lines where I put exit(0). | from sys import exit
def gold_room():
print "This room is full of gold, How much do you take?"
next = raw_input("> ")
if "0" in next or "1" in next:
how_much = int(next)
else:
dead("Man learn to type a number!")
if how_much < 50:
print "Nice, you're not greedy, you win!"
exit(0)
else:
dead("You greedy bastard!")
def bear_room():
print "There is a bear here."
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move a bear?"
bear_moved = False
while True:
next = raw_input("> ")
if next == "take honey":
dead("The bear looks at you and slaps your face off.")
elif next == "taunt bear" and not bear_moved:
print "The bear has moved from the door and you can go now."
bear_moved = True
elif next == "taunt bear" and bear_moved:
dead("The bear gets pissed off and chews your leg off.")
elif next == "open door" and bear_moved:
gold_room()
else:
print "I got no idea waht that means."
def cthulhu_room():
print "Here you see the great evil Cthulhu."
print " He, it, whatever stares at you and you go insane."
print "Do you flee for your life or eat your head?"
next = raw_input("> ")
if "flee" in next:
start()
elif "head" in next:
dead("Well that was tasty!")
else:
cthulhu_room()
def dead(why):
print why, "Good job!"
exit(0)
def start():
print "You are in dark room."
print "There is a door on your right and left."
print "Which one do you take?"
next = raw_input("> ")
if next == "left":
bear_room()
elif next == "right":
cthulhu_room()
else:
dead("You stumble around the room until you starved.")
start()
| <python><indentation> | 2016-01-05 13:52:54 | LQ_EDIT |
34,613,530 | how to connect an android application to MySQL database? | <p>I am developing an android application,and I have create a MySQL database in my computer,and I want to know how can I get the information in android application from the database ?</p>
| <android> | 2016-01-05 14:03:24 | LQ_CLOSE |
34,613,761 | detect non ascii characters in a string | <p>How can I detect non-ascii characters in a vector f strings in a grep like fashion. For example below I'd like to return <code>c(1, 3)</code> or <code>c(TRUE, FALSE, TRUE, FALSE)</code>:</p>
<pre><code>x <- c("façile test of showNonASCII(): details{",
"This is a good line", "This has an ümlaut in it.", "OK again. }")
</code></pre>
<p>Attempt:</p>
<pre><code>y <- tools::showNonASCII(x)
str(y)
p <- capture.output(tools::showNonASCII(x))
</code></pre>
| <r> | 2016-01-05 14:15:20 | HQ |
34,613,832 | Is this ER Diagram of a Bank Account correct? | > • Each customer has a name, a permanent address, and a social security
> number. • Each customer can have multiple phone numbers, and the same
> phone number may be shared by multiple customers. • A customer can
> own multiple accounts, but each account is owned by a single customer.
> • Each account has an account number, a type (such as saving,
> checking, etc.), and a balance • The bank issues an account statement
> for each account and mails it to its account owner every month. As
> time goes on, there will be multiple statements of the same account.
> • Each statement has an issued date and a statement ID. All the
> statements of the same account have different statement IDs, but two
> different accounts could have statements with the same statement ID.
> For example, it is possible that account A has a statement with ID
> ‘123', while account B has another statement with the same ID '123'.
[![enter image description here][1]][1]
I have a few questions:
(1) Can Min-Max notation be used in case of any relationships, or, just when there is an indication for that in the description?
(2) Are my many-to-many relationships portrayed correctly here?
(3) Could I properly portray the relationships among Account vs Account Statement vs StatementID?
(4) As per my assumption, Is Account Statement really a weak entity and is `Has` really a weak relation that is dependent on Statement ID? Is issue-date a weak key?
[1]: http://i.stack.imgur.com/pCyHQ.png | <relational-database><entity-relationship-model> | 2016-01-05 14:18:44 | LQ_EDIT |
34,614,379 | python 2.7 : find nested keys in dictionary | I have several dictionaries , dictionary keys are tupples.
Keys are always same length in each dictionary.
I'd like to find nested keys and print them .
dictionaries example :
dic_1 =
{
(u'A_String', u'B_String', u'C_String', u'D_String', u'E_String'): 111,
(u'A_String', u'B_String', u'C_String', u'D_String' ,u'F_String'): 112
}
dic_2 =
{
(u'A_String', u'B_String', u'C_String', u'D_String'): 300,
(u'A_String', u'B_String', u'C_String', u'F_String'): 301,
}
dic_3 =
{
(u'A_String', u'B_String', u'C_String'): 200,
(u'A_String', u'B_String', u'F_String'): 201,
}
First row in dic_3 is nested in first row in dic_2 and dic_1
First row in dic_2 is nested in first row of dic_1
I tried :
for key in dic_1:
print '-',key
for k in dic_2:
if k in tuple(key):
print '--', k
for i in dic_3:
if i in tuple(k):
print '---', i
Thank you in advance !
| <python><python-2.7><dictionary> | 2016-01-05 14:43:47 | LQ_EDIT |
34,614,551 | Why Android Fragment showing incompatible? | <p>I going to add a fragment to an Activity . But its shows following problems . May be it's not compatible .Has there any solution ?</p>
<pre><code> media/arifhasnat/1ED0E5663F78E3C1/
AjkerDeal/CustomNavigation/MyApplication/
app/src/main/java/navigationdrawer/arifhasnat
/com/androidcustomnavigationdrawer/
MainActivity.java:22: error: incompatible types:
FragmentOne cannot be converted to Fragment
fragmentTransaction.replace(R.id.frame_one, new FragmentOne()).commit();
</code></pre>
<p>Here my code: Its the Main Activity where i called Fragment class </p>
<pre><code> package navigationdrawer.arifhasnat.com.androidcustomnavigationdrawer;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
private String[] mNavigationDrawerItemTitles;
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nav);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame_one, new FragmentOne()).commit();
}
}
</code></pre>
<p>Fragment :</p>
<pre><code>package navigationdrawer.arifhasnat.com.androidcustomnavigationdrawer;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by arifhasnat on 1/5/16.
*/
public class FragmentOne extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment1,container,false);
return view;
}
}
</code></pre>
| <android><android-fragments> | 2016-01-05 14:52:17 | LQ_CLOSE |
34,614,584 | setCloseButtonIcon() method doesn't change default Close button | <p>I try to change default icon for Close Button in Chrome custom tabs (CustomTabsIntent.Builder)</p>
<p>Simple code for testing:</p>
<pre><code>Bitmap closeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
intentBuilder.setCloseButtonIcon(closeIcon);
</code></pre>
<p>But nothing happens. Why? (Nexus 7, Marshmallow)</p>
| <android><chrome-custom-tabs> | 2016-01-05 14:53:38 | HQ |
34,614,653 | Is the arguments object supposed to be an iterable in ES6? | <p>In ES6, I was trying to use the <code>arguments</code> object as an iterable when passed to the <code>Set</code> constructor. It works fine in IE11 and in Chrome 47. It does not work in Firefox 43 (throws a <code>TypeError: arguments is not iterable</code>). I've looked through the ES6 spec and cannot really find a definition of whether the <code>arguments</code> object should be an iterable or not.</p>
<p>Here's an example of what I was trying to do:</p>
<pre><code>function destroyer(arr) {
var removes = new Set(arguments);
return arr.filter(function(item) {
return !removes.has(item);
});
}
// remove items 2, 3, 5 from the passed in array
var result = destroyer([3, 5, 1, 2, 2], 2, 3, 5);
log(result);
</code></pre>
<p>FYI, I know there are various work-arounds for this code such as copying the arguments object into a real array or using rest arguments. This question is about whether the <code>arguments</code> object is supposed to be an <code>iterable</code> or not in ES6 that can be used anywhere iterables are expected.</p>
| <javascript><ecmascript-6><iterable> | 2016-01-05 14:57:08 | HQ |
34,614,772 | Change path symbols \ to / [C++] | I have a string path to my file that I want to execute .
It is for example :
E:\folderA\folderB\myfile.exe
If I write this path and I try to execute file there it says that file doesn't exist.
When I write it like that. Then it works.
E:/folderA/folderB/myFile.exe
How do I change \ to / ?
| <c++><string><windows> | 2016-01-05 15:01:49 | LQ_EDIT |
34,614,818 | Angular2 - root relative imports | <p>I have a problem with imports in angular2/typescript. I'd like to use imports with some root like 'app/components/calendar', instead only way I am able to use is something like:</p>
<pre><code>//app/views/order/order-view.ts
import {Calendar} from '../../components/calendar
</code></pre>
<p>where Calendar is defined like:</p>
<pre><code>//app/components/calendar.ts
export class Calendar {
}
</code></pre>
<p>and this obviously gets much worse the lower in hierarchy you go, deepest is '../../..' but it is still very bad and brittle. Is there any way how to use paths relative to project root? </p>
<p>I am working in Visual Studio, and relative imports seem to be the only thing that makes VS able to recognize these imports.y</p>
| <typescript><angular> | 2016-01-05 15:04:37 | HQ |
34,615,503 | Vue.js in Chrome extension | <h2>Vue.js in Chrome extension</h2>
<p>Hi! I'm trying to make a Chrome extension using Vue.js but when I write</p>
<pre><code><input v-model="email" type="email" class="form-control" placeholder="Email">
</code></pre>
<p>Chrome removes the v-model-part of the code and makes it</p>
<pre><code><input type="email" class="form-control" placeholder="Email">
</code></pre>
<p>Is there a way to prevent this?</p>
| <javascript><google-chrome><google-chrome-extension><vue.js> | 2016-01-05 15:37:41 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.