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
37,447,977
How to divide between groups of rows using dplyr?
<p>I have this dataframe:</p> <pre><code>x &lt;- data.frame( name = rep(letters[1:4], each = 2), condition = rep(c("A", "B"), times = 4), value = c(2,10,4,20,8,40,20,100) ) # name condition value # 1 a A 2 # 2 a B 10 # 3 b A 4 # 4 b B 20 # 5 c A 8 # 6 c B 40 # 7 d A 20 # 8 d B 100 </code></pre> <p>I want to group by name and divide the value of rows with <code>condition == "B"</code> with those with <code>condition == "A"</code>, to get this:</p> <pre><code>data.frame( name = letters[1:4], value = c(5,5,5,5) ) # name value # 1 a 5 # 2 b 5 # 3 c 5 # 4 d 5 </code></pre> <p>I know something like this can get me pretty close: </p> <pre><code>x$value[which(x$condition == "B")]/x$value[which(x$condition == "A")] </code></pre> <p>but I was wondering if there was an easy way to do this with dplyr (My dataframe is a toy example and I got to it by chaining multiple <code>group_by</code> and <code>summarise</code> calls).</p>
<r><dataframe><dplyr>
2016-05-25 21:32:49
HQ
37,448,159
What does "! []" Elm code syntax in Todomvc mean
<p>Coming from react, I am learning to understand Elm.</p> <p>In the <a href="https://github.com/evancz/elm-todomvc/blob/master/Todo.elm">Todomvc example code</a>, there is the following code snippet:</p> <pre><code>-- How we update our Model on a given Msg? update : Msg -&gt; Model -&gt; ( Model, Cmd Msg ) update msg model = case msg of NoOp -&gt; model ! [] &lt;-- What is this? </code></pre> <p>What I (think I) understand, is that the <code>update</code> function takes in a <code>msg</code> of type <code>Msg</code> and a <code>model</code> of type <code>Model</code>, and returns a tuple of containing a <code>Model</code> and a <code>Cmd Msg</code>.</p> <p>But how should I read the return statement?</p> <pre><code>model ! [] </code></pre> <p>What does this statement mean? return a "model [something] empty list"?<br> Did I miss something in the docs where this is explained? (Googling "elm !" did not get me far :)</p>
<elm>
2016-05-25 21:45:09
HQ
37,448,338
How to include Glyphicons without using Bootstrap CSS
<p>My Client project using some basic HTML and CSS. But they like the Glyphicons on the Website menus. So i just tried to include Glyphicons with the Bootstrap CSS, it does, but the other css got affected after including the Bootstrap CSS. </p> <p>So the question may be silly, I just want to include Glyphicons in client website menu links without bootstrap css. </p> <p>Is that possible first? I know Glyphicons free will be available with Bootstrap Package. </p> <p>And other things is that my client do not want me to include Bootstrap CSS since it is affecting page structure. </p> <p>So is it possible to include Glyphicons without Bootstrap css or my own custom css?</p> <p>Any help would be appreciated!</p>
<html><css><twitter-bootstrap><twitter-bootstrap-3><glyphicons>
2016-05-25 21:58:42
HQ
37,448,347
Editing a .csv file with a batch file
<p>this is my first question on here. I work as a meteorologist and have some coding experience, though it is far from professionally taught. Basically what I have is a .csv file from a weather station that is giving me data that is too detailed. (65.66 degrees and similar values) What I want to do is automate a way via a script file that would access the .csv file and get rid of values that were too detailed. (Take a temp from 65.66 to 66 (rounding up for anything above .5 and down for below) or for a pressure (29.8889) and making it (29.89) using the same rounding rules.) Is this possible to be done? If so how should I go about it. Again keep in mind that my coding skills for batch files are not the strongest. </p> <p>Any help would be much appreciated. </p> <p>Thanks,</p>
<csv><batch-file>
2016-05-25 21:59:25
LQ_CLOSE
37,448,624
'AnonymousUser' object is not iterable
<pre><code>if not request.user.is_authenticated: return None try: return ClientProfile.objects.get(user=request.user) except ClientProfile.DoesNotExist: return None </code></pre> <p>This code should return None, if I'm not logged in and trying to call it. But as I see from stacktrace, it crashes with error "'AnonymousUser' object is not iterable" on this line:</p> <pre><code>return ClientProfile.objects.get(user=request.user) </code></pre> <p>I'm browsing the following page in private mode, so I'm 100% not authenticated. </p> <p>How to fix this issue?</p>
<django><django-authentication>
2016-05-25 22:22:24
HQ
37,448,764
ASP.NET Core RC2 Project Reference "The Dependency X could not be resolved"
<h2>Overview</h2> <p>I've got an ASP.NET Core RC2 .NET framework web project, and I'd like to add a project reference to my regular C# class library contained within the same solution.</p> <h2>Steps to repro:</h2> <p>Using Visual Studio 2015 Update 2</p> <p>File -> New Project -> <code>ASP.NET Core Web Application (.NET Framework)</code></p> <p>Right click solution -> New Project -> <code>Class Library</code></p> <p>I'm not making any of these:</p> <ul> <li><code>Class Library (.NET Core)</code></li> <li><code>Class Library (Portable for iOS, Android, and Windows)</code></li> <li><code>Class Library (Portable)</code></li> </ul> <p>Add the following to <code>dependencies</code> in project.json:</p> <pre><code>"ClassLibrary1": { "version": "*", "target": "project" } </code></pre> <h2>Issue</h2> <p>Why can I not add <code>"target":"project"</code> to my dependencies when specifying a project dependency?</p> <p><a href="https://i.stack.imgur.com/1dpdA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1dpdA.png" alt="enter image description here"></a></p> <h2>Expectation</h2> <p>I expect this ASP.NET Core RC2 web application (.NET Framework) to be able to reference a regular class library as a project reference.</p> <p><strong>This works</strong></p> <pre><code>"ClassLibrary1": "*" </code></pre> <p><strong>This does not work</strong></p> <pre><code>"ClassLibrary1": { "version": "*", "target": "project" } </code></pre> <h2>My Question</h2> <p><strong>How do I add a project reference to my regular class library from an ASP.NET Core RC2 web project?</strong></p> <h2>Additional Information</h2> <p>If I run <code>dotnet restore</code> I get a better error message on why this can not be resolved.</p> <pre><code>dotnet : At line:1 char:1 + dotnet restore + ~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError Errors in C:\users\joshs\documents\visual studio 2015\Projects\WebApplication4\src\WebApplication4\project.json Unable to resolve 'ClassLibrary1' for '.NETFramework,Version=v4.6.1'. </code></pre> <p>I doubled checked the class library targets .NET Framework 4.6.1</p> <p><a href="https://i.stack.imgur.com/4hZYE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4hZYE.png" alt="enter image description here"></a></p> <p>I've already taken a look at <a href="https://stackoverflow.com/questions/37309368/cannot-add-reference-to-net-core-class-library-asp-net-core-rc2">cannot add reference to .net core Class library asp.net core rc2</a>, but that's for a .NET Core class library.</p> <p>I also looked at <a href="https://stackoverflow.com/questions/37398128/reference-a-full-framework-library-project-from-asp-net-core-mvc-web-application">Reference a Full Framework Library Project from ASP.NET Core MVC Web Application (RC2)?</a>, but that's because the user was trying to create a web project not targeting .NET Framework. My project.json contains:</p> <pre><code> "frameworks": { "net461": { } }, </code></pre> <p>If I right click my web project and 'Add reference' and then proceed to pick my class library, it puts the project dependency in a different part of the project.json, but it still gives me the same error message.</p> <pre><code>"frameworks": { "net461": { "dependencies": { "ClassLibrary1": { "target": "project" } } } }, </code></pre>
<c#><visual-studio-2015><asp.net-core>
2016-05-25 22:35:49
HQ
37,449,504
How to make windows read all .dll files while scanning the c: drive
<p>I am trying to make file scanner that scans for dlls. I try to scan my C: Drive but it doesn't scan the whole thing it just scans the portion with some random .txt and .sys files</p> <pre><code>using System; using System.IO; using System.Diagnostics; using System.Threading; namespace DLLScanner { class CheaterBeater { static System.Collections.Specialized.StringCollection log = new System.Collections.Specialized.StringCollection(); static void Main () { string[] drives = System.Environment.GetLogicalDrives (); foreach (string dr in drives) { System.IO.DriveInfo di = new System.IO.DriveInfo (dr); if (!di.IsReady) { Console.WriteLine ("The drive {0} could not be read or processed (32 Bit System)", di.Name); continue; } System.IO.DirectoryInfo rootDir = di.RootDirectory; WalkDirectoryTree (rootDir); } Console.WriteLine ("These are files with restricted access or could not be processed:"); foreach (string s in log) { Console.WriteLine (s); } Console.WriteLine ("Press any key to exit"); Console.ReadKey (); } static void WalkDirectoryTree (System.IO.DirectoryInfo root) { System.IO.FileInfo[] files = null; System.IO.DirectoryInfo[] subDirs = null; // First, process all the files directly under this folder try { files = root.GetFiles ("*.*"); } catch (UnauthorizedAccessException e) { log.Add (e.Message); } catch (System.IO.DirectoryNotFoundException e) { Console.WriteLine (e.Message); } if (files != null) { foreach (System.IO.FileInfo fi in files) { Console.WriteLine (fi.FullName); } } } } } </code></pre> <p>Any help is appreciated :)</p>
<c#><file>
2016-05-26 00:03:47
LQ_CLOSE
37,449,900
Contact form not working from free template
<p>I got this free template but the contact form is not working at all. It says the message was sent but I don't receive any email. The form looks really nice that's why I don't want to change it but it's not working. The developer does not provide technical help for free templates. Please help me and thank you in advance!</p> <p>HTML</p> <pre><code> &lt;form id="main-contact-form" name="contact-form" role="form" method="post" action="sendemail.php"&gt; &lt;div class="form_status" style="display: none;"&gt;&lt;p class="text-success"&gt;Thank you for contacting us. We'll get back to you shortly.&lt;/p&gt;&lt;/div&gt; &lt;div class="form-group"&gt; &lt;input type="text" name="name" class="form-control" placeholder="Name" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;input type="email" name="email" class="form-control" placeholder="Email" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;input type="text" name="subject" class="form-control" placeholder="Subject" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;textarea name="message" class="form-control" rows="8" placeholder="Message" required&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;button type="submit" class="btn btn-primary"&gt;Send Message&lt;/button&gt; &lt;/form&gt; </code></pre> <p>PHP</p> <pre><code>&lt;?php $name = @trim(stripslashes($_POST['name'])); $from = @trim(stripslashes($_POST['email'])); $subject = @trim(stripslashes($_POST['subject'])); $message = @trim(stripslashes($_POST['message'])); $to = 'nikita_lim@rocketmail.com';//replace with your email $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: {$name} &lt;{$from}&gt;"; $headers[] = "Reply-To: &lt;{$from}&gt;"; $headers[] = "Subject: {$subject}"; $headers[] = "X-Mailer: PHP/".phpversion(); mail($to, $subject, $message, $headers); die; </code></pre> <p>JS</p> <pre><code>var form = $('#main-contact-form'); form.submit(function(event){ event.preventDefault(); var form_status = $('&lt;div class="form_status"&gt;&lt;/div&gt;'); $.ajax({ url: $(this).attr('action'), url: '../sendemail.php', //type : $(this).attr('method'), //data : $(this).serialize(), beforeSend: function(){ form.prepend( form_status.html('&lt;p&gt;&lt;i class="fa fa-spinner fa-spin"&gt;&lt;/i&gt; Email is sending...&lt;/p&gt;').fadeIn() ); } }).done(function(data){ form_status.html('&lt;p class="text-success"&gt;Thank you for contacting us. We will get back to you shortly&lt;/p&gt;').delay(3000).fadeOut(); }); }); </code></pre>
<javascript><php><twitter-bootstrap><contact-form>
2016-05-26 00:57:36
LQ_CLOSE
37,450,344
How to convert Automation element in to UITestControl
<p>I came across one scenario where I have to identify object using Windows UI automation element.</p> <p>I want to convert this object back to UITestControl, so that I can use inbuilt methods like waitforcontrol ready etc.</p> <p>How Can I do this?</p> <p>regards,</p> <p>User232482</p>
<coded-ui-tests>
2016-05-26 01:58:17
LQ_CLOSE
37,450,542
Using the Facebook JS SDK in a Module (webpack)
<p>I'm using webpack to keep my JavaScript code organized in modules but I'm running into a problem trying to load the Facebook JS SDK. I've tried using the <code>externals</code> option of webpack but since the library is loaded asynchronously I don't think it will provide the answer I am looking for.</p> <p>There was an issue for webpack that addressed this problem. However, I don't think it works any longer. <a href="https://github.com/webpack/webpack/issues/367">https://github.com/webpack/webpack/issues/367</a></p> <p>What would be a good approach to this problem? Should I just load the SDK synchronously? </p>
<javascript><facebook><webpack>
2016-05-26 02:26:26
HQ
37,450,969
ROTATE Google-Map to display my real-time DIRECTION
<p>I am using the Google Maps Android API v2 where I display my Device location as a GoogleMap Marker on a Map. I have a listener (LocationServices.FusedLocationApi.requestLocationUpdates...) attach to the Map in order to handle every GPS location change. Every time I receive a new location I update the Marker (my position) as well as the Camera on the Map and pretty much it shows like I am moving as I drive. </p> <p>However... I need some help in order to have the MAP <strong>rotate</strong> and/or <strong>display</strong> on the same direction that I am moving to. I mean, while I drive I need to rotate the MAP where I can see on my map-left-side what I have on my real-life-left-side, and so the same with the right. Since the MAP direction is static, the Marker (Me) is moving on it but most of the time the direction does not match my car real-time direction.</p> <p>What should I do with the Map in order to accomplish this visual effect?</p>
<android><google-maps>
2016-05-26 03:17:02
HQ
37,451,029
What programming language would I need to create a sign in and login form?
<p>What programming language would I need to create a sign in and login form? Can I use only php to do that? I'm new to this area. So, any link referring to the procedure would be helpful.</p> <p>Thanks in advance.</p>
<php><forms>
2016-05-26 03:24:23
LQ_CLOSE
37,451,248
Autocapitalization of first letter of edit text not working
i am trying to add edittext with inputtype = textCapWords but it is not working for me . ihave also tried textcapsentences but it is also not working. <EditText android:id="@+id/editText2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/d1" android:textCursorDrawable="@drawable/custom_cursor" android:background="@drawable/text_field_account" android:gravity="left|center_vertical" android:hint="@string/Last_Name" android:inputType="se" android:maxWidth="30dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:singleLine="true" android:text="" android:maxLength="30" android:textColor="@color/black000" android:textColorHint="@color/text_color_hint" android:textSize="@dimen/font_n" />
<android><android-edittext>
2016-05-26 03:49:44
LQ_EDIT
37,451,395
Firebase onTokenRefresh() is not called
<p>In my <code>MainActivity</code>in my log, I can see the token using <code>FirebaseInstanceId.getInstance().getToken()</code> and it display the generated token. But it seems like in my <code>MyFirebaseInstanceIDService</code> where it is extends to <code>FirebaseInstanceIdService</code>, the <code>onTokenRefresh()</code> is not called, where in this function it was said that the token is initially generated here. I needed to call <code>sendRegistrationToServer()</code> that's why I'm trying to know why it doesn't go in the <code>onTokenRefresh()</code>. </p> <p>Here is my code</p> <pre><code>public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { @Override public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken); sendRegistrationToServer(refreshedToken); } } </code></pre>
<android><firebase><firebase-cloud-messaging><firebase-notifications>
2016-05-26 04:05:39
HQ
37,451,494
Fastest way to grep list 1000 reocrds in another million of records in a file in linux
Fastest way to grep list 1000 reocrds in another million of records in a file in linux . Let's say these are my sample records : 1,,EE1,1000,WAT,EEE,20160222T02:00:15+0400,20181231T23:59:59+0400,,vEEE,,47126469f184fee9a80664d952d7fea7,50278774602,95223904,140495221530736,21001,,,,,,,,,,,,,,,C 0,,EE1,1000,WAT,EEE,20160222T02:00:15+0400,20181231T23:59:59+0400,20160222T02:00:15+0400,,vEEE,47126469f184fee9a80664d952d7fea7,50278774602,,,21001,,,,,,,,,,,,,,,H 1,,EE1,1000,WAT,EEE,20160222T02:00:15+0400,20181231T23:59:59+0400,20160521T11:07:25+0400,,vEEE,47126469f184fee9a80664d952d7fea7,50278774602,0095223904,140495221530736,21001,,,,,,,,,,,,,,,H If i grep 50278774602 the values will come in three rows. I have developed one script using for loop on the same , i have a list to such numbers in a file and i am searching the value in the big file (millions of row) and i need only the last occurrence of such row containing my grep pattern , it works perfectly with for loop but my concern is its taking huge time . My script : for i in `cat /home/admin/pnd_tmp`; do grep $i /test/done/TEST_RT* | tail -1 > /home/admin/pnd_fin | awk -F "," '{if ( $1 == "4" ) print $13 }' > /home/admin/pnd_tmp_fin; done Can anyone write me a simple script to find in a quickest time .
<python><linux><bash><shell><awk>
2016-05-26 04:15:35
LQ_EDIT
37,451,615
How to get last installed/updated Jenkins plugins?
<p>My Jenkins instance interface broken. I suspect recent plugin update as the cause. However I cannot remember which plugins get updated recently. I need to know so I can rollback plugin version to the previous one.</p> <p>How to find this information?</p> <p>Some possible way:</p> <ul> <li>Jenkins log</li> <li>Retrieving plugins info via Groovy console</li> </ul>
<jenkins><jenkins-plugins>
2016-05-26 04:27:56
HQ
37,452,402
Webpack loaders vs plugins; what's the difference?
<p>What is the difference between loaders and plugins in webpack? </p> <p>The <a href="https://webpack.github.io/docs/using-plugins.html">documentation for plugins</a> just says:</p> <blockquote> <p>Use plugins to add functionality typically related to bundles in webpack.</p> </blockquote> <p>I know that babel uses a loader for jsx/es2015 transforms, but it looks like other common tasks (copy-webpack-plugin, for example) use plugins instead.</p>
<javascript><reactjs><webpack>
2016-05-26 05:37:01
HQ
37,453,235
TypeError: Cannot match against 'undefined' or 'null'
<p><strong>Code</strong></p> <pre><code>client.createPet(pet, (err, {name, breed, age}) =&gt; { if (err) { return t.error(err, 'no error') } t.equal(pet, {name, breed, age}, 'should be equivalent') }) </code></pre> <p><strong>Error</strong></p> <pre><code>client.createPet(pet, (err, {name, breed, age}) =&gt; { ^ TypeError: Cannot match against 'undefined' or 'null'. </code></pre> <p>Why am I getting this error? My knowledge of ES6 led me to presume that this error should only arise if the <em>array or object being destructured or its children</em> is <code>undefined</code> or <code>null</code>.</p> <p>I wasn't aware that function parameters are used as a match. And if they are then why is it only an error if I try to destructure one of them? (that isn't <code>undefined</code> or <code>null</code>).</p>
<javascript><node.js><ecmascript-6>
2016-05-26 06:34:18
HQ
37,453,828
I want to find all words using java regx, that starts with "#" and ends with space or "."
This is a sample string "hi #myname, you got #amount", I want to find all words using java regx, that starts with "#" and ends with space or "." example "#myname","#amount" I use Java.
<java><regex><string><pattern-matching><matcher>
2016-05-26 07:06:34
LQ_EDIT
37,454,248
How to solve Googlecloudmessaging cannot be resolved to a type error?
I am trying to create GCM Push Notification. I followed the same steps described in below link: http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/ After installing google-play-services using sdk manager, google-play-services folder is created but inside it there is no folder of lib. And I got the error of 'googlecloudmessaging cannot be resolved to a type'. How to resolve it? Plzz help me... Thanks
<android><google-cloud-messaging>
2016-05-26 07:28:46
LQ_EDIT
37,455,322
Vertical align content slickslider
<p>I've been struggling to get my content vertical aligned but really don't fix it. I tried the adaptiveHeight parameter but it really didn't do what I wanted.</p> <p>Fiddle: <a href="http://jsfiddle.net/fmo50w7n/400" rel="noreferrer">http://jsfiddle.net/fmo50w7n/400</a></p> <p>This is what the code looks like HTML:</p> <pre><code>&lt;section class="slider"&gt; &lt;div style="width:500px;height:200px"&gt;slide1&lt;/div&gt; &lt;div style="width:500px;height:300px;"&gt;slide2&lt;/div&gt; &lt;div style="width:500px;height:100px;"&gt;slide3&lt;/div&gt; &lt;/section&gt; </code></pre> <p>CSS:</p> <pre><code>$c1: #3a8999; $c2: #e84a69; .slider { width: auto; margin: 30px 50px 50px; } .slick-slide { background: $c1; color: white; padding: 40px 0; font-size: 30px; font-family: "Arial", "Helvetica"; text-align: center; } .slick-prev:before, .slick-next:before { color: black; } .slick-dots { bottom: -30px; } .slick-slide:nth-child(odd) { background: $c2; } </code></pre> <p>JS:</p> <pre><code>$(".slider").slick({ autoplay: true, dots: true, variableWidth:true, responsive: [{ breakpoint: 500, settings: { dots: false, arrows: false, infinite: false, slidesToShow: 2, slidesToScroll: 2 } }] }); </code></pre>
<css><vertical-alignment><slick.js>
2016-05-26 08:20:57
HQ
37,456,215
dialog - The specified child already has a parent. You must call removeView() on the child's parent first
<p>After a check demanding the user to switch on internet services and I try to click on a button my app crashes with the error message</p> <pre><code>java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. </code></pre> <p>On this line it crashes, I have tried doing this but not resolved absolutely</p> <pre><code>if(alert.getContext() != null){ alert.show(); } </code></pre> <p>This is the complete code</p> <pre><code>else if (id == R.id.xyz) { //startActivity(borrowIntent); AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); alert.setTitle("xyz"); input.setFilters(new InputFilter[] { // Maximum 2 characters. new InputFilter.LengthFilter(6), // Digits only. DigitsKeyListener.getInstance(), }); // Digits only &amp; use numeric soft-keyboard. input.setKeyListener(DigitsKeyListener.getInstance()); input.setHint("xyz"); alert.setView(input); alert.setPositiveButton("Borrow", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if(input.getText().length() == 0) { input.setError("xyz is required !"); } else { if(isNetworkAvailable()) { xyz( input.getText().toString()); }else{ //setContentView(R.layout.main); AlertDialog.Builder builder = new AlertDialog.Builder( MainActivity.this); builder.setCancelable(false); builder.setTitle("xyz"); builder.setMessage("Please enable wifi services"); builder.setInverseBackgroundForced(true); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); dialog.dismiss(); } }); AlertDialog alerts = builder.create(); alerts.show(); }//end of block } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); if(alert.getContext() != null){ alert.show(); //crashes at this line } } </code></pre> <p>Please what am I missing?</p>
<java><android>
2016-05-26 09:02:52
HQ
37,456,283
Implement Hashmap with different value types in Kotlin
<p>Is it possible to have a hashmap in Kotlin that takes different value types?</p> <p>I've tried this:</p> <pre><code>val template = "Hello {{world}} - {{count}} - {{tf}}" val context = HashMap&lt;String, Object&gt;() context.put("world", "John") context.put("count", 1) context.put("tf", true) </code></pre> <p>... but that gives me a type mismatch (apparantly <code>"John"</code>, <code>1</code> and <code>true</code> are not Objects) </p> <p>In Java you can get around this by creating types <code>new String("John")</code>, <code>new Integer(1)</code>, <code>Boolean.TRUE</code>, I've tried the equivalent in Kotlin, but still getting the type mismatch error.</p> <pre><code>context.put("tf", Boolean(true)) </code></pre> <p>Any ideas?</p>
<hashmap><kotlin>
2016-05-26 09:05:11
HQ
37,456,879
WHY IT IS SHOWING ENUM ,INTERFACE EXPECTING ERRORS?
THIS program is showing this errors asking interface in package concept...why is it so? can't i do package without using interfaces? i tried with that too..but still the same error is showing..what to do..pls help please click on this link fr the screenshot [errors regaring interface and enum][1] [1]: http://i.stack.imgur.com/Jjq8W.jpg
<java><interface><enums>
2016-05-26 09:32:45
LQ_EDIT
37,456,952
How to convert varchar to number
<p>I have character string as '00000625710' I want it as number 6257.10 how can I do that . I tried as follow <code>select to_number('00000002511','999999999.99')from dual;</code></p> <p>But didn't work . can any one help me in this . Thank you.</p>
<sql><oracle><plsql>
2016-05-26 09:36:08
LQ_CLOSE
37,457,091
Hi Guys I am working on android and I want to Embed Google Maps to my App
But to do that I need Google Maps v2 API key and to get that from the Google console I have to enter SHA1 of my app. What the problem is I can't get the SHA1 of the app because I am developing it using AIDE. I saw a solution on Google plus blog-it suggest to use zipSigner app to get it but I can't understand it as it isn't proofed. So how can I get the SHA1 on AIDE? Tanx for your help.....
<java><android><google-maps>
2016-05-26 09:42:32
LQ_EDIT
37,457,128
react open file browser on click a div
<p>My react component:</p> <pre><code>import React, { PropTypes, Component } from 'react' class Content extends Component { handleClick(e) { console.log("Hellooww world") } render() { return ( &lt;div className="body-content"&gt; &lt;div className="add-media" onClick={this.handleClick.bind(this)}&gt; &lt;i className="plus icon"&gt;&lt;/i&gt; &lt;input type="file" id="file" style={{display: "none"}}/&gt; &lt;/div&gt; &lt;/div&gt; ) } } export default Content </code></pre> <p>Here when I click a div with icon I want to open a <code>&lt;input&gt;</code> file which shows me option to select photos. After selecting the photos I want to get the value which photo is selected. How can I do this in react ??</p>
<reactjs>
2016-05-26 09:43:57
HQ
37,457,227
How can i get mobile number automatically to android app?
I am building an android app in which I consider mobile number as his unique id just like whatsapp. So can anyone please tell me how to get users number directly into my database when he install this android app.
<android><mobile><whatsapp>
2016-05-26 09:47:44
LQ_EDIT
37,457,498
IndentationError: expected an indented block when trying to reproduce LDA for a document
<p>I am trying to obtain the LDA distribution among the first article of my collection but I am running into several errors:</p> <p>my collection: <code>doc_set</code>, is a <code>pandas.core.series.Series</code>. Whenever I wanted to run the simple code:</p> <pre><code>print(ldamodel[doc_set[1]]) </code></pre> <p>I run the following error: <code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</code> Which I think I solved it by:</p> <pre><code>if doc_set is not None: print(ldamodel[doc_set[1]]) </code></pre> <p>Nevertheless, now I get the following error: <code>IndentationError: expected an indented block</code>. I am looking for the intuition of the error rather than the correction, I cannot put my whole LDA for reproduction because it is too massive. Thanks in advance!</p>
<python><pandas><lda>
2016-05-26 09:59:13
LQ_CLOSE
37,457,972
Low latency (< 2s) live video streaming HTML5 solutions?
<p>With Chrome disabling Flash by default very soon I need to start looking into flash/rtmp html5 replacement solutions.</p> <p>Currently with Flash + RTMP I have a live video stream with &lt; 1-2 second delay.</p> <p>I've experimented with MPEG-DASH which seems to be the new industry standard for streaming but that came up short with 5 second delay being the best I could squeeze from it.</p> <p>For context, I am trying to allow user's to control physical objects they can see on the stream, so anything above a couple of seconds of delay leads to a frustrating experience.</p> <p>Are there any other techniques, or is there really no low latency html5 solutions for live streaming yet?</p>
<html><video-streaming><rtmp><mpeg-dash>
2016-05-26 10:19:16
HQ
37,458,594
Even number count from an integer
How to get the even number count from an integer input. > var intInput = 10; Now i want the even count. In this case = 2+4+6+8+10 = 30 > var evenCount = 0; if (i % 2==0) { evenCount = evenCount + i; } How to achieve this?
<c#>
2016-05-26 10:46:15
LQ_EDIT
37,458,814
How to open remote files in sublime text 3
<p>I am connecting to remote server using "mRemoteNG" and want to open remote server files in my local sublime text editor. During my research, I found this relevant blog <a href="https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/" rel="noreferrer">https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/</a> and followed the instructions but it is not working for me. Does, anybody know how can I open remote files in my Sublime?</p>
<ssh><sublimetext3><remote-server>
2016-05-26 10:54:52
HQ
37,459,122
How to Pass IValueConverter Parameter?
<p>In XAML, <code>&lt;Grid x:Name="MainGrid3"&gt;</code>, Here I want to pass <code>MainGrid3</code> as a parameter of <code>IValueConverter</code>. How can I do this?<a href="https://i.stack.imgur.com/4l28Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4l28Y.png" alt="enter image description here"></a></p>
<wpf><xaml>
2016-05-26 11:08:25
HQ
37,459,383
React Native WebView pre-render for faster performance - how to do it?
<p>In React Native, when using the WebView component, it starts to load the external content at the moment when the component will be rendered. </p> <p>To increase performance in the application, I have tried to pre-fetch the external HTML so that it is ready when the component will be rendered. It seems like it is only an actual call to the render method will cause the loading to start and this is only controlled by what is rendered on the screen. I suppose React Native has no concept of shadow DOM that could be used to call the render method a head of time. Trying to manipulate the lifecycle methods does also not work and is probably not a correct way of doing it either? </p> <p>I have also tried to do a <code>fetch()</code> of the external HTML-content, with the right user-agent in the header, and pass the responseText to the WebComponent. This sometimes works for some sites of sources, but for others i run into ACAP (Automated Content Access Protocol) issues, to this is not the preferred solution.</p> <p>Is there a way to pre-fetch external HTML content to a WebView component so that it displays faster?</p>
<webview><react-native>
2016-05-26 11:20:01
HQ
37,460,402
Differences between using Lambda Expresions and without using it?
Could someone explain my the differences between methods using lambda expresions and without using it ? On the example : Function<Double, Double> function; public void methodCounting() { this.function = x -> x = x + 2; } public void methodCounting(double x) { x = x + 2; return x; } What do we gain ?
<java><lambda>
2016-05-26 12:06:28
LQ_EDIT
37,460,600
Is there a way to disconnect USB device from ADB?
<p>I have a lot of scripts that use ADB to debug Android applications via Wi-Fi with emulators. The problem appears when I charge my Android phone via USB from my computer: ADB sees it and sends commands to my phone instead of emulator. <strong>Is there a way to disconnect ADB from phone that charges via USB?</strong> I know I can send commands to emulators only via <code>-e</code> switch, as well as send them to specific device via <code>-s</code> switch. However, it is not OK for me, because I have to rewrite a lot of scripts to add more arguments if I want to implement this device selection feature. I don't need workarounds, I just curious does Google <em>force</em> ADB to debug any phone connected via USB that has USB debugging enabled in settings, or it is possible to remove specific USB connected phone from devices list on ADB side? When I run <code>adb disconnect</code>, USB device remains connected.</p>
<android><adb>
2016-05-26 12:15:59
HQ
37,460,626
why cant we use orginal for loop for Set
<p>The basic difference between the set and the list is that set wont allow the duplicates the question is why cant we use original for loop for the set as we use for list</p> <p>eg: length of set and list is same</p> <pre><code> for(int i =0 ; i&lt; list.size;i++){ list.get(i); set.get(i); // here it is throwing an error like get(index ) cant be applied for set </code></pre> <p>}</p> <p>but if i use advance for loop(for each) its working </p> <pre><code>for(Object sample : set){ system.out.println(sample); </code></pre> <p>}</p> <p>why is this happening ... is there any operational defference between for loop and for each , set and list ....</p> <p>any help and suggestion would be useful ... thank you in advance</p>
<java><list><set>
2016-05-26 12:16:57
LQ_CLOSE
37,461,611
Absolute positioning ignoring padding
<p>I am trying to position a div with buttons at the bottom of a parent div that has a padding.</p> <p><a href="https://i.stack.imgur.com/pQdi9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pQdi9.png" alt="current result"></a></p> <p>The expected result is having the button resting on top of the padding (green area).</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.btn-default, .btn-default:hover, .btn-default:focus { color: #333; text-shadow: none; /* Prevent inheritence from `body` */ background-color: #fff; border: 1px solid #fff; } a, a:focus, a:hover { color: #fff; } body { background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.6)), url("../img/blank.jpg"); background-attachment: fixed; background-size: cover; background-repeat: no-repeat; background-position: center top; } html, body { height: 100%; } body { color: #fff; text-align: left; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); } #mcontainer { position: relative; float: left; padding: 10%; width: 100%; height: 100%; } #header h1 { margin: 0px; } #header { height: auto; } #footer .link-item a { display: table-cell; padding: 10px 10px; border: 2px solid white; } #footer { position: absolute; top: auto; bottom: 0%; height: auto; } #footer .link-item:first-child { border-spacing: 0px 10px; margin: 10px 10px 10px 0px; } #footer .link-item { border-spacing: 0px 10px; margin: 10px 10px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;body&gt; &lt;div id="mcontainer"&gt; &lt;div id="header"&gt; &lt;h1&gt;Text&lt;/h1&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;span class="link-item"&gt;&lt;a href="www.google.com" target="new"&gt;Button&lt;/a&gt; &lt;/span&gt; &lt;span class="link-item"&gt;&lt;a href="www.google.com" target="new"&gt;Button&lt;/a&gt; &lt;/span&gt; &lt;span class="link-item"&gt;&lt;a href="www.google.com" target="new"&gt;Button&lt;/a&gt; &lt;/span&gt; &lt;span class="link-item"&gt;&lt;a href="www.google.com" target="new"&gt;Button&lt;/a&gt; &lt;/span&gt; &lt;span class="link-item"&gt;&lt;a href="www.google.com" target="new"&gt;Button&lt;/a&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>Any help would be appreciated.</p>
<html><css>
2016-05-26 12:59:42
HQ
37,462,132
Update mouse cursor without moving mouse with changed CSS cursor property
<p>I currently have a C# host that mirrors the screen and mouse on a website, the connection works totally fine, and when the mouse changes on the host, it changes the CSS almost immediatly. This way I can mirror the mouse too.</p> <p><strong>So here is the problem:</strong></p> <p><em>The mouse only updates when I move the mouse on the client website.</em></p> <p>Speed and performance is very important here, a quick fix would be to refresh the canvas, or move the page/mouse a little bit, but I'd rather have a more sophisticated approach.</p>
<javascript><c#><jquery><html><css>
2016-05-26 13:22:53
HQ
37,462,365
Laravel cache store does not support tagging
<p>I am getting this error since I installed <strong>Zizaco\Entrust</strong> on my Authentication Routes.</p> <pre><code>BadMethodCallException: This cache store does not support tagging. </code></pre> <p>I had few known issues and I had to change some config options and that is the reason I am getting this error.</p> <p>What does this error relate to so that I can find the problem and fix it instead of finding the code I modified?</p> <p>Thanks</p>
<laravel>
2016-05-26 13:32:08
HQ
37,462,550
Flyway repair with Spring Boot
<p>I don't quite understand what I am supposed to do when a migration fails using Flyway in a Spring Boot project.</p> <p>I activated Flyway by simply adding the Flyway dependency in my <code>pom.xml</code>. And everything works fine. My database scripts are migrated when I launch the Spring Boot app.</p> <p>But I had an error in one of my scripts and my last migration failed. Now when I try to migrate, there is a "Migration checksum mismatch". Normally, I would run <code>mvn flyway:repair</code>, but since I am using Spring Boot, I am not supposed to use the Flyway Maven plug-in. So what am I supposed to do?</p>
<java><spring><maven><spring-boot><flyway>
2016-05-26 13:39:28
HQ
37,462,620
I cannot get NSUserdefaults to work, tried all i know, anyone had same issue?
I cant get nsuserdefaults to save a bool value, its really simple and people do it but it just simply will not save, tried everything i know, most recent attempt being this: if (_EndHide == YES) { NSDictionary *aProperties=[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]forKey:@"EndHide"]; BOOL boolValue; if([aProperties valueForKey:@"EndHide"]) boolValue =[[aProperties valueForKey:@"EndHide"] boolValue]; } else if (_EndHide == NO) { NSDictionary *aProperties=[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]forKey:@"EndHide"]; BOOL boolValue; if([aProperties valueForKey:@"EndHide"]) boolValue =[[aProperties valueForKey:@"EndHide"] boolValue]; } what happens is, i am making ios app a game for iphone, and when you dodged these well objects for period of time, you end the game and unlock a button on the start menu named endless, after the story, now i need this button to be constantly unlocked, i managed to unlock it through a scene its all working but it just wont stay unlocked, does any one have any advice to help me with this? here is the endless button configuration and bool configuration: @property(nonatomic, getter=isActive) bool EndHide; @property(nonatomic) IBOutlet UIButton *endless; thats all the code for the buttons and bools, anyway to keep it unlocked? i know its simple but it wont work maybe a deep bug i tried it on another more updated version of xcode but still to no avail, the issue is persistent and a real problem, i even tried switch saving that didnt work aswell..
<ios><objective-c><nsuserdefaults>
2016-05-26 13:42:44
LQ_EDIT
37,462,725
Suppress reader parse problems in r
<p>I am currently reading in a file using the package <code>readr</code>. The idea is to use <code>read_delim</code> to read in row for row to find the maximum columns in my unstructured data file. The code outputs that there are <code>parsing</code> problems. I know of these and will deal with column type after import. Is there a way to turn off the <code>problems()</code> as the usual <code>options(warn)</code> is not working</p> <pre><code>i=1 max_col &lt;- 0 options(warn = -1) while(i != "stop") { n_col&lt;- ncol(read_delim("file.txt", n_max = 1, skip = i, delim="\t")) if(n_col &gt; max_col) { max_col &lt;- n_col print(max_col) } i &lt;- i+1 if(n_col==0) i&lt;-"stop" } options(warn = 0) </code></pre> <p>The output to console that I am trying to suppress is the following:</p> <pre><code>.See problems(...) for more details. Warning: 11 parsing failures. row col expected actual 1 1####4 valid date 1###8 </code></pre>
<r><readr>
2016-05-26 13:47:14
HQ
37,463,092
Firebase 2.0 - how to deal with multiple flavors (environments) of an android app?
<p>I have multiple flavors of my app. How should I set this up server side? My package names are:</p> <p><code>com.example.app</code> (production) <code>com.example.app.staging</code> (staging) <code>com.example.app.fake</code> (fake)</p> <p>Should this be 3 separate projects in the firebase console?</p>
<android><firebase><google-cloud-platform>
2016-05-26 14:01:17
HQ
37,463,226
Using repository pattern to eager load entities using ThenIclude
<p>My application uses Entity Framework 7 and the repository pattern.</p> <p>The GetById method on the repository supports eager loading of child entities:</p> <pre><code> public virtual TEntity GetById(int id, params Expression&lt;Func&lt;TEntity, object&gt;&gt;[] paths) { var result = this.Set.Include(paths.First()); foreach (var path in paths.Skip(1)) { result = result.Include(path); } return result.FirstOrDefault(e =&gt; e.Id == id); } </code></pre> <p>Usage is as follows to retrieve a product (whose id is 2) along with the orders and the parts associated with that product:</p> <pre><code>productRepository.GetById(2, p =&gt; p.Orders, p =&gt; p.Parts); </code></pre> <p>I want to enhance this method to support eager loading of entities nested deeper than one level. For example suppose an <code>Order</code> has its own collection of <code>LineItem</code>'s. </p> <p>Prior to EF7 I believe the following would have been possible to also retrieve the LineItems associated with each order:</p> <pre><code>productRepository.GetById(2, p =&gt; p.Orders.Select(o =&gt; o.LineItems), p =&gt; p.Parts); </code></pre> <p>However this doesn't appear to be supported in EF7. Instead there is a new ThenInclude method that retrieves additional levels of nested entities:</p> <p><a href="https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015" rel="noreferrer">https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015</a></p> <p>I am unsure as to how to update my repository to support retrieval of multiple-levels of eager loaded entities using <code>ThenInclude</code>. </p>
<c#><entity-framework><repository-pattern><eager-loading><entity-framework-core>
2016-05-26 14:06:23
HQ
37,463,232
Find text in array use preg_match
<p>I have code :</p> <pre><code>Array ( [0] =&gt; Array ( [Time] =&gt; 05/24/2016 05:24 [Type] =&gt; Income [Batch] =&gt; 134410438 [Currency] =&gt; USD [Amount] =&gt; 60.00 [Fee] =&gt; 0.00 [Payer Account] =&gt; 123213 [Payee Account] =&gt; 512321 [Memo] =&gt; ,Received Payment 60.00 USD from account 123213. Memo: API Payment. EXCHANGE755531. ) </code></pre> <p>How i can find text "EXCHANGE755531" in this array use preg_match ?</p>
<php><arrays><preg-match>
2016-05-26 14:06:45
LQ_CLOSE
37,463,645
Mathematical expressions with Floating points
<p>Hello I'm a sort of newbie in Python 2.What is the simplest way to take input and print the result of a mathematical expression which has decimals? For some reason i keep getting a syntax error.Here's the code im trying to run to calculate the mean:</p> <pre><code>a = input() b = input() c = input() print "MEDIA = %.1f\n"%(((a*2)+(b*3)+(c*5))/(10))) </code></pre>
<python><python-2.7>
2016-05-26 14:24:40
LQ_CLOSE
37,463,684
R gsub stringi, stringr misunderstanding
I don't seem to understand gsub or stringr. Example: > a<- "a book" > gsub(" ", ".", a) [1] "a.book" Okay. BUT: > a<-"a.book" > gsub(".", " ", a) [1] " " I would of expected >"a book" I'm replacing the full stop with a space. Also: `srintr`: `str_replace(a, ".", " ")` returns: `" .book"` and `str_replace_all(a, ".", " ")` returns `" "` I can use `stringi`: `stri_replace(a, " ", fixed=".")`: `"a book"` I'm just wondering why gsub (and str_replace) don't act as I'd have expected. They work when replacing a space with another character, but not the other way around.
<r><gsub><stringr><stringi>
2016-05-26 14:25:49
LQ_EDIT
37,463,832
how to play/pause video in React without external library?
<p>I have a video tag () in my webpage, and a "play/pause" button that when the user clicks on it, the video starts/stops playing . How can I do so in react if I'm not allowed to use js in order to call "getElementById" and then to use play()/pause() build-in methods. Any idea? </p>
<reactjs>
2016-05-26 14:31:25
HQ
37,463,902
How to pass -parameters javac flag to Java compiler via Gradle?
<p>I have a Gradle-managed multi-project setup that relies on the new Java 8 <code>-parameters</code> compiler flag. I need 2 ways of including the compiler flag:</p> <ul> <li>To test classes only (the main project should compile without parameter names attached).</li> <li>To all compiled sources.</li> </ul> <p>I've tried this:</p> <pre><code> tasks.withType(JavaCompile) { options.compilerArgs &lt;&lt; '-parameters' options.fork = true options.forkOptions.executable = 'javac' } </code></pre> <p>...but it does not seem to be working properly.</p>
<gradle><javac>
2016-05-26 14:34:53
HQ
37,464,407
Professional/ Better way of header/body/footer layout
<p>So this is the fist way i have see this with a wrapper.</p> <pre><code> &lt;body&gt; &lt;div id="wrapper"&gt; &lt;div id="header"&gt; &lt;h1&gt;My page&lt;/h1&gt; &lt;!-- Header content --&gt; &lt;/div&gt; &lt;div id="main"&gt; &lt;!-- Page content --&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;!-- Footer content --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body </code></pre> <p>This is the second way with out a wrapper , i just wanted to know the better most used way even if it's different than these two that will not cause problems afterwards in my page.</p> <pre><code> &lt;body&gt; &lt;div id="header"&gt; &lt;h1&gt;My page&lt;/h1&gt; &lt;!-- Header content --&gt; &lt;/div&gt; &lt;div id="main"&gt; &lt;!-- Page content --&gt; &lt;/div&gt; &lt;div id="footer"&gt; &lt;!-- Footer content --&gt; &lt;/div&gt; &lt;/body </code></pre>
<javascript><html><css>
2016-05-26 14:54:57
LQ_CLOSE
37,464,518
How to format the output of kubectl describe to JSON
<p><code>kubectl get</code> command has this flag <code>-o</code> to format the output.</p> <p>Is there a similar way to format the output of the <code>kubectl describe</code> command?</p> <p>For example:</p> <pre><code>kubectl describe -o="jsonpath={...}" pods my-rc </code></pre> <p>would print a JSON format for the list of pods in <code>my-rc</code> replication controller. But <code>-o</code> is not accepted for the <code>describe</code> command.</p>
<kubernetes><output-formatting><kubectl>
2016-05-26 14:59:29
HQ
37,464,872
What should I use to run HTML/CSS/JS code?
<p>I've created a few simple HTML/CSS/JS games. This time a few friends and I are going to create another game that people can download from some website. We want to use HTML CSS and JS even though that is probably not the best option. </p> <p>All the games I created before I've used Chrome to run them. Of course I can't just make people run my games with Chrome. So how should I run it?</p>
<javascript><html><css>
2016-05-26 15:15:53
LQ_CLOSE
37,464,875
Is terraform destroy needed before terraform apply?
<p>Is terraform <code>destroy</code> needed before terraform <code>apply</code>? If not, what is a workflow you follow when updating existing infrastructure and how do you decide if <code>destroy</code> is needed?</p>
<terraform>
2016-05-26 15:16:02
HQ
37,465,309
Less file not found
<p>I am most probably doing something really stupid but I just can't figure it out. It just keeps saying file not found. I tried using crunch and the same error. The file is right there and I am positive the location is right. <a href="https://i.stack.imgur.com/0ivc8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ivc8.png" alt="enter image description here"></a></p>
<css><less>
2016-05-26 15:35:54
LQ_CLOSE
37,466,315
Is there a way to group by monthly period?
<p>I have data that I need to query to find out which person spent the most over a 9 month period. My data spans 5 years and the 9 month period may consist of months from one year and through the next year.</p> <p>For example October 2005 through July 2006.</p> <p>I've managed to group by personid and month and year, but is there a way for me to group by 9 month periods? I figured if I can do that then I can just find the max value in that grouping.</p>
<sql><sql-server><datediff>
2016-05-26 16:24:48
LQ_CLOSE
37,466,683
Create a Legend on a Folium map
<p>The Folium documentation is incomplete at this time: <a href="https://folium.readthedocs.io/en/latest/" rel="noreferrer">https://folium.readthedocs.io/en/latest/</a></p> <p>According to the index of the incomplete docs Legends and Layers are, or will be supported. I've spent some time looking for examples on the web but have found nothing so far. If anyone has any idea how to create these things, or can point me to a document or tutorial I would be most grateful.</p>
<python><folium>
2016-05-26 16:43:12
HQ
37,466,916
Inheriting Python class methods?
<p>Still don't undertstand Python inheritance, I feel... thanks for tips!</p> <p>I want a subclass's instance to execute the superclass's class method. Tried this:</p> <pre><code>class SuperClass() @classmethod def aClassMethod(cls) pass class SubClass(SuperClass) def aMethod(self) self.__class__.aClassMethod() instance = SubClass() instance.aMethod() </code></pre> <p>But Python tells me that "SubClass" does not have attribute "aClassMethod". Yes, sure, I know, but how can I make the superclass's class method accessible to the subclass instance? </p>
<python><inheritance><static-methods>
2016-05-26 16:56:33
LQ_CLOSE
37,466,946
Java - How to force a gamemode in minecraft mod?
So, I am making this private modpack in Minecraft. It all is ready, but I need help with making a mod: It forces all players to be in gamemode 2 (adventure mode), or just make players unable to place/destroy blocks. I am not good in java, how can I make a mod like that? Any help is appreciated.
<java><minecraft>
2016-05-26 16:58:14
LQ_EDIT
37,467,492
How to provide user login with a username and NOT an email?
<p>I'd like to use Firebase for my web app that is for people with dementia in a care home. They do not have email or social network accounts so will need a simple username / password sign up / sign in.</p> <p>What is the easiest way to do this? From what I can see in the docs I'd have to use a custom auth flow but I do not have an existing auth server.</p> <p>If I do need ot do this what is the easiest way to provide the token? In Azure there is Functions and AWS has Lambda but I see nothing here is Firebase</p>
<firebase-authentication>
2016-05-26 17:28:51
HQ
37,467,561
Renaming multiple files in a directory using Python
<p>I'm trying to rename multiple files in a directory using this Python script:</p> <pre><code>import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1 </code></pre> <p>When I run this script, I get the following error:</p> <pre><code>Traceback (most recent call last): File "rename.py", line 7, in &lt;module&gt; os.rename(file, str(i)+'.jpg') OSError: [Errno 2] No such file or directory </code></pre> <p>Why is that? How can I solve this issue?</p> <p>Thanks.</p>
<python><directory><rename>
2016-05-26 17:33:22
HQ
37,467,888
Why do we need void functions?
<p>Is there any fathomable reason why we need void functions?</p> <p>For the same reason that <code>int main()</code> is a standard, why not simply return <code>0</code> from a function that doesn't require a return value? I see three immediate advantages to using an <code>int</code> type:<br> 1. We can return a code to indicate function status; typically, if there's a problem, we can return a non-zero error code.<br> 2. We can output the return value of the function when debugging<br> 3. It's the standard for the main() routine; that is, <code>int main() {}</code>. Why not follow suit? </p> <p>Is there any reason why we'd prefer <code>void</code> over <code>int</code>?</p> <p>Example: A function that sorts an array of cheeses, and returns it by reference.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; int sortArrayInt(string &amp; _cheese[]) { // pun intended ;D int errCode = 0; try { // ..sort cheese[] array } catch(e) { errCode = 1; } return errCode; } void sortArrayVoid(string &amp; _cheese[]) { // .. sort cheese[] array // no return code to work with, doesn't follow int main() standard, and nothing to output. } int main() { string cheese[5] = {"colby","swiss","cheddar","gouda","brie"}; std::cout &lt;&lt; "Sort Status: " &lt;&lt; sortCheeseArrayInt(cheese) &lt;&lt; std::endl; sortArrayVoid(cheese); // ..print cheese array } OUTPUT: Sort Status: 0 brie, cheddar, colby, gouda, swiss </code></pre>
<c++><c++11><int><return><void>
2016-05-26 17:52:59
LQ_CLOSE
37,468,531
Python: How do you make your code ask the same thing again if they answer with an integer out of range? My example below:
<p>How do I make this question asking for an input over and over until the user gets a valid answer between 5 and 25?</p> <pre><code>newGen = int(input("Input number of new generations to model (should be between 5 and 25\n)")) </code></pre>
<python><python-3.x>
2016-05-26 18:30:23
LQ_CLOSE
37,469,829
Espresso Tests in Library Module 'com.android.library'
<p>I have a library module that is used by two android applications and I want to add espresso tests to the Library module so that both apps can run common set of tests. Is there an example available where espresso tests are added in library module?</p>
<android-testing><android-espresso>
2016-05-26 19:52:27
HQ
37,470,424
Using Python to pull files from GitHub
<p>I am trying to find a way to use Python to pull files from a Github account. The only answers I seem to find is from 2013:</p> <pre><code>import requests from os import getcwd url = "https://raw.githubusercontent.com/Nav-aggarwal09/hello-world/master/README.doc" directory = getcwd() filename = directory + 'README.doc' r = requests.get(url) f = open(filename, 'w') f.write(r) </code></pre> <p>The above code does not seem to work. Can someone please tell me how to fix this code or give another way to do it through example? Thank you</p>
<python><github><pull-request>
2016-05-26 20:30:50
LQ_CLOSE
37,470,949
How do I generate nested json objects using mysql native json functions?
<p>Using only the native JSON fuctions (no PHP, etc) in MySQL version 5.7.12 (section 13.16 in the manual) I am trying to write a query to generate a JSON document from relational tables that contains a sub object. Given the following example:</p> <pre><code>CREATE TABLE `parent_table` ( `id` int(11) NOT NULL, `desc` varchar(20) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `child_table` ( `id` int(11) NOT NULL, `parent_id` int(11) NOT NULL, `desc` varchar(20) NOT NULL, PRIMARY KEY (`id`,`parent_id`) ); insert `parent_table` values (1,'parent row 1'); insert `child_table` values (1,1,'child row 1'); insert `child_table` values (2,1,'child row 2'); </code></pre> <p>I am trying to generate a JSON document that looks like this: </p> <pre><code>[{ "id" : 1, "desc" : "parent row 1", "child_objects" : [{ "id" : 1, "parent_id" : 1, "desc" : "child row 1" }, { "id" : 2, "parent_id" : 1, "desc" : "child row 2" } ] }] </code></pre> <p>I am new to MySQL and suspect there is a SQL pattern for generating nested JSON objects from one to many relationships but I'm having trouble finding it.</p> <p>In Microsoft SQL (which I'm more familiar with) the following works: </p> <pre><code>select [p].[id] ,[p].[desc] ,(select * from [dbo].[child_table] where [parent_id] = [p].[id] for json auto) AS [child_objects] from [dbo].[parent_table] [p] for json path </code></pre> <p>I attempted to write the equivalent in MySQL as follows: </p> <pre><code>select json_object( 'id',p.id ,'desc',p.`desc` ,'child_objects',(select json_object('id',id,'parent_id',parent_id,'desc',`desc`) from child_table where parent_id = p.id) ) from parent_table p; select json_object( 'id',p.id ,'desc',p.`desc` ,'child_objects',json_array((select json_object('id',id,'parent_id',parent_id,'desc',`desc`) from child_table where parent_id = p.id)) ) from parent_table p </code></pre> <p>Both attempts fail with the following error:</p> <pre><code>Error Code: 1242. Subquery returns more than 1 row </code></pre>
<mysql><json>
2016-05-26 21:02:21
HQ
37,471,082
C++ How to Check if Array contents can add up to a specific number
<p>Let's say I got this Array:</p> <pre><code>int myArray[] = {2,5,8,3,2,1,9}; </code></pre> <p>is ther any way I could check if some of the contents can add up to 20? I managed to check if any two values add up to 20 but I just don't know how to handle it if is irrelevant how many values it needs.</p> <p>Thank you for your help.</p>
<c++><arrays>
2016-05-26 21:10:35
LQ_CLOSE
37,471,253
How can I write unit tests for private clojure functions?
<p>I would like to write unit tests for functions defined as private using defn-. How can I do this?</p>
<unit-testing><clojure><private>
2016-05-26 21:24:01
HQ
37,471,313
setup_requires with Cython?
<p>I'm creating a <code>setup.py</code> file for a project with some Cython extension modules.</p> <p>I've already gotten this to work:</p> <pre><code>from setuptools import setup, Extension from Cython.Build import cythonize setup( name=..., ..., ext_modules=cythonize([ ... ]), ) </code></pre> <p>This installs fine. However, this assumes Cython is installed. What if it's not installed? I understand this is what the <code>setup_requires</code> parameter is for:</p> <pre><code>from setuptools import setup, Extension from Cython.Build import cythonize setup( name=..., ..., setup_requires=['Cython'], ..., ext_modules=cythonize([ ... ]), ) </code></pre> <p>However, if Cython isn't already installed, this will of course fail:</p> <pre><code>$ python setup.py install Traceback (most recent call last): File "setup.py", line 2, in &lt;module&gt; from Cython.Build import cythonize ImportError: No module named Cython.Build </code></pre> <p>What's the proper way to do this? I need to somehow import <code>Cython</code> only after the <code>setup_requires</code> step runs, but I need <code>Cython</code> in order to specify the <code>ext_modules</code> values.</p>
<python><build><cython><setuptools><software-distribution>
2016-05-26 21:28:16
HQ
37,471,352
Automatically open html links in new tab
<p>I have a html document with 100 html-links. When I open the document in a browser I want all the links in the document to open automatically in 100 different tabs in the same browser. Alternatively I want to do this some other way with the terminal in OS X or with cmd.exe in Windows. This is just for data collection and not web development.</p>
<javascript><html>
2016-05-26 21:31:23
LQ_CLOSE
37,471,797
Macro to find cells with value and replacing with value of adjacent cell
I want to search for all cells in a column that are 0000000000. If a cell is equal to 000000000, I want to replace the cell with the value of the cell to the left (previous column, same row) help please!
<excel><vba>
2016-05-26 22:05:08
LQ_EDIT
37,471,905
How to get user info (email, name, etc.) from the react-native-fbsdk?
<p>I'm trying to access the user's email and name to setup and account when a user authenticates with Facebook. I've ready the documentations for react-native-fbsdk but I'm not seeing it anywhere.</p>
<facebook><react-native>
2016-05-26 22:13:25
HQ
37,471,929
Docker: Container keeps on restarting again on again
<p>I today deployed an instance of MediaWiki using the appcontainers/mediawiki docker image, and I now have a new problem for which I cannot find any clue. After trying to attach to the mediawiki front container using:</p> <pre><code>docker attach mediawiki_web_1 </code></pre> <p>which answers <code>Terminated</code> on my configuration for a reason I ignore, trying also:</p> <pre><code>docker exec -it mediawiki_web_1 bash </code></pre> <p>I do get something close to an error message:</p> <pre><code>Error response from daemon: Container 81c07e4a69519c785b12ce4512a8ec76a10231ecfb30522e714b0ae53a0c9c68 is restarting, wait until the container is running </code></pre> <p>And there is my new problem, because this container never stop restarting. I can see that using <code>docker ps -a</code> which always returns a STATUS of <code>Restarting (127) x seconds ago</code>.</p> <p>The thing is, I am able to stop the container (I tested) but starting it again seems to bring it back into its restarting loop.</p> <p>Any idea what could be the issue here ? The whole thing was properly working until I tried to attach to it...</p> <p>I am sad :-(</p>
<docker>
2016-05-26 22:14:40
HQ
37,472,025
Java Script for of
<p>Can you explain me, please, why first console.log shows me array with both: array.foo and item, but when I use for of loop it does not show array.foo? </p> <pre><code>let array = [3,5,8, item = 'good']; array.foo = 'hello'; console.log(array); for (var i of array) { console.log( i); } </code></pre>
<javascript>
2016-05-26 22:25:29
LQ_CLOSE
37,472,331
Where to use await keyword - C#
<p>I am trying to wrap the WebApi calls from MVC app. So I created the below generic method,</p> <pre><code>public async Task&lt;T&gt; GetApi&lt;T&gt;(T model, string uri) where T : class { using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(baseAPIURL); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync(uri).Result; if (response.IsSuccessStatusCode) { return response.Content.ReadAsAsync&lt;T&gt;().Result; } } return default(T); } </code></pre> <p>Here, where to use the await keyword to make my method async?</p>
<c#><asp.net-mvc>
2016-05-26 22:55:44
LQ_CLOSE
37,472,367
ng:test no injector found for element argument to getTestability
<p>There other question on SO with same problem, but the solutions didnt worked for me. Here my spec.js</p> <pre><code>describe('Protractor Demo App', function() { it('should have a title', function() { browser.driver.get('http://rent-front-static.s3-website-us-east-1.amazonaws.com/'); expect(browser.getTitle()).toEqual('How It Works'); }); }); </code></pre> <p>And here my conf.js</p> <pre><code>exports.config = { framework: 'jasmine', rootElement: 'body', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'] } </code></pre> <p>So when i try to run my test im getting the error</p> <pre><code> Message: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.0/ng/test" Stack: Error: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.5.0/ng/test" at C:\Users\ShapeR\PycharmProjects\ratest\node_modules\jasminewd2\index.js:101:16 at Promise.invokeCallback_ (C:\Users\ShapeR\PycharmProjects\ratest\node_modules\selenium-webdriver\lib\promise.js:1329:14) at TaskQueue.execute_ (C:\Users\ShapeR\PycharmProjects\ratest\node_modules\selenium-webdriver\lib\promise.js:2790:14) at TaskQueue.executeNext_ (C:\Users\ShapeR\PycharmProjects\ratest\node_modules\selenium-webdriver\lib\promise.js:2773:21) 1 spec, 1 failure </code></pre> <p>I have a manual bootstrapping for body element and set the rootElement to body in config, but it didnt help. I even tried to remove manual boostraping and just add ng-app='rentapplicationApp' to body element, but it changes nothing, still same error.</p> <p>So what is wrong?</p>
<javascript><angularjs><protractor>
2016-05-26 23:00:03
HQ
37,472,453
Cannot read property 'style' of null - Google Sign-In Button
<p>I'm trying to implement Google sign in for my website. The Sign-In button shows up correctly and signs-people in well initially. My problem occurs when I log out after having used the website and try to move to the Sign-In page (I'm using React, so it's all one page). I use the exact same function to render the Sign-In page but it gives me a "cb=gapi.loaded_0:249 Uncaught TypeError: Cannot read property 'style' of null". The error in gapi occurs here (at least I think): </p> <pre><code> a.El;window.document.getElementById((c?"not_signed_in":"connected" </code></pre> <p>This is how I initially add the Sign-In button to be rendered: </p> <pre><code>elements.push(h('div.g-signin2',{'data-onsuccess': 'onSignIn'})) return h('div.page_content',elements) </code></pre> <p>which I later render with a ReactDOM.render call. </p> <p>Here's how I handle SignOut and SignIn: </p> <pre><code>function signOut() { var auth2 = gapi.auth2.getAuthInstance(); auth2.signOut().then(function () { // console.log('User signed out.'); signedin = false; auth2 = null; renderPage() }); } var google_idtoken; var signedin = false; // set auth2 to null to indicate that google api hasn't been loaded yet var auth2 = null; function onSignIn(googleUser) { auth2 = gapi.auth2.getAuthInstance({ client_id: 'ClientID.apps.googleusercontent.com' }); google_idtoken = googleUser.getAuthResponse().id_token; wrongemail = true; // if(auth2 != null &amp;&amp; auth2.isSignedIn.get() == true){ if ((((auth2.currentUser.get()).getBasicProfile()).getEmail()).split("@").pop() == 'domain.com'){ signedin = true wrongemail = false } updateSources() // renderPage() } </code></pre>
<javascript><reactjs><google-signin><google-api-js-client>
2016-05-26 23:09:46
HQ
37,472,700
So, I just started coding in the book, "Think Java", and I couldn't figure out what was wrong with my code. Please help me out and thanks
// So the problem arises in the line "String pls = printABCS("A", "B", "c", "D", "E", "F,", "G");", and I have no idea why, I've tried for the past hour and nothing seems to be working. Is there any fix to why when I run the code, the result is "Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method printABCS(Time3) in the type Time3 is not applicable for the arguments (String, String, String, String, String, String, String) at chapter11.Time3.main(Time3.java:16)" Thanks for taking your time to help. public class Time3 { String a, b, c, d, e, f, g; public Time3(String a, String b, String c, String d, String e, String f, String g) { this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; this.g = g; } public static void main(String[] args) { String pls = printABCS("A", "B", "c", "D", "E", "F,", "G"); } public static String printABCS(Time3 p) { return (p.a + p.b + p.c + p.d + p.e + p.f + p.g); } }
<java><object>
2016-05-26 23:40:32
LQ_EDIT
37,473,001
Java swing: cannot open popup frame from JTable
<p>My current project is simple email client. Now im done main window with list of messages from inbox. Next step is open new window with message from click on Jtable with list of messages. But Im getting this exception when click on row in table: </p> <pre><code>22 Test problem "Alb." &lt;test@gmail.com&gt; Hello My PC is not working Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException:4 &gt;= 4 at java.util.Vector.elementAt(Vector.java:470) at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:294) at sun.swing.SwingUtilities2.convertColumnIndexToModel(SwingUtilities2.java:1896) at javax.swing.JTable.convertColumnIndexToModel(JTable.java:2582) at javax.swing.JTable.getValueAt(JTable.java:2717) at CheckEmail$1.mouseClicked(CheckEmail.java:129) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270) at java.awt.Component.processMouseEvent(Component.java:6519) at javax.swing.JComponent.processMouseEvent(JComponent.java:3312) at java.awt.Component.processEvent(Component.java:6281) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4872) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4698) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4698) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747) at java.awt.EventQueue.access$300(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:706) at java.awt.EventQueue$3.run(EventQueue.java:704) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:720) at java.awt.EventQueue$4.run(EventQueue.java:718) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77) at java.awt.EventQueue.dispatchEvent(EventQueue.java:717) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) </code></pre> <p>here is my code: </p> <pre><code>import java.awt.BorderLayout; import org.apache.commons.codec.binary.Base64; import java.awt.Dimension; import java.util.*; import javax.mail.*; import javax.swing.*; import javax.swing.table.*; import org.apache.commons.codec.binary.Base64; import java.awt.*; import java.awt.event.*; public class CheckEmail { static Object[][] mess = new Object[][]{}; JTextField textMessage = null; String text = null; static Object messi = null; public static void check(String host, String storeType, String user, String password) { try { Properties properties = new Properties(); properties.put("mail.pop3.host", host); properties.put("mail.pop3.port", "995"); properties.put("mail.pop3.starttls.enable", "true"); Session emailSession = Session.getDefaultInstance(properties); Store store = emailSession.getStore("pop3s"); store.connect(host, user, password); Folder emailFolder = store.getFolder("INBOX"); emailFolder.open(Folder.READ_ONLY); Message[] messages = emailFolder.getMessages(); JFrame frame = new JFrame("Main"); JPanel panel = new JPanel(); final String data[][] = null; String [] col = {"num","Subject","From", "Text"}; DefaultTableModel model = new DefaultTableModel(data, col); final JTable table = new JTable(model); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(1).setPreferredWidth(400); table.getColumnModel().getColumn(2).setPreferredWidth(400); table.getColumnModel().getColumn(3).setPreferredWidth(1); table.setSize(830, 600); for (int i = 0, n = messages.length; i &lt; n; i++) { Message message = messages[i]; int num = i + 1; String subject = message.getSubject(); String from = message.getFrom()[0].toString(); String text = message.getContent().toString(); Object[] mess = new Object[]{num, subject, from, text}; model.insertRow(i, mess); } panel.add(table); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(830, 600); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); emailFolder.close(false); store.close(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 1) { final JTable target = (JTable)e.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedRow(); for(int i = 0; i &lt; column; i++) { Object mess = (Object)target.getValueAt(row, i); System.out.println(target.getValueAt(row, i)); } StringBuffer sb = new StringBuffer(); sb.append(mess); TextFrame textFrame = new TextFrame(sb.toString()); textFrame.setVisible(true); } } }); } catch (NoSuchProviderException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { String host = "pop3.gmail.com";// change accordingly String mailStoreType = "pop3"; String username = "test@gmail.com";// change accordingly String password = "pass";// change accordingly check(host, mailStoreType, username, password); } } </code></pre> <p>and the second class:</p> <pre><code>import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JTextArea; class TextFrame extends JFrame { public TextFrame(String content) { super("TextFrame"); JTextArea ta = new JTextArea(); ta.setText(content); getContentPane().add(ta); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { dispose(); } }); setSize(600, 400); } } </code></pre>
<java><swing><jtable>
2016-05-27 00:25:14
LQ_CLOSE
37,474,405
Understanding Type of IO () in `let` Expression
<p>Given:</p> <pre><code>λ: let f = putStrLn "foo" in 42 42 </code></pre> <p>What is <code>f</code>'s type? Why does <code>"foo"</code> not get printed before showing the result of <code>42</code>?</p> <p>Lastly, why doesn't the following work?</p> <pre><code>λ: :t f &lt;interactive&gt;:1:1: Not in scope: ‘f’ </code></pre>
<haskell>
2016-05-27 03:33:20
HQ
37,474,947
How set that,vim number style
I want to set vim with that. but I can't find the way. thanks! [enter image description here][1] [1]: http://i.stack.imgur.com/U2t8R.png
<vim>
2016-05-27 04:36:46
LQ_EDIT
37,475,012
I am getting this error "your cpu doesn't support vt-x or svm, android studio 2.1.1 in AMD 6300 processor"
<p>I have enabled the virtualization in bios setup but when i try to launch the emulator i am getting the error "your cpu doesn't support vt-x or svm"</p> <p>I have installed Intel haxm too.</p>
<android><virtualization><android-studio-2.1>
2016-05-27 04:43:52
HQ
37,475,222
Ncurses 6.0 Compilation Error - error: expected ')' before 'int'
<h1>Problem description</h1> <p>Trying to install ncurses 6.0 on Ubuntu 16.04 LTS is failing with a compilation error:</p> <pre><code>In file included from ./curses.priv.h:325:0, from ../ncurses/lib_gen.c:19: _24273.c:843:15: error: expected ‘)’ before ‘int’ ../include/curses.h:1631:56: note: in definition of macro ‘mouse_trafo’ #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) ^ Makefile:962: recipe for target '../objects/lib_gen.o' failed make[1]: *** [../objects/lib_gen.o] Error 1 make[1]: Leaving directory '/home/netsamir/Sofware/Tmux/ncurses-6.0/ncurses' Makefile:113: recipe for target 'all' failed make: *** [all] Error 2 </code></pre> <h1>Configuration</h1> <pre><code>netsamir@octopus:~/Sofware/Tmux/ncurses-6.0$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial netsamir@octopus:~/Sofware/Tmux/ncurses-6.0$ gcc --version gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. netsamir@octopus:~/Sofware/Tmux/ncurses-6.0$ cpp --version cpp (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. </code></pre>
<ncurses>
2016-05-27 05:04:00
HQ
37,475,829
Django Rest Framework How to update SerializerMethodField
<p>I have a serializer like this:</p> <pre><code>class PersonSerializer(serializers.ModelSerializer): gender = serializers.SerializerMethodField() bio = BioSerializer() class Meta: model = Person fields = UserSerializer.Meta.fields + ('gender', 'bio',) def get_gender(self, obj): return obj.get_gender_display() </code></pre> <p>I used this to display "Male" and "Female"(insted of "M" of "F") while performing GET request. </p> <p>This works fine. </p> <p>But now I am writing an patch method for the model and <code>SerializerMethodField()</code> has <code>read_only=True</code>. So I am not getting value passed for gender field in <code>serializer.validated_data()</code>. How to overcome this issue?</p>
<python><django><django-rest-framework><django-serializer>
2016-05-27 05:57:02
HQ
37,476,409
Run python-script from CMD - windows
<p>I want to run my python script without the <code>python</code> keyword at the beginning.</p> <p>Example : I don't want <code>python script.py</code>.</p> <p>I want <code>script.py</code></p> <p>The problem is that when I run it how I want the script opens in a text editor, and it doesn't run in the console...</p> <p>Why?</p>
<python><python-2.7><cmd>
2016-05-27 06:34:58
LQ_CLOSE
37,477,139
How to debug a gulp task with VSCode
<p>I need to debug a command <code>gulp start</code> with VScode (I got some mapping error with babel during transpilation that I don't understand yet...). The VSCode debug default configuration aims to launch <code>node app.js</code>. How to modify it to trigger the <code>gulp command</code>?</p> <p>Here is the default configuration. If anyone has hint of how can I do that, I'll be in your debt :)</p> <pre><code>{ "version": "0.2.0", "configurations": [ { "name": "Lancer", "type": "node", "request": "launch", "program": "${workspaceRoot}/app.js", "stopOnEntry": false, "args": [], "cwd": "${workspaceRoot}", "preLaunchTask": null, "runtimeExecutable": null, "runtimeArgs": [ "--nolazy" ], "env": { "NODE_ENV": "development" }, "externalConsole": false, "sourceMaps": false, "outDir": null }, { "name": "Attacher", "type": "node", "request": "attach", "port": 5858, "address": "localhost", "restart": false, "sourceMaps": false, "outDir": null, "localRoot": "${workspaceRoot}", "remoteRoot": null } ] } </code></pre>
<debugging><gulp><visual-studio-code>
2016-05-27 07:16:34
HQ
37,477,397
Count how many rows you have in your db with PHP
<p>Hellow, </p> <p>I want to count how many rows i have in a table. I got a table (workstations) in my mysql database (phpmyadmin). I want to print it out, so ik can see how many workstations their are "active" in my environment</p> <p>I've read many blogs about this, but all the things they propose are not working for me.</p> <p>Thanks in advance!</p>
<php><mysql><count><phpmyadmin>
2016-05-27 07:29:21
LQ_CLOSE
37,477,479
How to share two private keys ,while anyone else is listening in on the conversation
<p>Cryptographic hashing is a very useful concept. The MD varieties are no longer sufficiently secure--you can break them in reasonable time using Amazon cloud. We use SHA-512 for our superuser password.</p> <p>While we're on cryptography, you should explain how 2 people can share a completely private key while anyone else is listening in on the conversation. That is the basis of all security on the Internet.</p>
<encryption><cryptography><private-key>
2016-05-27 07:34:14
LQ_CLOSE
37,477,644
Firebase Permission denied Error
<p>I am Very beginner to firebase and trying to get value from my database.</p> <p>but it showing me same error every time.</p> <pre><code> W/SyncTree: Listen at /child failed: FirebaseError: Permission denied </code></pre> <p>My firebase rules</p> <pre><code> { "Condition" : "sunny", "child" : 5 } </code></pre> <p>my Androidmanifest.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mohit.firebase" &gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".MainActivity" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>My mainactivity.java package com.mohit.firebase;</p> <pre><code>import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.firebase.client.DataSnapshot; import com.firebase.client.Firebase; import com.firebase.client.FirebaseError; import com.firebase.client.ValueEventListener; public class MainActivity extends AppCompatActivity { TextView tv; Button bt1; Button bt2; Firebase mRootRef; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv = (TextView) findViewById(R.id.button); bt1 = (Button) findViewById(R.id.button); bt2 = (Button) findViewById(R.id.button2); Firebase.setAndroidContext(this); mRootRef = new Firebase("https://superb-flag-126719.firebaseio.com/"); Log.d("fb","Firebase Object: " + String.valueOf(mRootRef)); } @Override protected void onStart() { super.onStart(); Firebase mchild = mRootRef.child("child"); mchild.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String condition = (String) dataSnapshot.getValue(); Log.d("fb","String get: " + condition); tv.setText(condition); } @Override public void onCancelled(FirebaseError firebaseError) { } }); } } </code></pre> <p>my BuildGraddle</p> <pre><code> apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.mohit.firebase" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.firebase:firebase-client-android:2.5.2+' } </code></pre> <p>i checked my firebase url. It's Perfectly Correct.</p>
<android><firebase><firebase-realtime-database><android-database>
2016-05-27 07:41:54
HQ
37,478,727
How can I make a browser display all datalist options when a default value is set?
<p>I have an HTML form with a datalist and where the value is set with PHP, like</p> <pre><code>&lt;input list="values" value="&lt;?php echo $val; ?&gt;"&gt; &lt;datalist id="values"&gt; &lt;option value="orange"&gt; &lt;option value="banana"&gt; &lt;/datalist&gt; </code></pre> <p>I want the user to see the options in the datalist, as well as the current value from the PHP. However, the "autocomplete" action causes values from the list that don't match (or start with) the current value to be hidden from the list, say if <code>$val='apple'</code>. Is there any way to avoid that, or is this behaviour fixed by the browser?</p>
<html><browser><datalist>
2016-05-27 08:36:56
HQ
37,478,874
There is no Download dSYM option on iTunes connect
<p>I need to download dSYM file from iTunes Connect.</p> <p>I can see "Include symbols" is Yes, but there is no link to download the dSYM file.</p> <p>Any idea why the option is not there? </p>
<ios><app-store-connect><dsym>
2016-05-27 08:43:50
HQ
37,479,314
How to get value by key from JObject?
<p>I have a JObject like this:</p> <pre><code>{ "@STARTDATE": "'2016-02-17 00:00:00.000'", "@ENDDATE": "'2016-02-18 23:59:00.000'" } </code></pre> <p>I want to get @STARTDATE and @ENDDATE value from JObject.</p> <hr> <p>This is a sample code that I've tried to do the task:</p> <pre><code>JObject json = JObject.Parse("{\"@STARTDATE\": \"'2016-02-17 00:00:00.000'\",\"@ENDDATE\": \"'2016-02-18 23:59:00.000'\"}"); var key = "@STARTDATE"; var value = GetJArrayValue(json, key); private string GetJArrayValue(JObject yourJArray, JToken key) { string value = ""; foreach (JToken item in yourJArray.Children()) { var itemProperties = item.Children&lt;JProperty&gt;(); //If the property name is equal to key, we get the value var myElement = itemProperties.FirstOrDefault(x =&gt; x.Name == key.ToString()); value = myElement.Value.ToString(); //It run into an exception here because myElement is null break; } return value; } </code></pre> <p><em>Note: The code above cannot get the value by key from JObject.</em></p> <hr> <p><strong>Could you help me to find a way to get the value by key from JObject?</strong></p>
<c#><json>
2016-05-27 09:05:36
HQ
37,479,338
How to remove a contour inside contour in Python OpenCV?
<p>OpenCV in Python provides the following code:</p> <pre><code>regions, hierarchy = cv2.findContours(binary_image, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) for region in regions: x, y, w, h = cv2.boundingRect(region) cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 1) </code></pre> <p>This gives some contours within contour. How to remove them in Python?</p>
<python><opencv><contour>
2016-05-27 09:06:45
HQ
37,479,982
Visual Studio Code - Select current word (ctrl-w in old visual studio bindings)?
<p>How to select current word (the one where the caret is) in <strong>Visual Studio Code</strong> (the text editor, not Visual Studio)? In Visual Studio old bindings it was the <code>ctrl+w</code> shortcut but it was changed to close tab action.</p>
<visual-studio-code>
2016-05-27 09:35:48
HQ
37,480,790
Firebase and Crashlytics - Which one to use?
<p>Since the presentation of Firebase Crash Reporting, one of the most prominent questions has been wether moving from Crashlytics or not.</p> <p>What are the pros and cons when comparing the two crash reporting services?</p>
<android><firebase><crashlytics><crashlytics-android><firebase-crash-reporting>
2016-05-27 10:14:05
HQ
37,480,896
How do get other links in search when searched for other query
<p>I searched in google for "Dominoes Coupons" and in the list of result I found some links linking to different pages of same website. Refer the below image : <a href="https://i.stack.imgur.com/gubD8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gubD8.png" alt="enter image description here"></a></p> <p>How do I achieve this for my website.</p>
<seo><serp>
2016-05-27 10:19:17
LQ_CLOSE
37,481,019
progress bar appear before that i click on button to create PDF
why progress bar appear before that i click on button to create PDF? I hope that you can help me! I want that progress bar appear during creation PDF file... THANKS IN ADVANCED EVERYBODY! @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_two, container, false); pdfProgress = (ProgressBar)rootView.findViewById(R.id.progressbar); Button mButton = (Button) rootView.findViewById(R.id.newbutton); mButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //sendemail(); pdfProgress.setVisibility(View.VISIBLE); createPDF(); pdfProgress.setVisibility(View.GONE); viewPDF(); } }); TextView titolo3 = (TextView)rootView.findViewById(R.id.result); TextView titolo2 = (TextView)rootView.findViewById(R.id.result2); TextView titolo4 = (TextView)rootView.findViewById(R.id.resultpizze);
<java><android><pdf><progress-bar>
2016-05-27 10:25:13
LQ_EDIT
37,481,312
Why they still have separate floating point unit , if there is Neon for fast processing of floating points in ARM cortex processors.
<p>Neon (advanced SIMD) is very fast for add,subtract,multiply and floating point operations like single precision and double precision. Why ARM company still have another separate unit for floating point calculation as you can see in picture. i am little bit confused about it. </p> <p><a href="https://i.stack.imgur.com/d8Xe0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d8Xe0.png" alt="enter image description here"></a></p>
<arm><neon><fpu><cortex-a>
2016-05-27 10:38:52
LQ_CLOSE
37,483,117
How to get a folder's name with PHP?
<p>I want to get a folder's name with PHP and store it in a variable. But I don't know how to do that ! So my site directory is like this: </p> <pre><code>---daygostar.com ---css ---js ---scss ---index.php </code></pre> <p>So here ,I would like to get <strong>daygostar.com</strong>'s name and store it at <strong>index.php</strong>. So how to do that ? </p>
<php>
2016-05-27 12:05:19
LQ_CLOSE
37,483,343
search string value with wild card in another string java
<p>Suppose I have string value</p> <pre><code>String strValue1 = "This is the 3TB value"; String strValue2 = "3TB is the value"; String strValue3 = "The value is 3TB"; </code></pre> <p>No when the user search for <code>3TB*</code> then it should match with the strValue2 same like for when user search for <code>*3TB*</code> then it should match with strValue1 and for <code>*3TB</code> it should match with strValue3</p> <p>I tried with so many examples but no luck. Is there any wildcard search for string? I can't use any external libraries</p>
<java><string-matching>
2016-05-27 12:16:03
LQ_CLOSE