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
40,123,854
GET form will not echo
<p>I'm starting to learn PHP and keep getting stuck at this point after copying word for word on each guide I'm following. When I complete the form below it updates the query string but dose not echo out the paragraph, same for print. Other answers I've seen for this say to reinstall the server but I have it on Host Gator.</p> <pre><code>&lt;form methon="get" action="index.php"&gt; &lt;input type="text" name="name"&gt; &lt;input type="text" name="age"&gt; &lt;input type="submit" name="name" value="submit"&gt; &lt;/form&gt; &lt;?php $name = $GET_['name']; $age = $GET_['age']; echo '&lt;p&gt;' . $name '&lt;/p&gt;'; echo '&lt;p&gt;' . $age . '&lt;/p&gt;'; ?&gt; </code></pre>
<php><html>
2016-10-19 06:33:26
LQ_CLOSE
40,124,066
Sql query to find max value within 60 seconds ....
Suppose i have a table like below (with different ids) ... here for example took '99' ... id hist_timestamp DP mints Secnds value 99 2016-08-01 00:09:40 1 9 40 193.214 99 2016-08-01 00:10:20 1 10 20 198.573 99 2016-08-01 00:12:00 1 12 0 194.432 99 2016-08-01 00:52:10 1 52 10 430.455 99 2016-08-01 00:55:50 1 55 50 400.739 99 2016-08-01 01:25:10 2 25 10 193.214 99 2016-08-01 01:25:50 2 25 50 193.032 99 2016-08-01 01:34:30 2 34 30 403.113 99 2016-08-01 01:37:10 2 37 10 417.18 99 2016-08-01 01:38:10 2 38 10 400.495 99 2016-08-01 03:57:00 4 57 0 190.413 99 2016-08-01 03:58:40 4 58 40 191.936 Here i have a value column, starting from the first record i need to find max value within next 60 seconds which will result in below. In the group of those 60 seconds, i need to select one record with max value. id hist_timestamp DP mints Secnds value 99 2016-08-01 00:10:20 1 10 20 198.573 99 2016-08-01 00:12:00 1 12 0 194.432 99 2016-08-01 00:52:10 1 52 10 430.455 99 2016-08-01 00:55:50 1 55 50 400.739 99 2016-08-01 01:25:10 2 25 10 193.214 99 2016-08-01 01:34:30 2 34 30 403.113 99 2016-08-01 01:37:10 2 37 10 417.18 99 2016-08-01 03:57:00 4 57 0 190.413 99 2016-08-01 03:58:40 4 58 40 191.936 Can you please help me please with sql query. Thanks !!!
<sql><sql-server><tsql>
2016-10-19 06:45:01
LQ_EDIT
40,125,159
Angular2 Testing No provider for LocationStrategy
<p>I am trying to write a test for a Component, but I always get the error: "Error: Error in ./ExpenseOverviewComponent class ExpenseOverviewComponent - inline template:41:8 caused by: No provider for Location Strategy!"</p> <pre><code>import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; import { FormsModule } from "@angular/forms"; import { RouterModule, Router, ActivatedRoute } from '@angular/router'; import { RouterStub, ActivatedRouteStub } from '../../../../utils/testutils'; import { HttpModule } from "@angular/http"; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { ExpenseOverviewComponent } from './expense-overview.component'; import { ExpenseFilterPipe } from '../pipes/expense-filter.pipe'; import { ExpenseService } from '../services/expense.service'; describe('ExpenseOverviewComponent', () =&gt; { let expenseOverviewComponent: ExpenseOverviewComponent; let fixture: ComponentFixture&lt;ExpenseOverviewComponent&gt;; let debugElement: DebugElement; let htmlElement: HTMLElement; let spy: jasmine.Spy; let expenseService: ExpenseService; beforeEach(() =&gt; { TestBed.configureTestingModule({ imports: [FormsModule, RouterModule, HttpModule], declarations: [ExpenseOverviewComponent, ExpenseFilterPipe], providers: [ ExpenseService, { provide: Router, useClass: RouterStub }, { provide: ActivatedRoute, useClass: ActivatedRouteStub } ] }); fixture = TestBed.createComponent(ExpenseOverviewComponent); expenseOverviewComponent = fixture.componentInstance; // Expense service actually injected into the component expenseService = fixture.debugElement.injector.get(ExpenseService); // query for the title &lt;panel-heading&gt; by CSS class selector debugElement = fixture.debugElement.query(By.css('.table')); htmlElement = debugElement.nativeElement; }); it('should not show expenses before OnInit', () =&gt; { spy = spyOn(expenseService, 'getExpenses').and.returnValue(new BehaviorSubject([]).asObservable()); expect(spy.calls.any()).toBe(false, 'getExpenses not yet called'); }); }); </code></pre> <p>The component under test is the following:</p> <pre><code>import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Expense } from '../model/expense'; import { ExpenseService } from '../services/expense.service'; @Component({ template: require('./expense-overview.component.html'), styles: [require('./expense-overview.component.css')] }) export class ExpenseOverviewComponent implements OnInit { expenseFilter: string = ''; errorMessage: string; expenses: Expense[]; constructor(private expenseService: ExpenseService) { } ngOnInit(): void { this.expenseService.getExpenses() .subscribe(expenses =&gt; this.expenses = expenses, error =&gt; this.errorMessage = &lt;any&gt;error); } deleteExpense(expense: Expense) { this.expenseService.deleteExpense(expense) .subscribe(response =&gt; { this.expenses = this.expenses.filter(rec =&gt; rec.id !== expense.id); }, error =&gt; { console.error("Error deleting expense with id: " + expense.id); return Observable.throw(error); }); } } </code></pre> <p>Does anyone see the problem? I am bundling with webpack.</p> <pre><code>var path = require('path'); // Webpack Plugins var ProvidePlugin = require('webpack/lib/ProvidePlugin'); var DefinePlugin = require('webpack/lib/DefinePlugin'); var ENV = process.env.ENV = process.env.NODE_ENV = 'test'; /* * Config */ module.exports = { resolve: { cache: false, extensions: ['','.ts','.js','.json','.css','.html'] }, devtool: 'inline-source-map', module: { loaders: [ { test: /\.ts$/, loader: 'ts-loader', query: { // remove TypeScript helpers to be injected below by DefinePlugin 'compilerOptions': { 'removeComments': true, 'noEmitHelpers': true, }, 'ignoreDiagnostics': [ 2403, // 2403 -&gt; Subsequent variable declarations 2300, // 2300 Duplicate identifier 2374, // 2374 -&gt; Duplicate number index signature 2375 // 2375 -&gt; Duplicate string index signature ] }, exclude: [ /\.e2e\.ts$/, /node_modules/ ] }, { test: /\.json$/, loader: 'json-loader' }, { test: /\.html$/, loader: 'raw-loader' }, { test: /\.css$/, loader: 'raw-loader' }, { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } } ], postLoaders: [ // instrument only testing sources with Istanbul { test: /\.(js|ts)$/, include: root('src'), loader: 'istanbul-instrumenter-loader', exclude: [ /\.e2e\.ts$/, /node_modules/ ] } ], noParse: [ /zone\.js\/dist\/.+/, /angular2\/bundles\/.+/ ] }, stats: { colors: true, reasons: true }, debug: false, plugins: [ new DefinePlugin({ // Environment helpers 'process.env': { 'ENV': JSON.stringify(ENV), 'NODE_ENV': JSON.stringify(ENV) }, 'global': 'window', // TypeScript helpers '__metadata': 'Reflect.metadata', '__decorate': 'Reflect.decorate' }), new ProvidePlugin({ // '__metadata': 'ts-helper/metadata', // '__decorate': 'ts-helper/decorate', '__awaiter': 'ts-helper/awaiter', '__extends': 'ts-helper/extends', '__param': 'ts-helper/param', 'Reflect': 'es7-reflect-metadata/dist/browser' }) ], // we need this due to problems with es6-shim node: { global: 'window', progress: false, crypto: 'empty', module: false, clearImmediate: false, setImmediate: false } }; </code></pre>
<angular><jasmine><webpack><karma-runner><angular2-testing>
2016-10-19 07:45:16
HQ
40,125,716
lightweight hardware to send a simple message to a .NET app via wifi
<p>If possible, could someone point me in the direction of some hardware which is capable of using a wifi signal to send a message to a .NET app, which could then pop a push notification on a mobile device? It would have to be a real-time thing, popping messages into a data table to be read when the app is launched will not serve the purpose I require it to, so the app would act constantly as a 'listener'. The contents of the message are not important (1 or 0 would do), what's more important is that the message is sent quickly and that the mobile device receives the message every time.</p> <p>PS - cheap and lightweight is preferable of course! Thanks in advance.</p>
<.net><xamarin><push-notification><wifi><hardware>
2016-10-19 08:13:31
LQ_CLOSE
40,126,565
@SuppressWarnings vs @SuppressLint
<p>Can anyone explain to me the differences between <code>@SuppressWarnings</code> and <code>@SuppressLint</code>? When we should use one over another? </p> <p>I've read the documentation, but still don't get the differences. Explain using an example/sample code will be much appreciated. Thanks.</p>
<java><android><android-studio>
2016-10-19 08:54:56
HQ
40,126,706
Composer Autoloading classes not found
<p>I have folder structure like:</p> <pre><code>includes/ libraries/ Classes/ Contact/ Contact.php ContactController.php admin/ controllers/ contact/ edit.php </code></pre> <p>Contact.php is my class that file that I'm trying to use. The file contains.</p> <pre><code>&lt;?php namespace Classes; class Contact { function __construct() { die('here'); } } </code></pre> <p>I have my composer.json file like:</p> <pre><code>{ "autoload": { "psr-4": { "Classes\\": "includes/libraries/Classes/" } }, } </code></pre> <p>The file I'm trying to use the Contact class in is <code>edit.php</code> within the <code>admin/controllers/contact/</code> folder. My <code>edit.php</code> file is like:</p> <pre><code>&lt;?php use Classes\Contact; $contact = new Contact(); var_dump($contact); </code></pre> <p>This file has the <code>vendor/autoload.php</code> file included, yet I can't seem to get it to use the class?</p>
<php><namespaces><composer-php><autoload>
2016-10-19 09:00:34
HQ
40,127,507
Can I select part of the street in Google Maps API?
I need to be able select/delete/update some parts of the streets on Google map(as on picture bellow). This selected parts must be saved on server and there is must be counter of selected distance. There is possible solution of this problem in Google Maps API? [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/bJK8x.png
<javascript><google-maps>
2016-10-19 09:33:04
LQ_EDIT
40,129,279
how to add Favicon icon in email template?
We are using word-press website with Email template , all emails working fine , but our requirement is showing Favicon icon in our Email template . How to pass Favicon icon in my email template ?
<wordpress><html-email>
2016-10-19 10:50:11
LQ_EDIT
40,129,364
how to cancel timer in neworderfragment from utilmethod.java class...when iam logout from homeactivity..in Adroid
when Iam logout from homeactivity, shows fragment processing though timer inside it.I want to cancel timer from utilmethod java class where logoutalertdialog exits.when iam pressing yes timer should cancel their
<android><timer><fragment><logout>
2016-10-19 10:53:38
LQ_EDIT
40,130,263
Issues with my website copyright footer
<p>Not really code related but website related which in a different view is programming. The copyright footer on a website has to be of current year, right!?! </p>
<html>
2016-10-19 11:32:30
LQ_CLOSE
40,130,357
Sub folder are not copying
This is the [function][1] that i am using to copy folders content into antoher folder but its not copying the sub folder not its internal data: private static void DirectoryCopy( string sourceDirName, string destDirName, bool copySubDirs) { DirectoryInfo dir = new DirectoryInfo(sourceDirName); DirectoryInfo[] dirs = dir.GetDirectories(); // If the source directory does not exist, throw an exception. if (!dir.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + sourceDirName); } // If the destination directory does not exist, create it. if (!Directory.Exists(destDirName)) { Debug.Log("Directory created.." + destDirName); Directory.CreateDirectory(destDirName); } // Get the file contents of the directory to copy. FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { // Create the path to the new copy of the file. string temppath = Path.Combine(destDirName, file.Name); // Copy the file. file.CopyTo(temppath, false); } // If copySubDirs is true, copy the subdirectories. if (copySubDirs) { foreach (DirectoryInfo subdir in dirs) { // Create the subdirectory. string temppath = Path.Combine(destDirName, subdir.Name); // Copy the subdirectories. DirectoryCopy(subdir.FullName, temppath, copySubDirs); } } } While I am calling it string destingationPath = startupFolder + @"\NetworkingDemoPlayerWithNetworkAwareShooting1_Data"; DirectoryCopy("NetworkingDemoPlayerWithNetworkAwareShooting1_Data", destingationPath, true); [1]: http://stackoverflow.com/questions/1974019/folder-copy-in-c-sharp
<c#>
2016-10-19 11:37:07
LQ_EDIT
40,131,315
Errors occuring on running
I am new to C programming in Linux. I wrote a program, in compiling, no errors are occurred. But on running it is giving too many errors. My program is, #include <stdio.h> typedef struct a{ char *name; int id; char *department; int num; } ab; int main() { ab array[2]={{"Saud",137,"Electronics",500},{"Ebad",111,"Telecom",570}}; printf("First student data:\n%s\t%d\t%s\t%d",array[0].name,array[0].id, array[0].department,array[0].num); //ab swap(&array[]); } Errors are, ./newproject: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here ./newproject: In function `data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here ./newproject: In function `data_start': (.data+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o:(.data+0x0): first defined here ./newproject:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here ./newproject: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here ./newproject: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__' ./newproject:(.data+0x10): first defined here /usr/bin/ld: error in ./newproject(.eh_frame); no .eh_frame_hdr table will be created. collect2: error: ld returned 1 exit status
<c><linux><structure>
2016-10-19 12:23:40
LQ_EDIT
40,133,197
assigning a list property to another list property c#
I have three different lists including students,courses and grades. what I want to do is to use some of courses and students properties in grades property. here is my code: namespace educationsystem { public class student { public int scode { get; set; } public string name { get;set;} public string lastname {get;set;} public long phone {get;set;} } public class course { public int code { get; set;} public string name { set; get;} public int unit { set; get;} } public class grade { public student studentinfo { get; set; } public course courseinfo { get; set; } public double value { get; set; } public int term { get; set; } } public class education { } class Program { static void Main(string[] args) { List<student> Students = new List<student>(); List<course> courses = new List<course>(); List<int> grades = new List<int>(); Students.Add(new student { scode=1,name = "mahta", lastname = "sahabi", phone = 3244 }); Students.Add(new student { scode=2, name = "niki", lastname = "fard", phone = 5411 }); Students.Add(new student { scode=3, name = "hana", lastname = "alipoor", phone = 6121 }); courses.Add(new course { code = 1, name = "Mathemathics", unit = 3 }); courses.Add(new course { code = 2, name = "physics", unit = 3 }); courses.Add(new course { code = 3, name = "computer", unit = 3 }); Students.ForEach((student) => { Console.WriteLine(student.scode+" "+student.name + " " + student.lastname + " " + student.phone); }); courses.ForEach((course) => { Console.WriteLine(course.code + " " + course.name + " " + course.unit); }); Console.ReadKey(); } so I want to print the grades like: mahta sahabi mathematics 20. how can I do such thing?
<c#><list>
2016-10-19 13:45:17
LQ_EDIT
40,133,582
Assign value not reference in javascript
<p>I am having a little problem assigning objects in javascript.</p> <p>take a look at this sample code that reproduces my problem.</p> <pre><code>var fruit = { name: "Apple" }; var vegetable = fruit; vegetable.name = "potatoe"; console.log(fruit); </code></pre> <p>it logs </p> <pre><code>Object {name: "potatoe"} </code></pre> <p>How can I assign the value not the reference of an object to another object?</p>
<javascript><variable-assignment>
2016-10-19 14:01:46
HQ
40,134,031
Want to add none as value in select multiple
<p>I am using chosen.jquery.js for select field</p> <pre><code>&lt;select chosen multiple data-placeholder="Select Body Part(s)" ng-options="option.Name as option.Name for option in BodyPartList" ng-model="Body_Part"&gt; &lt;option value="" disabled&gt;Select Body Part(s)&lt;/option&gt; &lt;/select&gt; </code></pre> <p>But It shows only data-placeholder value in case of no data in model. I want to show "Select Body Part(s)" as a option in list. And user must not select this. Reason is that, I want to add dynamic "Unknown" value in list of Body_Parts. But it not reflect in list.</p> <p>Same work for select having single selection.</p>
<javascript><jquery><angularjs><jquery-chosen><angular-chosen>
2016-10-19 14:19:07
HQ
40,134,104
How to pass the button value into my onclick event function?
<pre><code>&lt;input type="button" value="mybutton1" onclick="dosomething()"&gt;test </code></pre> <p>The dosomething function evoked when to click the button,how can pass the value of the button <code>mybutton1</code> into dosomething function as it's parameter ?</p>
<javascript>
2016-10-19 14:21:23
HQ
40,134,139
C++ delete a pointer (free memory)
<p>Consider the following code:</p> <pre><code>int a = 10; int * b = &amp;a; int * c = b; delete b; // equivalent to delete c; </code></pre> <p>Am I correct to understand in the last line, <code>delete b</code> and <code>delete c</code> are equivalent, and that both will free the memory space holding <code>a</code>, thus <code>a</code> is no longer accessible?</p>
<c++><pointers><memory-management>
2016-10-19 14:22:32
HQ
40,134,326
How to add bulk number of white spaces in C# code?
<p>i have a count to add white spaces to the text file. For Example: 12 as count means need to add 12 spaces in the existing text file. is there any possible way?</p>
<c#>
2016-10-19 14:29:39
LQ_CLOSE
40,136,014
Can I write javascript web apps in visual studio 2015?
<p>I don't know anything about javascript web programming... but want to learn.</p> <p>My question is : Can I use visual studio 2015 to write, debug and publish(?) javascript web applications.</p> <p>Again... I don't know if 'publishing' is the right terminology for writing web applications in Javascript... of if you can even 'write' web applications in Javascript...</p> <p>Any information on the topic would be good to know.</p> <p>thanks</p>
<javascript><visual-studio-2015>
2016-10-19 15:41:40
LQ_CLOSE
40,136,070
Ipython cv2.imwrite() not saving image
<p>I have written a code in python opencv. I am trying to write the processed image back to disk but the image is not getting saved and it is not showing any error(runtime and compilation) The code is</p> <pre><code>""" Created on Wed Oct 19 18:07:34 2016 @author: Niladri """ import numpy as np import cv2 if __name__ == '__main__': import sys img = cv2.imread('C:\Users\Niladri\Desktop\TexturesCom_LandscapeTropical0080_2_S.jpg') if img is None: print 'Failed to load image file:' sys.exit(1) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) h, w = img.shape[:2] eigen = cv2.cornerEigenValsAndVecs(gray, 15, 3) eigen = eigen.reshape(h, w, 3, 2) # [[e1, e2], v1, v2] #flow = eigen[:,:,2] iter_n = 10 sigma = 5 str_sigma = 3*sigma blend = 0.5 img2 = img for i in xrange(iter_n): print i, gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) eigen = cv2.cornerEigenValsAndVecs(gray, str_sigma, 3) eigen = eigen.reshape(h, w, 3, 2) # [[e1, e2], v1, v2] x, y = eigen[:,:,1,0], eigen[:,:,1,1] print eigen gxx = cv2.Sobel(gray, cv2.CV_32F, 2, 0, ksize=sigma) gxy = cv2.Sobel(gray, cv2.CV_32F, 1, 1, ksize=sigma) gyy = cv2.Sobel(gray, cv2.CV_32F, 0, 2, ksize=sigma) gvv = x*x*gxx + 2*x*y*gxy + y*y*gyy m = gvv &lt; 0 ero = cv2.erode(img, None) dil = cv2.dilate(img, None) img1 = ero img1[m] = dil[m] img2 = np.uint8(img2*(1.0 - blend) + img1*blend) #print 'done' cv2.imshow('dst_rt', img2) cv2.waitKey(0) cv2.destroyAllWindows() #cv2.imwrite('C:\Users\Niladri\Desktop\leaf_image_shock_filtered.jpg', img2) for i in xrange(iter_n): print i, gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) eigen = cv2.cornerEigenValsAndVecs(gray, str_sigma, 3) eigen = eigen.reshape(h, w, 3, 2) # [[e1, e2], v1, v2] x, y = eigen[:,:,1,0], eigen[:,:,1,1] print eigen gxx = cv2.Sobel(gray, cv2.CV_32F, 2, 0, ksize=sigma) gxy = cv2.Sobel(gray, cv2.CV_32F, 1, 1, ksize=sigma) gyy = cv2.Sobel(gray, cv2.CV_32F, 0, 2, ksize=sigma) gvv = x*x*gxx + 2*x*y*gxy + y*y*gyy m = gvv &lt; 0 ero = cv2.erode(img, None) dil = cv2.dilate(img, None) img1 = dil img1[m] = ero[m] img2 = np.uint8(img2*(1.0 - blend) + img1*blend) print 'done' #cv2.imwrite('D:\IP\tropical_image_sig5.bmp', img2) cv2.imshow('dst_rt', img2) cv2.waitKey(0) cv2.destroyAllWindows() #cv2.imshow('dst_rt', img2) cv2.imwrite('C:\Users\Niladri\Desktop\tropical_image_sig5.bmp', img2) </code></pre> <p>Can anyone please tell me why it is not working. cv2.imshow is working properly(as it is showing the correct image). Thanks and Regards Niladri</p>
<python><opencv>
2016-10-19 15:44:23
HQ
40,136,606
How to expose audio from Docker container to a Mac?
<p>I know it's possible by using pulse audio on a Linux host system But <code>paprefs</code> is built for linux not mac.</p>
<macos><audio><docker><containers><pulseaudio>
2016-10-19 16:10:20
HQ
40,136,699
Using Google API for Python- where do I get the client_secrets.json file from?
<p>I am looking into using the Google API to allow users to create/ edit calendar entries in a company calendar (Google calendar) from within iCal.</p> <p>I'm following the instructions at: <a href="https://developers.google.com/api-client-library/python/auth/web-app" rel="noreferrer">https://developers.google.com/api-client-library/python/auth/web-app</a></p> <p>Step 2 says that I will need the application's <code>client ID</code> and <code>client secret</code>. I can see the <code>client ID</code> in the 'Credentials' page for my app, but I have no idea what the <code>client secret</code> is or where I get that from- anyone know what this is? How do I download it? Where can I get the value from to update the field?</p>
<python><json><google-api>
2016-10-19 16:15:37
HQ
40,136,965
Python Call a Function With Arguments From a User Input
So this may seem like a duplicate, as there are many posts on this topic. However, I am actually asking for something different. So I would like to call a function from a user input, *but include arguments in the parenthesis.* EG: `def var(value): print(value)` I would like to ask the user for a function, `input("Command: ")`, which should be executed, *with the argument*. `Command: var("Test")` This should print `test`. I have heard this is a bad idea, for security reasons, but as I'm just using this to write HTML, I don't think it's a problem.
<python>
2016-10-19 16:30:52
LQ_EDIT
40,138,031
How to read realtime microphone audio volume in python and ffmpeg or similar
<p>I'm trying to read, in <em>near-realtime</em>, the volume coming from the audio of a USB microphone in Python. </p> <p>I have the pieces, but can't figure out how to put it together. </p> <p>If I already have a .wav file, I can pretty simply read it using <strong>wavefile</strong>:</p> <pre><code>from wavefile import WaveReader with WaveReader("/Users/rmartin/audio.wav") as r: for data in r.read_iter(size=512): left_channel = data[0] volume = np.linalg.norm(left_channel) print volume </code></pre> <p>This works great, but I want to process the audio from the microphone in real-time, not from a file.</p> <p>So my thought was to use something like ffmpeg to PIPE the real-time output into WaveReader, but my Byte knowledge is somewhat lacking. </p> <pre><code>import subprocess import numpy as np command = ["/usr/local/bin/ffmpeg", '-f', 'avfoundation', '-i', ':2', '-t', '5', '-ar', '11025', '-ac', '1', '-acodec','aac', '-'] pipe = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=10**8) stdout_data = pipe.stdout.read() audio_array = np.fromstring(stdout_data, dtype="int16") print audio_array </code></pre> <p>That looks pretty, but it doesn't do much. It fails with a <strong>[NULL @ 0x7ff640016600] Unable to find a suitable output format for 'pipe:'</strong> error. </p> <p>I assume this is a fairly simple thing to do given that I only need to check the audio for volume levels. </p> <p>Anyone know how to accomplish this simply? FFMPEG isn't a requirement, but it does need to work on OSX &amp; Linux. </p>
<python><linux><numpy><audio><ffmpeg>
2016-10-19 17:35:14
HQ
40,138,032
Lodash to find if object property exists in array
<p>I have an array of objects like this:</p> <pre><code>[ {"name": "apple", "id": "apple_0"}, {"name": "dog", "id": "dog_1"}, {"name": "cat", "id": "cat_2"} ] </code></pre> <p>I want to insert another element, also named <code>apple</code>, however, because I don't want duplicates in there, how can I use lodash to see if there already is an object in the array with that same name? </p>
<javascript><arrays><reactjs><lodash>
2016-10-19 17:35:16
HQ
40,138,907
Check For Internet Connectivity In Xcode
I am using Swift 3 and xCode 8. All the other scripts and stuff online to do this all raise a lot of errors. How would I in a simple way make the app check for an internet connection when it was launched and if it had one to continue and if it doesn't have a connection to show the user a popup saying so? I am open to any suggestion. Thank you!
<swift3><reachability>
2016-10-19 18:23:31
LQ_EDIT
40,138,961
clearing border in second table using css
<p>I have created two tables on an html page, I want the first table to have a border but I don't want the second table to have one. How do I make the second table not display a border in css?</p>
<html><css><html-table>
2016-10-19 18:26:52
LQ_EDIT
40,139,667
Lodash group by multiple properties if property value is true
<p>I have an array of vehicles that need to be grouped by make and model, only if the 'selected' property is true. The resulting object should contain properties for make model and count. Using lodash, how can I organize the vehicle objects into the desired result objects. I'm able to get the vehicle objects grouped by makeCode but I'm not sure how to group by more than one property.</p> <p><strong><em>group by make code works</em></strong></p> <pre><code> var vehicles = _.groupBy(response.vehicleTypes, function(item) { return item.makeCode; // how to group by model code as well }); </code></pre> <p><strong><em>initial vehicles</em></strong></p> <pre><code>{ id: 1, selected: true, makeCode: "Make-A", modelCode: "Model-a", trimCode: "trim-a", yearCode: "2012" }, { id: 2, selected: false, makeCode: "Make-A", modelCode: "Model-a", trimCode: "trim-a", yearCode: "2013" }, { id: 3, selected: true, makeCode: "Make-B", modelCode: "Model-c", trimCode: "trim-a", yearCode: "2014" }, { id: 25, selected: true, makeCode: "Make-C", modelCode: "Model-b", trimCode: "trim-b", yearCode: "2012" }, { id: 26, selected: true, makeCode: "Make-C", modelCode: "Model-b", trimCode: "trim-a", yearCode: "2013" } </code></pre> <p><strong><em>result object</em></strong></p> <pre><code>{ Make-A: { Model-a: { count: 1 } } }, { Make-B: { Model-c: { count: 1 } } }, { Make-C: { Model-b: { count: 2 } } } </code></pre>
<javascript><lodash>
2016-10-19 19:10:30
HQ
40,140,062
Is 'return' necessary in the last line of JS function?
<p>what's the best practice of finishing the JS function if it doesn't return anything?</p> <pre><code>function (a) {if (a) {setTimeout()} return;} </code></pre> <p>In this case 'return' is unnecessary but I leave it for readability purposes. I also tried to google if this is a way to micro-optimize JS but wasn't able to find anything.</p>
<javascript>
2016-10-19 19:33:42
HQ
40,140,178
How to add Google Analytics to Github respository
<p>I like to add google analytics on my github respository. So i can keep track of user visit.</p>
<git><google-analytics>
2016-10-19 19:40:39
HQ
40,141,486
error: incompatible types: Vb0201 cannot be coverted to JFrame
My problem is that i want to make a simple JFrame, but i keep getting the same error with this line of code: JFrame frame = new Vb0201(); The error that i get is: error: incompatible types: Vb0201 cannot be coverted to JFrame The full sourcecode is: import javax.swing.*; public class Vb0201 { public static void main(String[] args) { JFrame frame = new Vb0201(); frame.setSize( 400, 200 ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setTitle( "Eerste applicatie" ); frame.setVisible( true ); } }
<java><swing><jframe>
2016-10-19 21:02:17
LQ_EDIT
40,143,289
Why do most asyncio examples use loop.run_until_complete()?
<p>I was going through the Python documentation for <code>asyncio</code> and I'm wondering why most examples use <code>loop.run_until_complete()</code> as opposed to <code>Asyncio.ensure_future()</code>.</p> <p>For example: <a href="https://docs.python.org/dev/library/asyncio-task.html" rel="noreferrer">https://docs.python.org/dev/library/asyncio-task.html</a></p> <p>It seems <code>ensure_future</code> would be a much better way to demonstrate the advantages of non-blocking functions. <code>run_until_complete</code> on the other hand, blocks the loop like synchronous functions do. </p> <p>This makes me feel like I should be using <code>run_until_complete</code> instead of a combination of <code>ensure_future</code>with <code>loop.run_forever()</code> to run multiple co-routines concurrently.</p>
<python-3.x><python-asyncio>
2016-10-19 23:46:46
HQ
40,143,500
How to make Pipeline job to wait for all triggered parallel jobs?
<p>I've Groovy script as part of the Pipeline job in Jenkins as below:</p> <pre><code>node { stage('Testing') { build job: 'Test', parameters: [string(name: 'Name', value: 'Foo1')], quietPeriod: 2, wait: false build job: 'Test', parameters: [string(name: 'Name', value: 'Bar1')], quietPeriod: 2, wait: false build job: 'Test', parameters: [string(name: 'Name', value: 'Baz1')], quietPeriod: 2, wait: false build job: 'Test', parameters: [string(name: 'Name', value: 'Foo2')], quietPeriod: 2, wait: false build job: 'Test', parameters: [string(name: 'Name', value: 'Bar2')], quietPeriod: 2, wait: false build job: 'Test', parameters: [string(name: 'Name', value: 'Baz2')], quietPeriod: 2, wait: false } } </code></pre> <p>which executes multiple other freestyle jobs in parallel, because of <code>wait</code> flag being set to <code>false</code>. However I'd like for the caller job to finish when all jobs are finished. Currently the Pipeline job triggers all the jobs and finishes it-self after few seconds which is not what I want, because I cannot track the total time and I don't have ability to cancel all triggered jobs at one go.</p> <p>How do I correct above script for Pipeline job to finish when all jobs in parallel are completed?</p> <p>I've tried to wrap build jobs in <code>waitUntil {}</code> block, but it didn't work.</p>
<jenkins><groovy><jenkins-pipeline>
2016-10-20 00:13:56
HQ
40,143,528
hdfs dfs -mkdir, No such file or directory
<p>Hi I am new to hadoop and trying to create directory in hdfs called twitter_data. I have set up my vm on softlayer, installed &amp; started hadoop successfully. </p> <p>This is the commend I am trying to run:</p> <blockquote> <p>hdfs dfs -mkdir hdfs://localhost:9000/user/Hadoop/twitter_data</p> </blockquote> <p>And it keeps returning this error message: </p> <pre><code> /usr/local/hadoop/etc/hadoop/hadoop-env.sh: line 2: ./hadoop-env.sh: Permission denied 16/10/19 19:07:03 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable mkdir: `hdfs://localhost:9000/user/Hadoop/twitter_data': No such file or directory </code></pre> <p>Why does it say there is no such file and directory? I am ordering it to make directory, shouldn't it just create one? I am guessing it must be the permission issue, but I cant resolve it. Please help me hdfs experts. I have been spending too much time on what seems to be a simple matter.</p> <p>Thanks in advance. </p>
<hadoop><hdfs>
2016-10-20 00:18:37
HQ
40,144,202
JAVA - read binary file with header (trying to transfer c++ code)
i have some old C code that does what i need, with the file type i'm working with, but i need to get it into Java. i've been reading up on binary I/O but i can't figure out how to deal with the header and i don't understand the C code enough to know what it's doing i would appreciate any assistance - mostly with understanding what the C code means when it uses br.readInt32() and such and how to emulate that with Java which (as i understand it) reads the binary differently i don't understand binary files very well (nor do i want to, this is a one off code piece), i just want to get the data out then i can work on the code that i understand better. thanks C snippet: [code] public void ConvertEVDtoCSV(string fileName) { string[] fileArray = File.ReadAllLines(fileName); float minX = 0; float maxX = 0; try { FileStream fs = new FileStream(fileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); /* 16 + n*80*6 = sizeof(header) where n is the 9th nibble of the file (beginning of the 5th byte) */ //Reads "EVIS" br.ReadBytes(4); //Reads numDataSets int numDataSets = br.ReadInt32(); //Reads lngNumPlotSurfaces int lngNumPlotSurfaces = br.ReadInt32(); //Reads headerEvisive length int headerEvisive = br.ReadInt32(); //skip all six title and axes text lines. int remainingHeader = (lngNumPlotSurfaces * 6 * 80) + headerEvisive; br.ReadBytes(remainingHeader); //could also use seek(remainingHeader+16), but streams don't support seek? long dataSize = numDataSets * (2 + lngNumPlotSurfaces); //meb 6-8-2016: +2 for X and Y string[] dataForCSVFile = new string[dataSize]; for (long cnt = 0; cnt < numDataSets; cnt++) { for (int j = 0; j < 2 + lngNumPlotSurfaces; j++) //+2 for X and Y { //don't read past the end of file if (br.BaseStream.Position<br.BaseStream.Length) { //This is where the data needs to be read in and converted from 32-bit single-precision floating point to strings for the csv file float answerLittle = br.ReadSingle(); if (j == 0 && answerLittle > maxX) maxX = answerLittle; if (j == 0 && answerLittle < minX) minX = answerLittle; if (j > lngNumPlotSurfaces) dataForCSVFile[cnt * (2 + lngNumPlotSurfaces) + j] = answerLittle.ToString() + "\r\n"; else dataForCSVFile[cnt * (2 + lngNumPlotSurfaces) + j] = answerLittle.ToString() + ","; } } } fs.Close(); textBox_x_max.Text = (maxX).ToString("F2"); textBox_x_min.Text = (minX).ToString("F2"); StreamWriter sw = new StreamWriter(tempfile); for (int i = 0; i < dataForCSVFile.Length; i++) { sw.Write(dataForCSVFile[i]); } sw.Close(); } catch (Exception ex) { Console.WriteLine("Error reading data past eof."); } }
<java>
2016-10-20 01:53:23
LQ_EDIT
40,144,668
Repeated Popup: Xcode wants to access key "com.apple.dt.XcodeDeviceMonitor" in your keychain
<p>Starting in MacOS Sierra, I've started to get this popup periodically from XCode, even after pressing 'Always Allow'. </p> <p><a href="https://i.stack.imgur.com/fWurq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fWurq.png" alt="Popup"></a></p> <p>I've tried deleting the "com.apple.dt.XcodeDeviceMonitor" item in Keychain. This regenerates the key, but doesn't fix the issue.</p> <p>It's an open discussion topic on the Apple <a href="https://forums.developer.apple.com/thread/64863" rel="noreferrer">forums</a>, but no one seems to have a solution.</p>
<xcode><macos><macos-sierra>
2016-10-20 02:58:56
HQ
40,145,917
How do you set a cell to null in datagrip?
<p>Is there a quick way without diving into sql to set a particular attribute back to null? entering in "" doesn't work. </p>
<datagrip>
2016-10-20 05:12:17
HQ
40,145,996
Fragments Implement OnClickListener
<p>I have this Fragments but i cant findviewbyid. i already look around website but get nothing. thankss</p> <pre><code>public class Course extends Fragment implements OnClickListener @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.course, container, false); View button1Button = findViewById(R.id.button_button1); button1Button.setOnClickListener(this); View button2Button = findViewById(R.id.button_button2); button2Button.setOnClickListener(this); View button3Button = findViewById(R.id.button_button3); button3Button.setOnClickListener(this); View button4Button = findViewById(R.id.button_button4); button4Button.setOnClickListener(this); View button5Button = findViewById(R.id.button_button5); button5Button.setOnClickListener(this); View button6Button = findViewById(R.id.button_button6); button6Button.setOnClickListener(this); View button7Button = findViewById(R.id.button_button7); button7Button.setOnClickListener(this); View button8Button = findViewById(R.id.button_button8); button8Button.setOnClickListener(this); } </code></pre> <p>thankss</p>
<android><android-studio><android-fragments><fragment>
2016-10-20 05:18:12
LQ_CLOSE
40,146,472
quickest way to swap index with values
<p>consider the <code>pd.Series</code> <code>s</code></p> <pre><code>s = pd.Series(list('abcdefghij'), list('ABCDEFGHIJ')) s A a B b C c D d E e F f G g H h I i J j dtype: object </code></pre> <p>What is the quickest way to swap index and values and get the following</p> <pre><code>a A b B c C d D e E f F g G h H i I j J dtype: object </code></pre>
<python><pandas>
2016-10-20 05:54:37
HQ
40,147,676
Javascript Copy To Clipboard on safari?
<p>It may be duplicate question but i didnt find the solution for this.</p> <p>I am trying to copy text on button click. Its working on chrome, mozilla(working on on windows and mac but not on linux). And its not working on safari.</p> <p>I am using <code>document.execCommand("copy")</code> command for copy. </p> <p><strong>Is safari support this command?</strong></p> <p><strong>Is there any way which will supports to all browsers?</strong></p>
<javascript><jquery><google-chrome><firefox><safari>
2016-10-20 07:07:56
HQ
40,148,179
Check if a specific string contains any lower/uppercase
<p>Is there a way to check if a <strong>specific</strong> string contains any lower/upper case ?</p> <p>E.G :</p> <pre><code>String myStr = "test"; if (myStr.contains("test") { // I would like this condition to check the spell of "test", weather it is written like "Test" or "teSt" etc... //Do stuff } </code></pre> <p>With this syntax, it works only for the exact same string. How could I make my condition for anyform of "test", like : "Test", "tEst", "tesT" etc... ?</p>
<java><string>
2016-10-20 07:34:16
LQ_CLOSE
40,149,418
Django channels and socket.io-client
<p>I'm trying to use them for the first time and wonder I'm headed to the right direction.</p> <p>Here are my understandings, </p> <p>socket.io is a wrapper around websocket, and falls back to sub-optimal solutions when websocket is not available.</p> <p>Django channels can talk websocket as well.<br> (I think it converts django as a message queue like system. although this understanding or misunderstanding should affect this question)</p> <p>So I'm trying to use Django channels on the server and socket.io-client on the client.</p> <p>socket.io has api which looks like </p> <p><code>socket.on(type, (payload)=&gt; {})</code></p> <p>Whereas Django channels has a form of</p> <p><code>message.reply_channel.send({ "text": json }) </code></p> <p>is the "text" <code>type</code> of <code>socket.on(type)</code>?</p> <p>Can Django channels and socket.io-client talk to each other?</p>
<django><socket.io>
2016-10-20 08:38:10
HQ
40,150,658
Does PHP have to go along with SQL?
<p>I have been researching Sql, Django, PhP,</p> <p>I saw this one tutorial on creating a social network website and they were using SQL in conjunction with PHP. Is this always required? What does the PHP do for the SQL? I know it is a server side, but isn't Django as well? So I can use Django/SQL instead of PHP/SQL?</p>
<php><python><sql><django>
2016-10-20 09:34:01
LQ_CLOSE
40,150,693
C# button up/down/left/right not detected
<p>A week ago I used this for detecting the <code>up/down/left/right keys</code> in my wpf application:</p> <pre><code>private void Invaders_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyCode.ToString()); switch (e.KeyCode.ToString()) { case "Up": MessageBox.Show("Up"); break; case "Down": MessageBox.Show("Down"); break; case "Left": MessageBox.Show("Left"); break; case "Right": MessageBox.Show("Right"); break; } } </code></pre> <p>But today I started a new application and this does not work anymore? It detects everything except <code>up/down/left/right</code>. What could be going on here?</p>
<c#><wpf>
2016-10-20 09:35:37
LQ_CLOSE
40,151,107
I am new in java please help when i run my code it shows an error like.
public class PhraseOMatic { public void main (String[] args) { String [] wordListOne = {"24/7","multitier","Akshay","Aalok","teslaBoys","Team"}; String[] wordListTwo = {"empowered","positivity","money","foucused","welth","strenth"}; String[] wordListThree = {"ok","dear","priorityies","love","Dreams","sapne"}; int oneLength = wordListOne.length; int twoLength = wordListTwo.length; int threeLength = wordListThree.length; int rand1 = (int) (Math.random() * oneLength); int rand2 = (int) (Math.random() * twoLength); int rand3 = (int) (Math.random() * threeLength); String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3]; System.out.println("What we need is a " + phrase); } } // error Main.java:1: error: class PhraseOMatic is public, should be declared in a file named PhraseOMatic.java public class PhraseOMatic { ^ 1 error
<java>
2016-10-20 09:54:19
LQ_EDIT
40,151,410
IntelliJ highlights Lombok generated methods as “cannot resolve method”
<p>I am using Lombok’s <code>@Data</code> annotation to create the basic functionality of my POJOs. When I try to use these generated methods, IntelliJ highlights these as errors (<code>Cannot resolve method ‘getFoo()’</code>) and seems to be unable to find them. They do however exist, as I am able to run code using these methods without any trouble.</p> <p>I made sure to enable annotation processing, so that shouldn’t cause any problems.</p> <p>How can I get IntelliJ to find the methods and stop wrongly marking them as errors?</p>
<java><intellij-idea><lombok>
2016-10-20 10:08:18
HQ
40,152,483
HTTPURLResponse allHeaderFields Swift 3 Capitalisation
<p>Converting to Swift 3 I noticed a strange bug occur reading a header field from HTTPURLResponse.</p> <pre><code>let id = httpResponse.allHeaderFields["eTag"] as? String </code></pre> <p>no longer worked.</p> <p>I printed out the all headers dictionary and all my header keys seem to be in Sentence case.</p> <p>According to Charles proxy all my headers are in lower case. According to the backend team, in their code the headers are in Title-Case. According the docs: headers should be case-insensitive. </p> <p>So I don't know which to believe. Is anyone else finding in Swift 3 that their headers are now being turned into Sentence case by iOS? If so is this behaviour we want?</p> <p>Should I log a bug with Apple or should I just make a category on HTTPURLResponse to allow myself to case insensitively find a header value.</p>
<ios><http><swift3><case-insensitive><nshttpurlresponse>
2016-10-20 10:57:38
HQ
40,152,491
Hi Guys, am new to codeigniter, i used active record to update my data in my database and its updated inside the database,
am new to codeigniter, i used active record to update my data in my database and its updated inside the database, but after updating data inside the database, i want it to redirect back to my Edit Page showing the updated data from my database.. i have tried all my possible best but its not working.. pls help.. my codeigniter version is 2.7 <!--THIS IS MY CONTROLLER--> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class account extends CI_Controller { function __construct() { parent::__construct(); } public function index(){ $username = $this->input->post('username'); $password = $this->input->post('password'); $result = $this->login_model->database($username, $password); if ($result == TRUE){ $data['posts'] = $result; $data['subview'] = 'testview'; $this->load->view('display', $data); }else{ echo "invalid password"; }; } public function edit(){ $id = $this->input->post('id'); $name = $this->input->post('name'); $email = $this->input->post('email'); $telephone = $this->input->post('telephone'); $result = $this->login_model->update($id, $name, $email, $telephone); if ($result == TRUE){ redirect('account/edit'); } } } <!-- end snippet --> <!--THIS IS MY MODEL--> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class login_model extends CI_Model { function __construct() { parent::__construct(); } public function database($username, $password) { $this->db->select('*'); $this->db->from('user'); $this->db->where('username', $username); $this->db->where('password', $password); $this->db->limit(1); $query = $this->db->get(); if($query->num_rows() ==1){ return $query->result(); }else{ return false; } } public function update($id){ $data = array( 'id' => $this->input->post('id'), 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'telephone' => $this->input->post('telephone'), ); $this->db->where('id', $id); $this->db->update('user', $data); } } <!-- end snippet -->
<php><mysql><codeigniter>
2016-10-20 10:58:04
LQ_EDIT
40,152,854
How to watch for file changes "dotnet watch" with Visual Studio ASP.NET Core
<p>I am using Visual Studio with ASP.NET Core and run the web site using just F5 or Ctrl+F5 (not using command line directly). I would like to use the "dotnet watch" functionality to make sure all changes are picked up on the fly to avoid starting the server again. It seems that with command line you would use "dotnet watch run" for this, but Visual Studio uses launchSettings.json and does it behind the scenes if I understand it correctly. </p> <p>How can I wire up "dotnet watch" there?</p>
<asp.net-core><dnx><kestrel-http-server>
2016-10-20 11:14:24
HQ
40,152,959
Annotate interface function that must call super
<p>I'm creating interface and some function in it has a body. It's required, that class that implements this interface must call super in overriding function before executing other code. How can I do this?</p> <pre><code>interface Watcher { fun funWithoutBody() fun startWatching() { //do some important stuff which must be called } } </code></pre>
<kotlin>
2016-10-20 11:18:48
HQ
40,153,045
Angular2 get ActivatedRoute url
<p>I want to get the url which comes from this:</p> <p><code>this.router.navigate(./somepath, { relativeTo: this.route })</code></p> <p><code>this.route</code> is of the type <code>ActivatedRoute</code>.</p> <p>I tried <code>url: string = route.snapshot.url.join('');</code> but this gives an empty string.</p>
<angular><angular-routing>
2016-10-20 11:22:51
HQ
40,153,361
What is the difference between QQmlApplicationEngine and QQuickView?
<p>I'm using <code>QQmlApplicationEngine</code> as follows:</p> <pre><code>QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); app.exec(); </code></pre> <p>But now I want to enable multisampling for my app, and <code>QQmlApplicationEngine</code> doesn't seem to have a <code>setFormat</code> method for enabling multisampling.</p> <p>I found a way to do it with a <code>QQmlApplicationEngine</code> <a href="https://v-play.net/developers/forums/t/antialiasing#post-9745" rel="noreferrer">in a forum</a>:</p> <pre><code>QQuickWindow* window = (QQuickWindow*) engine.rootObjects().first(); QSurfaceFormat format; format.setSamples(16); window-&gt;setFormat(format) </code></pre> <p>But it relies on the first root object of the engine being a <code>QQuickWindow</code>, which is not documented in Qt docs. So I don't want to use that technique.</p> <p>Another way would be to skip <code>QQmlApplicationEngine</code> and create a <code>QQuickView</code> instead. This does have a <code>setFormat</code> method letting me enable multisampling, but I'm wondering, am I losing anything by switching from <code>QQmlApplicationEngine</code> to <code>QQuickView</code>?</p> <p>In other words, what are the differences between these two classes?</p> <p>One difference I found is this (from <a href="http://doc.qt.io/qt-5/qqmlapplicationengine.html#details" rel="noreferrer">here</a>):</p> <blockquote> <p>Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window.</p> </blockquote> <p>This particular difference doesn't matter to me.</p> <p>Any other differences?</p>
<qt><qml><qtquick2><qquickview><qqmlapplicationengine>
2016-10-20 11:37:18
HQ
40,153,542
how to get the telecom provider name of dual sim in android
enter code here public String getImsiSIM1() { return imsiSIM1; } public String getImsiSIM2() { return imsiSIM2; } public boolean isSIM1Ready() { return isSIM1Ready; } public boolean isSIM2Ready() { return isSIM2Ready; } /*public static void setSIM2Ready(boolean isSIM2Ready) { TelephonyInfo.isSIM2Ready = isSIM2Ready; }*/ public boolean isDualSIM() { return imsiSIM2 != null; } public String getNetworkOperator(){ return networkOperatorOne ; } public String getNetworkOperatorDual(){ return networkOperatorDual ; } private TelephonyInfo() { } public static TelephonyInfo getInstance(Context context){ if(telephonyInfo == null) { telephonyInfo = new TelephonyInfo(); TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)); telephonyInfo.imsiSIM1 = telephonyManager.getDeviceId();; telephonyInfo.imsiSIM2 = null; telephonyInfo.networkOperatorOne =telephonyManager.getNetworkOperator(); telephonyInfo.networkOperatorDual = null ; try { telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context, "getDeviceIdGemini", 0); telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context, "getDeviceIdGemini", 1); telephonyInfo.networkOperatorOne = getCarrierName(context,"getCarrierName",0); telephonyInfo.networkOperatorDual = getCarrierName(context,"getCarrierName",1); } catch (GeminiMethodNotFoundException e) { e.printStackTrace(); try { telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context, "getDeviceId", 0); telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context, "getDeviceId", 1); telephonyInfo.networkOperatorOne = getCarrierName(context,"getCarrierName",0); telephonyInfo.networkOperatorDual = getCarrierName(context,"getCarrierName",1); } catch (GeminiMethodNotFoundException e1) { //Call here for next manufacturer's predicted method name if you wish e1.printStackTrace(); } } telephonyInfo.isSIM1Ready = telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY; telephonyInfo.isSIM2Ready = false; try { telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimStateGemini", 0); telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimStateGemini", 1); } catch (GeminiMethodNotFoundException e) { e.printStackTrace(); try { telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimState", 0); telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimState", 1); } catch (GeminiMethodNotFoundException e1) { //Call here for next manufacturer's predicted method name if you wish e1.printStackTrace(); } } } return telephonyInfo; } private static String getDeviceIdBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException { String imsi = null; TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try{ Class<?> telephonyClass = Class.forName(telephony.getClass().getName()); Class<?>[] parameter = new Class[1]; parameter[0] = int.class; Method getSimID = telephonyClass.getMethod(predictedMethodName, parameter); Object[] obParameter = new Object[1]; obParameter[0] = slotID; Object ob_phone = getSimID.invoke(telephony, obParameter); if(ob_phone != null){ imsi = ob_phone.toString(); } } catch (Exception e) { e.printStackTrace(); throw new GeminiMethodNotFoundException(predictedMethodName); } return imsi; } private static boolean getSIMStateBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException { boolean isReady = false; TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try{ Class<?> telephonyClass = Class.forName(telephony.getClass().getName()); Class<?>[] parameter = new Class[1]; parameter[0] = int.class; Method getSimStateGemini = telephonyClass.getMethod(predictedMethodName, parameter); Object[] obParameter = new Object[1]; obParameter[0] = slotID; Object ob_phone = getSimStateGemini.invoke(telephony, obParameter); if(ob_phone != null){ int simState = Integer.parseInt(ob_phone.toString()); if(simState == TelephonyManager.SIM_STATE_READY){ isReady = true; } } } catch (Exception e) { e.printStackTrace(); throw new GeminiMethodNotFoundException(predictedMethodName); } return isReady; } private static String getCarrierName(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException { String carrier = null; TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try{ Class<?> telephonyClass = Class.forName(telephony.getClass().getName()); Class<?>[] parameter = new Class[1]; parameter[0] = int.class; Method sim = telephonyClass.getMethod(predictedMethodName, parameter); Object[] obParameter = new Object[1]; obParameter[0] = slotID; Object ob_phone = sim.invoke(telephony, obParameter); if(ob_phone != null){ carrier = ob_phone.toString(); if(carrier .equals(TelephonyManager.SIM_STATE_READY)) { Log.d("Services","servicessss"+carrier); ; } } } catch (Exception e) { e.printStackTrace(); throw new GeminiMethodNotFoundException(predictedMethodName); } return carrier; } private static class GeminiMethodNotFoundException extends Exception { private static final long serialVersionUID = -996812356902545308L; public GeminiMethodNotFoundException(String info) { super(info); } } }
<android><telephonymanager>
2016-10-20 11:45:55
LQ_EDIT
40,153,543
Java: Difference between Class.function() and Object.function()
<p>In cases where it does not seem to matter, i.e. the value is a parameter and the function is not operating directly on the calling object instance, what are the "under the hood" differences between calling a Class.function() and Object.function()?</p> <p>This can be illustrated by a convoluted example:</p> <pre><code>Character c = new Character(); boolean b = c.isDigit(c); </code></pre> <p>vs.</p> <pre><code>boolean b = Character.isDigit(c); </code></pre> <p>I can see cases where hardcoded variables would easier to change (find/replace) if only Character were used repeatedly instead of a bunch of different instance names. MOST IMPORTANTLY: What is the accepted best practice?</p>
<java><class><oop><object>
2016-10-20 11:45:59
LQ_CLOSE
40,154,672
"ImportError: file_cache is unavailable" when using Python client for Google service account file_cache
<p>I'm using a service account for G Suite with full domain delegation. I have a script with readonly access to Google Calendar. The script works just fine, but throws an error (on a background thread?) when I "build" the service. Here's the code:</p> <pre><code>from oauth2client.service_account import ServiceAccountCredentials from httplib2 import Http import urllib import requests from apiclient.discovery import build cal_id = "my_calendar_id@group.calendar.google.com" scopes = ['https://www.googleapis.com/auth/calendar.readonly'] credentials = ServiceAccountCredentials.from_json_keyfile_name('my_cal_key.json', scopes=scopes) delegated_credentials = credentials.create_delegated('me@mydomain.com') http_auth = delegated_credentials.authorize(Http()) # This is the line that throws the error cal_service = build('calendar','v3',http=http_auth) #Then everything continues to work normally request = cal_service.events().list(calendarId=cal_id) response = request.execute() # etc... </code></pre> <p>The error thrown is:</p> <pre><code>WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client &gt;= 4.0.0 Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect from google.appengine.api import memcache ImportError: No module named 'google' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in &lt;module&gt; from oauth2client.contrib.locked_file import LockedFile ImportError: No module named 'oauth2client.contrib.locked_file' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in &lt;module&gt; from oauth2client.locked_file import LockedFile ImportError: No module named 'oauth2client.locked_file' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect from . import file_cache File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in &lt;module&gt; 'file_cache is unavailable when using oauth2client &gt;= 4.0.0') ImportError: file_cache is unavailable when using oauth2client &gt;= 4.0.0 </code></pre> <p>What's going on here and is this something that I can fix? I've tried reinstalling and/or upgrading the <code>google</code> package. </p>
<python><google-calendar-api>
2016-10-20 12:36:31
HQ
40,154,727
How to use xmltodict to get items out of an xml file
<p>I am trying to easily access values from an xml file.</p> <pre><code>&lt;artikelen&gt; &lt;artikel nummer="121"&gt; &lt;code&gt;ABC123&lt;/code&gt; &lt;naam&gt;Highlight pen&lt;/naam&gt; &lt;voorraad&gt;231&lt;/voorraad&gt; &lt;prijs&gt;0.56&lt;/prijs&gt; &lt;/artikel&gt; &lt;artikel nummer="123"&gt; &lt;code&gt;PQR678&lt;/code&gt; &lt;naam&gt;Nietmachine&lt;/naam&gt; &lt;voorraad&gt;587&lt;/voorraad&gt; &lt;prijs&gt;9.99&lt;/prijs&gt; &lt;/artikel&gt; ..... etc </code></pre> <p>If i want to acces the value ABC123, how do I get it?</p> <pre><code>import xmltodict with open('8_1.html') as fd: doc = xmltodict.parse(fd.read()) print(doc[fd]['code']) </code></pre>
<python><xml><xmltodict>
2016-10-20 12:38:25
HQ
40,155,196
What's wrong with my command Insert using a datagriedview
I'm trying to insert data into my database using a DataGriedView in C #. However when I click the save button appears the following error message: System.Data.OleDb.OleDbException was unhandled    HResult = -2147217900    Message = Syntax error in INSERT INTO statement.    Source = Microsoft Office Access Database Engine    ErrorCode = -2147217900    Here's the code I have: private void save_btn_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Stock.accdb"); con.Open(); for (int i = 0; i < dataGridView_insert.Rows.Count; i++) { OleDbCommand cmd = new OleDbCommand("INSERT INTO product(OV,Reference,Cod_Client,Client,Qtd,Type_product,Posicion_product,) VALUES ('" + dataGridView_insert.Rows[i].Cells["OV"].Value + "','" + dataGridView_insert.Rows[i].Cells["Reference"].Value + "','" + dataGridView_insert.Rows[i].Cells["Cod_Client"].Value + "','" + dataGridView_insert.Rows[i].Cells["Client"].Value + "','" + dataGridView_insert.Rows[i].Cells["Qtd"].Value + "','" + dataGridView_insert.Rows[i].Cells["Type_product"].Value + "','" + dataGridView_insert.Rows[i].Cells["Posicion_product"].Value + " ' ", con); cmd.ExecuteNonQuery(); } con.Close(); } What is wrong? Thanks in advance,
<c#><mysql><sql><database>
2016-10-20 13:00:24
LQ_EDIT
40,155,770
Could you please give please tell me how to give validators in Mongodb database?
I m working on backend with database MongoDB .I have already done server side validation using node js , now I need to add validation in database level .Could you pls tell me how to give required validators , unique validators , exists validators in MongoDB As of now I have added one validator in MongoDB like that db.createCollection(name:("string")).
<mongodb><validation><database>
2016-10-20 13:25:08
LQ_EDIT
40,156,035
google-bigquery format date as mm/dd/yyyy in query results
<p>I am using Bigquery SQL to generate a report. The standard Bigquery date format is yyyy-mm-dd, but I want it to be formatted as mm/dd/yyyy.</p> <p>Is there a way via Bigquery SQL to convert the date format on SELECT?</p> <p>Thanks in advance,</p>
<sql><date><format><google-bigquery>
2016-10-20 13:35:39
HQ
40,156,203
Unable to monitor event loop AND Wait for app to idle
<p>I am writing UITest cases for my app using XCTest. App makes several server calls in the homescreen. I could not navigate to next screen. Automation often stays idle for 1 min or even more than that with the message </p> <blockquote> <p>Wait for app to idle </p> </blockquote> <p>or</p> <blockquote> <p>Unable to monitor event loop</p> </blockquote> <p>Is the there a way to make the app to execute my testCases breaking this ???</p>
<ios><xcode><xctest><xctestcase>
2016-10-20 13:42:37
HQ
40,156,610
just started learning selenium.while i run my first selenium code i got this error
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296) at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127) at sele.Abc.main(Abc.java:10)
<java><selenium-webdriver><selenium-rc>
2016-10-20 13:59:10
LQ_EDIT
40,157,154
googleMaps load from DB with GeoLocation
So I have some working code which fetches results from my DB and displays them on a google map. I also have some code which uses my location to place a marker on a google map. My issue is that when i add them together the page loads the results from the DB then i accept geoloaction and it centers the map to my location but doesnt display my marker and also removes the markers for the db results. here is the db result code: <!DOCTYPE html > <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>PHP/MySQL & Google Maps Example</title> <script src="https://maps.googleapis.com/maps/api/js?key=API_KEY" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var customIcons = { restaurant: { icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png' }, bar: { icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png' } }; function load() { var map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(47.6145, -122.3418), zoom: 13, mapTypeId: 'roadmap' }); var infoWindow = new google.maps.InfoWindow; // Change this depending on the name of your PHP file downloadUrl("/Models/phpsqlajax_genxml2.php", function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var html = "<b>" + name + "</b> <br/>" + address; var icon = customIcons[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon }); bindInfoWindow(marker, map, infoWindow, html); } }); } function bindInfoWindow(marker, map, infoWindow, html) { google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html); infoWindow.open(map, marker); }); } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing() {} //]]> </script> </head> <body onload="load()"> <div id="map" style="width: 500px; height: 300px"></div> </body> </html> This is my geolocation code: // Check if user support geo-location if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; var geolocpoint = new google.maps.LatLng(latitude, longitude); var map = new google.maps.Map(document.getElementById('nearMeMap'), { zoom: 11, scaleControl: false, scrollwheel: false, center: geolocpoint, mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } // Place a marker var geolocation = new google.maps.Marker({ position: geolocpoint, map: map, title: 'Your Location', icon: 'https://mt.google.com/vt/icon?psize=20&font=fonts/Roboto-Regular.ttf&color=ff330000&name=icons/spotlight/spotlight-waypoint-blue.png&ax=44&ay=48&scale=1&text=%E2%80%A2' }); }); } Also i get this in the console: ReferenceError: locations is not defined for (i = 0; i < locations.length; i++) {
<javascript><php><google-maps>
2016-10-20 14:22:36
LQ_EDIT
40,157,445
Mac Terminal error: -bash: /Users/tim/.profile: No such file or directory
<p>Every time I open a new Terminal window I see the following.</p> <pre><code>-bash: /Users/tim/.profile: No such file or directory </code></pre> <p>I have no idea why this is happening or where to look to fix it; my profile is located at <code>/Users/tim/.bash_profile</code> not <code>/Users/tim/.profile</code></p> <p>Any thoughts on how to troubleshoot this?</p>
<terminal>
2016-10-20 14:34:59
HQ
40,159,653
Digest authentication in ASP.NET Core / Kestrel
<p>Is it possible to use <a href="https://en.wikipedia.org/wiki/Digest_access_authentication" rel="noreferrer">digest authentication</a> in ASP.NET Core / Kestrel? If it is, how do I enable and use it?</p> <p>I know that <a href="https://en.wikipedia.org/wiki/Basic_access_authentication" rel="noreferrer">basic authentication</a> is not and will not be implemented because <a href="https://github.com/aspnet/Security#notes" rel="noreferrer">it's considered insecure and slow</a>, but I can't find anything at all about digest.</p> <p>I don't want to use IIS' authentication because I don't want to be tied to Windows accounts, I want use a custom credentials validation logic.</p>
<asp.net-core><digest-authentication><kestrel-http-server>
2016-10-20 16:21:50
HQ
40,159,839
How to make non selectable embed custom format in quilljs
<p>I would like to create a custom embed format which can be styled but it's text cannot be changed. My use case is pretty similar to the hashtag case. I want to have an external button that will add an hashtag to the current selected range on the editor. But after doing this i want the hashtag to behave as a "block" so that the user cannot go there and change its text.</p> <p>The only way i could accomplish this was by saying that the format's node is contenteditable=false but i'm not sure i'm going the right way as i'm having some issues with this approach, mainly:</p> <p>If the hashtag is the last thing on the editor i cannot move past it (with arrows or cursor) Double clicking it to select should select the whole thing (and not individual words) (for styling) If the cursor is immediately behind the hashtag, pressing right and writing will write inside the hashtag You can check a codepen i made while experimenting with this:</p> <pre><code> Quill.import('blots/embed'); class QuillHashtag extends Embed { static create(value) { let node = super.create(value); node.innerHTML = `&lt;span contenteditable=false&gt;#${value}&lt;/span&gt;`; return node; } } QuillHashtag.blotName = 'hashtag'; QuillHashtag.className = 'quill-hashtag'; QuillHashtag.tagName = 'span'; </code></pre> <p>Here's the full codepen: <a href="http://codepen.io/emanuelbsilva/pen/Zpmmzv">http://codepen.io/emanuelbsilva/pen/Zpmmzv</a></p> <p>If you guys can give me any tips on how can i accomplish this i would be glad.</p> <p>Thanks.</p>
<quill>
2016-10-20 16:32:17
HQ
40,160,592
Dockerfile - How to pass an answer to a prompt post apt-get install?
<p>In my Dockerfile, I am trying to install jackd2 package:</p> <pre><code>RUN apt-get install -y jackd2 </code></pre> <p>It installs properly, but after installation, I can see the following prompt:</p> <pre><code>If you want to run jackd with realtime priorities, the user starting jackd needs realtime permissions. Accept this option to create the file /etc/security/limits.d/audio.conf, granting realtime priority and memlock privileges to the audio group. Running jackd with realtime priority minimizes latency, but may lead to complete system lock-ups by requesting all the available physical system memory, which is unacceptable in multi-user environments. Enable realtime process priority? [yes/no] </code></pre> <p>```</p> <p>At this point, I would like to answer with either yes or no, hit enter and move on but I have no idea how to script this inside a dockerfile and my build hangs right there. </p>
<bash><docker><dockerfile>
2016-10-20 17:15:34
HQ
40,160,648
Searching whole word in vim - alternative to \<\>
There are several answers on how to search a whole word in vim. For example, this link http://stackoverflow.com/questions/15288155/how-to-do-whole-word-search-similar-to-grep-w-in-vim answers it. I am wondering is there any alternative to `\<word\>` in vim to search whole word?
<vim><vi>
2016-10-20 17:18:40
LQ_EDIT
40,160,758
Does calling View Model methods in Code Behind events break the MVVM?
<p>I wonder if that would break the MVVM pattern and, if so, why and why is it so bad?</p> <p><strong>WPF:</strong></p> <pre><code>&lt;Button Click="Button_Click" /&gt; </code></pre> <p><strong>Code Behind:</strong></p> <pre><code>private void Button_Click(object sender, RoutedEventArgs e) { ViewModel.CallMethod(); } </code></pre> <p><strong>View Model:</strong></p> <pre><code>public void CallMethod() { // Some code } </code></pre> <p>IMHO, it keeps the code behind quite simple, the view model is still agnostic about the view and code behind and a change to the view doesn't affect the business logic.</p> <p>It seems to me more simple and clear than <code>Commands</code> or <code>CallMethodAction</code>.</p> <p>I don't want the kind of answer "it is not how it should be done". I need a proper and logical reason of why doing so could lead to maintenance or comprehension problems.</p>
<c#><wpf><mvvm>
2016-10-20 17:24:46
HQ
40,161,956
Kotlin sequence concatenation
<pre><code>val seq1 = sequenceOf(1, 2, 3) val seq2 = sequenceOf(5, 6, 7) sequenceOf(seq1, seq2).flatten().forEach { ... } </code></pre> <p>That's how I'm doing sequence concatenation but I'm worrying that it's actually copying elements, whereas all I need is an iterator that uses elements from the iterables (seq1, seq2) I gave it.</p> <p>Is there such a function?</p>
<kotlin>
2016-10-20 18:31:36
HQ
40,161,982
aspnetcore.dll failed to load
<p>I usually dev on a windows 7 desktop, using visual studio 2015 update 3. I have the same vs2015.3 on my windows 10 laptop. I copied an asp mvc 5 app I am working on to the laptop but it wont run when I try to launch it from VS. I get the "aspnetcore.dll failed to load" error. I looked around and most solutions are to repair the asp net core install, but my laptop does not have asp net core installed on it, because I don't use core yet. My project is targeting .Net 4.6.</p> <p>My desktop does have Core on it. So do I have to install .net core just because? Or is there some other solution? I am using the default IIS 10.</p>
<asp.net-mvc><visual-studio><asp.net-core><iis-express>
2016-10-20 18:32:59
HQ
40,162,062
How to define role/permission security in Swagger
<p>In my API documentation, I would like to define the security necessary for each API endpoint. The project has defined roles and permissions that determine which users can access the APIs. What is the best way in Swagger to document this information? Is there a best practice or recommendation on how to show this detail?</p> <p>This what I tried out using securityDefinitions and a self-defined variable for the roles, but that information (x-role-names) didn't get copied over into the documentation when I ran it through swagger2markup or using swagger-ui.</p> <pre><code> "securityDefinitions": { "baseUserSecurity": { "type": "basic", "x-role-names": "test" } } </code></pre> <p>What's the best way to document the role and permission information per endpoint?</p>
<swagger><swagger-ui><swagger-2.0>
2016-10-20 18:36:55
HQ
40,162,370
heartbeat failed for group because it's rebalancing
<p>What's the exact reason to have heartbeat failure for group because it's rebalancing ? What's the reason for rebalance where all the consumers in group are up ? </p> <p>Thank you.</p>
<apache-kafka><kafka-producer-api>
2016-10-20 18:53:50
HQ
40,162,392
How to write ResponseEntity to HttpServletResponse?
<p>How to write ResponseEntity to HttpServletResponse (as it makes @ResponseBody)?</p> <p>For example I have authentication success handler:</p> <pre><code>@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { Map responseMap = new HashMap(); responseMap.put("user", "my_user_name"); ResponseEntity responseEntity = new ResponseEntity(response, HttpStatus.OK); } </code></pre> <p>If use MappingJackson2HttpMessageConverter I have error: "Could not write content: not in non blocking mode."</p> <p>Code:</p> <pre><code>HttpOutputMessage outputMessage = new ServletServerHttpResponse(response); messageConverter.write(responseEntity, null, outputMessage); </code></pre> <p>What are the best practices of implementation handlers with HttpServletResponse?</p>
<java><spring>
2016-10-20 18:54:55
HQ
40,163,348
CanActivate vs. CanActivateChild with component-less routes
<p>The angular2 documentation about <a href="https://angular.io/docs/ts/latest/guide/router.html#!#guards" rel="noreferrer">Route Guards</a> left me unclear about when it is appropriate to use a <code>CanActivate</code> guards vs. a <code>CanActivateChild</code> guard in combination with component-less routes. </p> <p><strong>TL;DR:</strong> what's the point in having <code>canActivateChild</code> when I can use a component-less routes with <code>canActivate</code> to achieve the same effect?</p> <p>Long version: </p> <blockquote> <p>We can have multiple guards at every level of a routing hierarchy. The router checks the CanDeactivate and CanActivateChild guards first, from deepest child route to the top. Then it checks the CanActivate guards from the top down to the deepest child route.</p> </blockquote> <p>I get that <code>CanActivateChild</code> is checked bottom up and <code>CanActivate</code> is checked top down. What doesn't make sense to me is the following example given in the docs: </p> <pre><code>@NgModule({ imports: [ RouterModule.forChild([ { path: 'admin', component: AdminComponent, canActivate: [AuthGuard], children: [ { path: '', canActivateChild: [AuthGuard], children: [ { path: 'crises', component: ManageCrisesComponent }, { path: 'heroes', component: ManageHeroesComponent }, { path: '', component: AdminDashboardComponent } ] } ] } ]) ], exports: [ RouterModule ] }) export class AdminRoutingModule {} </code></pre> <p>So the <code>admin</code> path has a component-less route: </p> <blockquote> <p>Looking at our child route under the AdminComponent, we have a route with a path and a children property but it's not using a component. We haven't made a mistake in our configuration, because we can use a component-less route.</p> </blockquote> <p>Why is the code in this case inserting the <code>AuthGuard</code> in the child and in the root component (path <code>admin</code>)? Wouldn't is suffice to guard at the root? </p> <p>I have created a <a href="http://plnkr.co/edit/B6s8H17q3pGDp2QAqKIU" rel="noreferrer">plunkr</a> based on the sample that removes the <code>canActivateChild: [AuthGuard]</code> and adds a logout button on the <code>AdminDashboard</code>. Sure enough, the <code>canActivate</code> of the parent route still guards, so what's the point in having <code>canActivateChild</code> when I can use component-less routes with <code>canActivate</code>?</p>
<angular><angular2-routing>
2016-10-20 19:53:23
HQ
40,163,527
How to run NUnit test in Visual Studio Team Services
<p>When I try to execute <strong>NUnit</strong> test in VSTS task I am getting the following error:</p> <pre><code>Warning: The path 'C:\a\1\s\INCASOL.IP\packages' specified in the 'TestAdapterPath' does not contain any test adapters, provide a valid path and try again. </code></pre> <p>I have these tasks in VSTS:</p> <p><a href="https://i.stack.imgur.com/pEPFo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pEPFo.png" alt="enter image description here"></a></p> <p>The "Run unit test" task is configured as follows: <a href="https://i.stack.imgur.com/9g8Ix.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9g8Ix.png" alt="enter image description here"></a></p> <p>Note I have set the "Path to Custom Test Adapters".</p> <p>I think the dlls for NUnit are properly copied to packages folder because in "Nuget restore" task I can see the following:</p> <pre><code>Added package 'NUnit.2.6.4' to folder 'C:\a\1\s\INCASOL.IP\packages' </code></pre> <p>Notes: The NUnit version is 2.6.4 and I'm using Hosted Agent</p>
<continuous-integration><nunit><azure-devops><azure-pipelines-build-task>
2016-10-20 20:02:38
HQ
40,163,603
Deleting multiple items based on global secondary index in DynamoDB
<p>I have an existing table which has two fields - primary key and a global secondary index:</p> <pre><code>---------------------------- primary key | attributeA(GSI) ---------------------------- 1 | id1 2 | id1 3 | id2 4 | id2 5 | id1 </code></pre> <p>Since having the attributeA as a global secondary index, can I delete all items by specifying a value for the global secondary index? i.e I want to delete all records with the attributeA being id1 - Is this possible in Dynamo? </p> <p>Dynamo provides documentation about deleting the index itself, but not specifically if we can use the GSI to delete multiple items </p>
<amazon-dynamodb>
2016-10-20 20:06:53
HQ
40,164,243
creating the multiple div dynamically using javascript
i have div element and have a class for it,i want to create multiple div using that class,but i dont want to create nested div,i want to create div outside using javascript,i used append property,but its create nested div below is html as i required need help //have this div <div class="one"></div> //need to create multiple div <div id="one"> </div> <div id="two"> </div> <div id="three"> </div> <div id="four"> </div>
<javascript><html><jquery><knockout.js><dom-events>
2016-10-20 20:47:44
LQ_EDIT
40,164,963
How to run Spark Scala code on Amazon EMR
<p>I am trying to run the following piece of Spark code written in Scala on Amazon EMR:</p> <pre><code>import org.apache.spark.{SparkConf, SparkContext} object TestRunner { def main(args: Array[String]): Unit = { val conf = new SparkConf().setAppName("Hello World") val sc = new SparkContext(conf) val words = sc.parallelize(Seq("a", "b", "c", "d", "e")) val wordCounts = words.map(x =&gt; (x, 1)).reduceByKey(_ + _) println(wordCounts) } } </code></pre> <p>This is the script I am using to deploy the above code into EMR:</p> <pre><code>#!/usr/bin/env bash set -euxo pipefail cluster_id='j-XXXXXXXXXX' app_name="HelloWorld" main_class="TestRunner" jar_name="HelloWorld-assembly-0.0.1-SNAPSHOT.jar" jar_path="target/scala-2.11/${jar_name}" s3_jar_dir="s3://jars/" s3_jar_path="${s3_jar_dir}${jar_name}" ################################################### sbt assembly aws s3 cp ${jar_path} ${s3_jar_dir} aws emr add-steps --cluster-id ${cluster_id} --steps Type=spark,Name=${app_name},Args=[--deploy-mode,cluster,--master,yarn-cluster,--class,${main_class},${s3_jar_path}],ActionOnFailure=CONTINUE </code></pre> <p>But, this exits with producing no output at all in AWS after few minutes!</p> <p>Here's my controller's output:</p> <pre><code>2016-10-20T21:03:17.043Z INFO Ensure step 3 jar file command-runner.jar 2016-10-20T21:03:17.043Z INFO StepRunner: Created Runner for step 3 INFO startExec 'hadoop jar /var/lib/aws/emr/step-runner/hadoop-jars/command-runner.jar spark-submit --deploy-mode cluster --class TestRunner s3://jars/mscheiber/HelloWorld-assembly-0.0.1-SNAPSHOT.jar' INFO Environment: PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/opt/aws/bin LESS_TERMCAP_md=[01;38;5;208m LESS_TERMCAP_me=[0m HISTCONTROL=ignoredups LESS_TERMCAP_mb=[01;31m AWS_AUTO_SCALING_HOME=/opt/aws/apitools/as UPSTART_JOB=rc LESS_TERMCAP_se=[0m HISTSIZE=1000 HADOOP_ROOT_LOGGER=INFO,DRFA JAVA_HOME=/etc/alternatives/jre AWS_DEFAULT_REGION=us-east-1 AWS_ELB_HOME=/opt/aws/apitools/elb LESS_TERMCAP_us=[04;38;5;111m EC2_HOME=/opt/aws/apitools/ec2 TERM=linux XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt runlevel=3 LANG=en_US.UTF-8 AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon MAIL=/var/spool/mail/hadoop LESS_TERMCAP_ue=[0m LOGNAME=hadoop PWD=/ LANGSH_SOURCED=1 HADOOP_CLIENT_OPTS=-Djava.io.tmpdir=/mnt/var/lib/hadoop/steps/s-3UAS8JQ0KEOV3/tmp _=/etc/alternatives/jre/bin/java CONSOLETYPE=serial RUNLEVEL=3 LESSOPEN=||/usr/bin/lesspipe.sh %s previous=N UPSTART_EVENTS=runlevel AWS_PATH=/opt/aws USER=hadoop UPSTART_INSTANCE= PREVLEVEL=N HADOOP_LOGFILE=syslog HOSTNAME=ip-10-17-186-102 NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat HADOOP_LOG_DIR=/mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3 EC2_AMITOOL_HOME=/opt/aws/amitools/ec2 SHLVL=5 HOME=/home/hadoop HADOOP_IDENT_STRING=hadoop INFO redirectOutput to /mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3/stdout INFO redirectError to /mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3/stderr INFO Working dir /mnt/var/lib/hadoop/steps/s-3UAS8JQ0KEOV3 INFO ProcessRunner started child process 24549 : hadoop 24549 4780 0 21:03 ? 00:00:00 bash /usr/lib/hadoop/bin/hadoop jar /var/lib/aws/emr/step-runner/hadoop-jars/command-runner.jar spark-submit --deploy-mode cluster --class TestRunner s3://jars/TestRunner-assembly-0.0.1-SNAPSHOT.jar 2016-10-20T21:03:21.050Z INFO HadoopJarStepRunner.Runner: startRun() called for s-3UAS8JQ0KEOV3 Child Pid: 24549 INFO Synchronously wait child process to complete : hadoop jar /var/lib/aws/emr/step-runner/hadoop-... INFO waitProcessCompletion ended with exit code 0 : hadoop jar /var/lib/aws/emr/step-runner/hadoop-... INFO total process run time: 44 seconds 2016-10-20T21:04:03.102Z INFO Step created jobs: 2016-10-20T21:04:03.103Z INFO Step succeeded with exitCode 0 and took 44 seconds </code></pre> <p>The <code>syslog</code> and <code>stdout</code> is empty and this is in my <code>stderr</code>:</p> <pre><code>16/10/20 21:03:20 INFO RMProxy: Connecting to ResourceManager at ip-10-17-186-102.ec2.internal/10.17.186.102:8032 16/10/20 21:03:21 INFO Client: Requesting a new application from cluster with 2 NodeManagers 16/10/20 21:03:21 INFO Client: Verifying our application has not requested more than the maximum memory capability of the cluster (53248 MB per container) 16/10/20 21:03:21 INFO Client: Will allocate AM container, with 53247 MB memory including 4840 MB overhead 16/10/20 21:03:21 INFO Client: Setting up container launch context for our AM 16/10/20 21:03:21 INFO Client: Setting up the launch environment for our AM container 16/10/20 21:03:21 INFO Client: Preparing resources for our AM container 16/10/20 21:03:21 WARN Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME. 16/10/20 21:03:22 INFO Client: Uploading resource file:/mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4/__spark_libs__5484581201997889110.zip -&gt; hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/__spark_libs__5484581201997889110.zip 16/10/20 21:03:24 INFO Client: Uploading resource s3://jars/HelloWorld-assembly-0.0.1-SNAPSHOT.jar -&gt; hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/DataScience-assembly-0.0.1-SNAPSHOT.jar 16/10/20 21:03:24 INFO S3NativeFileSystem: Opening 's3://jars/HelloWorld-assembly-0.0.1-SNAPSHOT.jar' for reading 16/10/20 21:03:26 INFO Client: Uploading resource file:/mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4/__spark_conf__5724047842379101980.zip -&gt; hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/__spark_conf__.zip 16/10/20 21:03:26 INFO SecurityManager: Changing view acls to: hadoop 16/10/20 21:03:26 INFO SecurityManager: Changing modify acls to: hadoop 16/10/20 21:03:26 INFO SecurityManager: Changing view acls groups to: 16/10/20 21:03:26 INFO SecurityManager: Changing modify acls groups to: 16/10/20 21:03:26 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(hadoop); groups with view permissions: Set(); users with modify permissions: Set(hadoop); groups with modify permissions: Set() 16/10/20 21:03:26 INFO Client: Submitting application application_1476995377469_0002 to ResourceManager 16/10/20 21:03:26 INFO YarnClientImpl: Submitted application application_1476995377469_0002 16/10/20 21:03:27 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED) 16/10/20 21:03:27 INFO Client: client token: N/A diagnostics: N/A ApplicationMaster host: N/A ApplicationMaster RPC port: -1 queue: default start time: 1476997406896 final status: UNDEFINED tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/ user: hadoop 16/10/20 21:03:28 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED) 16/10/20 21:03:29 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED) 16/10/20 21:03:30 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED) 16/10/20 21:03:31 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:31 INFO Client: client token: N/A diagnostics: N/A ApplicationMaster host: 10.17.181.184 ApplicationMaster RPC port: 0 queue: default start time: 1476997406896 final status: UNDEFINED tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/ user: hadoop 16/10/20 21:03:32 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:33 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:34 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:35 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:36 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:37 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:38 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:39 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:40 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:41 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:42 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:43 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:44 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:45 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:46 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:47 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:48 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:49 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:50 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:51 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:52 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:53 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:54 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:55 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:56 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:57 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:58 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:03:59 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING) 16/10/20 21:04:00 INFO Client: Application report for application_1476995377469_0002 (state: FINISHED) 16/10/20 21:04:00 INFO Client: client token: N/A diagnostics: N/A ApplicationMaster host: 10.17.181.184 ApplicationMaster RPC port: 0 queue: default start time: 1476997406896 final status: SUCCEEDED tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/ user: hadoop 16/10/20 21:04:00 INFO Client: Deleting staging directory hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002 16/10/20 21:04:00 INFO ShutdownHookManager: Shutdown hook called 16/10/20 21:04:00 INFO ShutdownHookManager: Deleting directory /mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4 Command exiting with ret '0' </code></pre> <p>What am I missing?</p>
<scala><amazon-web-services><apache-spark><emr><amazon-emr>
2016-10-20 21:36:37
HQ
40,165,092
Improve design movement on Snake game
<p>I am trying to improve my game development design and for now I have something like this:</p> <pre><code>class Movement { private: Body b; public: move_up() { // catch the body head // add one snake character above head // catch the body tail // remove the tail character } move_down(){ // catch the body head // add one snake character below head // catch the body tail // remove the tail character } move_left(){ // catch the body head // add one snake character on left side of head // catch the body tail // remove the tail character } move_right(){ // catch the body head // add one snake character on right side of head // catch the body tail // remove the tail character } } </code></pre> <p>It is pretty ugly to see repetead pseudocode inside each move method. I would like to make this more generic but I don't know how to do it in C++. Any suggestions?</p>
<c++>
2016-10-20 21:46:32
LQ_CLOSE
40,165,189
swap() function for variables's values
<p>I am not able to achieve the desired result for this swap function below, where I want the values printed as 3,2 </p> <pre><code>function swap(x,y){ var t = x; x = y; y = t; } console.log(swap(2,3)); </code></pre> <p>Any clue will be appreciated !</p>
<javascript><function><variables><swap>
2016-10-20 21:56:03
LQ_CLOSE
40,165,406
File upload, change name
<p>I have a file upload script which works fine, however it currently saves the document under the original file name, I want to rename this on upload, ideally adding an ID number before it (from GET variable, below)</p> <pre><code>$employee=$_GET["id"]; </code></pre> <p>The file upload script, where the name comes from is below:</p> <pre><code>$file_name = $key.$_FILES['files']['name'][$key]; </code></pre> <p>How can I add the ID number before the name upon saving?</p>
<php><file>
2016-10-20 22:16:59
LQ_CLOSE
40,165,665
Flask-RESTful vs Flask-RESTplus
<p>Other than the ability to automatically generate an interactive documentation for our API using Swagger UI, are there any real advantages of using <a href="http://flask-restplus.readthedocs.io/en/stable/">Flask-RESTplus</a> over <a href="http://flask-restful.readthedocs.io/en/0.3.5/">Flask-RESTful</a>?</p>
<flask><flask-restful><flask-restplus>
2016-10-20 22:41:45
HQ
40,165,766
Returning Promises from Vuex actions
<p>I recently started migrating things from jQ to a more structured framework being VueJS, and I love it!</p> <p>Conceptually, Vuex has been a bit of a paradigm shift for me, but I'm confident I know what its all about now, and totally get it! But there exist a few little grey areas, mostly from an implementation standpoint.</p> <p>This one I feel is good by design, but don't know if it contradicts the Vuex <a href="http://vuex.vuejs.org/en/images/vuex.png" rel="noreferrer">cycle</a> of uni-directional data flow.</p> <p>Basically, is it considered good practice to return a promise(-like) object from an action? I treat these as async wrappers, with states of failure and the like, so seems like a good fit to return a promise. Contrarily mutators just change things, and are the pure structures within a store/module.</p>
<promise><vue.js><es6-promise><state-management><vuex>
2016-10-20 22:51:53
HQ
40,166,303
Sql server What happens in delete with index
I have a heap table of 36 mill,am trying to delete selected 6 mill.. When i delete in 100 of batches reads is 16++++++ and write is 113 so i add NON-clus index on Identity column to make read faster, now read is 34899 and write is 3508 with adding one NON-clus Idx it increase the write IO shoot up. So what to know why this much difference what does sql server does in behind as in plan i see table delete is 8% and no more details. just to add more before doing this I drop 2 Nvarchar column, and clean the table and rebuild it
<sql><sql-server><sql-server-2012><sql-server-2014>
2016-10-20 23:53:35
LQ_EDIT
40,166,397
How to find the length of a path between two nodes in a tree?
<p>I want to calculate the path between two arbitrary nodes in a tree (implemented in Java). Are there in literature any solutions?</p>
<java><tree>
2016-10-21 00:05:38
LQ_CLOSE
40,167,038
Using Realm in React Native app with Redux
<p>I am about to undertake the development of a React Native app and am thoroughly convinced of the benefits of managing the app's state using Redux, however I'd like to make the app's data available whilst offline by using Realm for persistent storage. What I'm wondering is how Redux will play with Realm?</p> <p>The app I'm developing will pull a large amount of JSON data via a RESTful API and then I'd like to persist this data to local storage - Realm seems to be an excellent option for this. What I'm unsure of however is how the Realm database will exist within the Redux store? Will it have to exist external to the store? Is using Realm within a Redux based app somehow a contradiction?</p> <p>I've had a good search for articles describing the use of Realm, or other storage options (Asyncstorage or SQLite) for large datasets with Redux and could find little information.</p>
<sqlite><react-native><redux><realm><asyncstorage>
2016-10-21 01:38:19
HQ
40,167,279
How to add the numbers 1-12 which = 78 using a loop?
class Program { static void Main(string[] args) { int sum = 1; while (sum < 12) { sum = sum + 1; } Console.WriteLine(sum); Console.ReadLine(); } } } I am new to C# and I have to add the numbers all together. I know adding them up will equal 78 but still don't know how to do it. Any help would be great Thanks!
<c#>
2016-10-21 02:10:18
LQ_EDIT
40,167,287
react Material-ui, How do I know I can use onClick for button?
<p>The list of properties on the doc doesn't include <code>onClick</code> (<a href="http://www.material-ui.com/#/components/icon-button" rel="noreferrer">http://www.material-ui.com/#/components/icon-button</a>)</p> <p>How do I know I need to use onClick for click handler?</p>
<reactjs><material-ui>
2016-10-21 02:11:59
HQ
40,167,670
Does _finddata_t structure returns the local time in UTC timestamp?
I am referring the documentation of `_filefirst()` and `_findnext()` APIs [here][1] These APIs return file information in a _finddata_t structure. I need to access file modification time from `time_write` element. Though documentation says that time is stored in UTC format (It is a times stamp). Documentation doesn't clarify if this time represents local time or UTC time. It seems to me that `time_write` doesn't return the UTC timestamp instead its value is influenced by the system time zone settings. My Question is - Does `time_write` returns local time represented in the UTC timestamps ? [1]: https://msdn.microsoft.com/en-us/library/kda16keh.aspx
<c++><windows><datetime><winapi>
2016-10-21 03:00:25
LQ_EDIT
40,167,875
I am trying to find a function or expression which finds reads the resulting value and if it is a whole number. then ends program
<p>this is my program I hope you understand what I am trying to do. </p> <pre class="lang-js prettyprint-override"><code> if (primeNum = int) { Console.WriteLine(" the number entered is not prime "); } </code></pre>
<c#><function><math>
2016-10-21 03:25:52
LQ_CLOSE
40,168,248
'router-outlet' is not a known element in angular2
<p>I've just created a new angular project using the Angular CLI and scaffolded a new route and I am getting error as :</p> <p>'router-outlet' is not a known element</p> <p>Can anyone help me ?</p>
<angular>
2016-10-21 04:09:20
HQ
40,168,283
Why does the default shell in OS X 10 look differently than that in Linux (Mint, Lubuntu...)?
<p>To clarify, when entering the default shell in OS X it appears as:</p> <p><strong>pcname:~ username$</strong></p> <p>and changing directories appears as:</p> <p><strong>pcname:myFolder~ username$</strong></p> <hr> <p>however, in my experience with linux distros, the shell appears as:</p> <p><strong>username@pcname:~$</strong></p> <p>what is the purpose for the differences in syntax?</p>
<linux><bash><macos><shell><terminal>
2016-10-21 04:11:44
LQ_CLOSE
40,168,310
Create a sql sequence programmatically in Java
<p>I need to create a sql sequence in sql server programmatically from Java and I should be able to retrieve the continuous value from the sequence to program. First of all can I do so? If so how?</p>
<java><sql><jdbc>
2016-10-21 04:13:58
LQ_CLOSE
40,169,051
Attach an object to another object
<p>Where can i find the script on c# (unity3d) to attach an object to another object when you press the mouse button?</p> <p>I tried to use a lot of different scripts, but one does not work.</p>
<c#><unity3d>
2016-10-21 05:29:44
LQ_CLOSE
40,169,286
How to disable Firebase/Core debug messages in iOS
<p>I get several debug messages from Firebase - quite chatty:</p> <pre><code>2016-10-20 22:18:33.576 Sitch[1190] &lt;Debug&gt; [Firebase/Core][I-COR000019] Clearcut post completed </code></pre> <p>I don't see any way to quiet them. FIRAnalytics only shows INFO and more severe but Firebase/Core seems to have debug enabled by default?</p> <p>This is the cocoapods build - from podfile.lock:</p> <pre><code>FirebaseCore (3.4.3): GoogleInterchangeUtilities (~&gt; 1.2) GoogleUtilities (~&gt; 1.2) </code></pre>
<ios><logging><firebase>
2016-10-21 05:51:06
HQ
40,169,653
Convert DataFrame into dict
<p><a href="https://i.stack.imgur.com/kErXL.png" rel="nofollow">I use pandas to read df.csv, so I have a Dataframe Like this, </a></p> <p><a href="https://i.stack.imgur.com/DlogA.png" rel="nofollow">I want to convert it to dict like this</a></p>
<python><csv><pandas><dictionary>
2016-10-21 06:21:47
LQ_CLOSE
40,169,710
Should I master maven or start learning gradle
<p>The project I'm working on uses Maven as a build tool. I know the basic concepts like profiles, pom inheritance, modules, plugins, goals, phases and so on the surface, but I'm still missing the true craftsmanship to implement complicated builds from a starch for different environments.</p> <p>Now, should I become Maven expert or start learning Gradle instead of unveiling all technical nuances of Maven? </p> <p>I don't see what value Gradle brings on the table. It is configured programmatically, but could this actually be evil? I have worked in Javascript world and used tools like Gulp and Webpack. The programmatic configuration in those tools was just a horrible mess and lacked consistency. It wasn't possible to form a clear mental picture of the configuration, as it was dynamic code, not a static document. When you had to make a change, it wasn't so obvious where to find that line of code handling that functionality. Well defined XML document is self describing, organized and easily grepable.</p> <p>Also, by programmatic configuration, there is a higher change to introduce bug in the build itself. Will there be a time, when builds become so complex that it's necessary to build the build configuration of the project?</p> <p>Considering these aspects, is there some pragmatic reason start using Gradle (other than following the trend)? </p>
<java><maven><gradle><build>
2016-10-21 06:24:56
LQ_CLOSE
40,169,795
How To Put Values Dynamicly
Hi All I am Trying To Add Comments At Below Post As Like (Posted By : Some Name From My Text Box)And In Next Line (Comment: )Again In Next Line Print That Textarea's Value Below Of That Post So Please My Trying Code Is Here Please Let me Know Any Mistakes in My Code . Please Help Me Anybody Expert In This Type Of Functionality . Thanks In Advanced . <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var cnt; var name; $(document).ready(function(){ $('#comment').click(function(){ $('#form1').html("<div class=\"form-group\" ><input type=\"text\" class=\"form-control\" placeholder=\"Please Enter Your Name Or Email\" id=\"namefield\"/> <textarea class=\"form-control\" placeholder=\"Leave A Comment Here\" style=\"width:100%; height:150px;\" id=\"coment-txt\" required></textarea></div><button class=\"btn btn-success\" id=\"post\">Post</button>"); $('#post').click(function(){ cnt = $('#coment-txt').val(); name = $('#namefield').val(); alert('Posted by '+name+'\n'+' Comment : '+'\n'+cnt); }); }); $('#newcoment').html('Posted by '+name+'\n'+' Comment : '+'\n'+cnt); }); <!-- language: lang-css --> /* Set height of the grid so .sidenav can be 100% (adjust if needed) */ .row.content {height: 1500px} /* Set gray background color and 100% height */ .sidenav { background-color: #f1f1f1; height: 100%; } /* Set black background color, white text and some padding */ footer { background-color: #555; color: white; padding: 15px; } .text-justify{ text-align:justify; } .cursor{cursor:pointer;} /* On small screens, set height to 'auto' for sidenav and grid */ @media screen and (max-width: 767px) { .sidenav { height: auto; padding: 15px; } .row.content {height: auto;} } <!-- language: lang-html --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <div class="container-fluid"> <div class="row content"> <div class="col-sm-3 sidenav"> <h4>Samudrala's Blog</h4> <ul class="nav nav-pills nav-stacked"> <li class="active"><a href="#section1">Home</a></li> <li><a href="#section2">Friends</a></li> <li><a href="#section3">Family</a></li> <li><a href="#section3">Photos</a></li> <li><a href="#section3">Likes</a></li> <li><a href="#section3">DisLikes</a></li> </ul><br> <div class="input-group"> <input type="text" class="form-control" placeholder="Search Blog.."> <span class="input-group-btn"> <button class="btn btn-default" type="button"> <span class="glyphicon glyphicon-search"></span> </button> </span> </div> </div> <div class="col-sm-9 sidenav" style="background:#337ab7; color:#fff;"> <h4>RECENT POSTS</h4> <hr> <h2>I Like Updated Technologies</h2> <h5><span class="glyphicon glyphicon-time"></span> Post by Samudrala, Oct 21, 2016.</h5> <h5><span class="label label-danger">Updated Technologies</span> <span class="label label-primary">Samudrala</span></h5><br> <p class="text-justify">Nowadays technology has brought a lot of changes to our life, especially in education and communication. In communication, the major changes happen in the way we communicate with other people. We do not need to meet them in person or face to face to say what is in our mind. We simply can phone them or do video chat using Internet connection. In the past, we spent a long time to travel to a distant place, but now we just need hours or even minutes to go there using the latest technology in a form of transportation means. In education, the changes have brought advantages to students and teachers. For instance, students can do their homework or assignment faster because using Internet. The teachers also get some advantages from it. They can combine their teaching skill with it and produce some interesting materials to teach like colorful slides to deliver the lesson and animation to show how things happen. In conclusion, technology itself has given us advantages to improve our life's quality. </p> <p id="newcoment"></p> <br><br> <h4>Leave a Comment : <span class="label label-success cursor" id="comment">Comments</span></h4> <br/> <form role="form" id="form1"> </form> </div> </div> </div> <footer class="container-fluid"> <p>Footer Text</p> </footer> <!-- end snippet -->
<javascript><jquery><html><twitter-bootstrap><css>
2016-10-21 06:30:30
LQ_EDIT
40,170,149
Javascript code displaying error on for loop
What's the problem in this javascript code,there is a constant red line under the for loop, The code does work in a Java class but not in javascript: <%! EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("Dima_TestPU"); RegionJpaController djc = new RegionJpaController(emf); List<Region> lstRegion = djc.findRegionEntities(); for( Region device : lstRegion ) { System.out.println(device.getId()); System.out.println(device.getName()); System.out.println(device.getLatitude()); } %>
<java>
2016-10-21 06:53:24
LQ_EDIT
40,170,567
What do the TargetFramework settings mean in web.config in ASP .NET MVC?
<p>One of our ASP.NET MVC 5 web applications has the following web.config settings:</p> <pre><code>&lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.6" /&gt; &lt;httpRuntime targetFramework="4.5" /&gt; &lt;!--... many other things --&gt; &lt;/system.web&gt; </code></pre> <p>It is not clear why are two targetFramework settings, and it seems to be wrong to compile targeting 4.6 then trying to run under 4.5...</p> <p>Obviously I am missing something, but what?</p>
<asp.net><asp.net-mvc>
2016-10-21 07:16:32
HQ