Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
39,397,548
How to give non-root user in Docker container access to a volume mounted on the host
<p>I am running my application in a Docker container as a non-root user. I did this since it is one of the best practices. However, while running the container I mount a host volume to it <code>-v /some/folder:/some/folder</code> . I am doing this because my application running inside the docker container needs to write files to the mounted host folder. But since I am running my application as a non-root user, it doesn't have permission to write to that folder</p> <p><strong>Question</strong></p> <p>Is it possible to give a nonroot user in a docker container access to the hosted volume?</p> <p>If not, is my only option to run the process in docker container as root?</p>
<security><docker>
2016-09-08 18:08:18
HQ
39,397,944
javascript: a = b. Is it possible to change a but not influence b?
<p>Javascript Question. I am pretty new to javascript so pardon me if anything is not clear.</p> <p>Please play following example at (right click) "inspect --> Console".</p> <p>Example: </p> <pre><code>o = [1,2,3]; y = o; delete y[0]; y;// result: [undefined × 1, 2, 3] o;// result: [undefined × 1, 2, 3] </code></pre> <p>Is it possible that the delete of <code>y</code> does not affect <code>o</code>? Here I made <code>y</code> equal to <code>o</code>. I just wanted to delete the first item of <code>y</code> but not <code>o</code>. However, <code>o</code> changes with <code>y</code> together. I wonder if it is possible to prevent <code>o</code> being changed even I change <code>y</code>?</p>
<javascript>
2016-09-08 18:32:55
LQ_CLOSE
39,398,021
IntelliJ Idea Slack user channel
<p>Is there a Slack user group / community dedicated to everything IntelliJ Idea such as keyboard shortcuts, plugins, support inquires, feature discussions, etc and if so what is its URL? Thanks.</p>
<intellij-idea><slack>
2016-09-08 18:37:54
HQ
39,398,031
Django BooleanField as a dropdown
<p>Is there a way to make a Django BooleanField a drop down in a form?</p> <p>Right now it renders as a radio button. Is it possible to have a dropdown with options: 'Yes', 'No' ?</p> <p>Currently my form definition for this field is:</p> <pre><code>attending = forms.BooleanField(required=True) </code></pre>
<python><django>
2016-09-08 18:38:18
HQ
39,398,173
Best practices for draining or clearing a Google Cloud pubsub topic
<p>For pubsub topics with number of messages in the range of ~100k, what is the best practice for draining/dropping/clearing/deleting all messages using gcloud-java SDK? </p> <p>Possible solutions:</p> <ul> <li><p>Deleting and recreating the subscribers and then the publishers</p></li> <li><p>High concurrency pull+ack (easy to hit the quota this way) </p></li> <li>Something else</li> </ul> <p>My hope is that this process can be fast (not more than ~60 seconds, say), robust, and uses supported SDK methods with minimal other code.</p>
<google-cloud-pubsub>
2016-09-08 18:47:27
HQ
39,399,553
How do I disable the Show Tab Bar menu option in Sierra apps?
<p>I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called <code>Show Tab Bar</code>. How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons.</p>
<nswindow><nsmenu><macos-sierra>
2016-09-08 20:21:21
HQ
39,399,563
MySQL Workbench 6.3 (Mac) hangs on simple queries
<p>I am using MySQL Workbench 6.3.7 build 1199 CE (64 bits) on a Mac with OS X Yosemite 10.10.5. I am connecting to an Amazon RDS MySQL instance.</p> <p>When I enter a simple query such as</p> <pre><code>select * from `devices`; </code></pre> <p>and click the lightning-bolt-with-cursor icon, the query starts, indicated by the spinner activating next to the "SQL File 4" tab in the following screenshot. However, the query doesn't complete and it just hangs. The white-hand-in-red-stop-sign icon is disabled.</p> <p><a href="https://i.stack.imgur.com/rtr7a.png"><img src="https://i.stack.imgur.com/rtr7a.png" alt="screenshot of MySQL Workbench in hung state"></a></p> <p>I can only force quit MySQL Workbench from this point on. If I try to do a regular quit, nothing happens.</p> <p>How can I consistently run a simple query on my database? Sometimes it works (maybe 10% of the time), but it mostly just hangs.</p>
<mysql-workbench>
2016-09-08 20:22:01
HQ
39,400,074
iTextsharp PDF Generation
I am using iTextSharp to create PDF in a .NET application. I do not need to save/write the PDF to a server for storage. Just create a file to the users local machine. Posted controller below. Not sure where I am going wrong. [HttpPost] public FileResult DailyReport(string path ="") { path = !String.IsNullOrWhiteSpace(path) ? path : String.Format("~/downloads/daily-report.pdf"); var report = new Document(PageSize.LETTER, 10, 10, 10, 10); PdfWriter.GetInstance(report, new FileStream(MapPath(path), FileMode.OpenOrCreate)); report.Open(); var table = new Table(2, 1) { Width = 100, Border = 0, Cellpadding = 2 }; table.AddCell( new Cell(new Paragraph("Daily Schedule", new Font(Font.TIMES_ROMAN, 18, Font.BOLD))) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Colspan = 2 }); table.AddCell(new Cell { Colspan = 2, Border = 0, Leading = 2 }); report.Add(table); report.Close(); return path; } public static string MapPath(string path) { return (path.StartsWith("~") ? System.Web.HttpContext.Current.Server.MapPath(path) : path); }
<c#><asp.net-mvc><itext>
2016-09-08 20:56:57
LQ_EDIT
39,400,370
How to launch Chrome Advanced REST Client
<p>There's <a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US" rel="noreferrer">this great REST client "extension" for Chrome</a>, but the only way I can find to launch it is to go to the Chrome webstore!</p> <p>It's listed as Enabled in my Chrome extensions. Is there any local way to launch it?</p> <p><a href="https://i.stack.imgur.com/dUjGs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dUjGs.png" alt="Advanced REST client Chrome extenstion"></a></p>
<google-chrome-extension>
2016-09-08 21:18:46
HQ
39,400,886
Docker cannot resolve DNS on private network
<p>My machine is on a private network with private DNS servers, and a private zone for DNS resolution. I can resolve hosts on this zone from my host machine, but I cannot resolve them from containers running on my host machine. </p> <p><strong>Host</strong>:</p> <pre><code>root@host:~# cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 root@host:~# ping privatedomain.io PING privatedomain.io (192.168.0.101) 56(84) bytes of data. </code></pre> <p><strong>Container</strong>:</p> <pre><code>root@container:~# cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4 root@container:~# ping privatedomain.io ping: unknown host privatedomain.io </code></pre> <p>It's fairly obvious that Google's public DNS servers won't resolve my private DNS requests. I know I can force it with <code>docker --dns 192.168.0.1</code>, or set <code>DOCKER_OPTS="--dns 192.168.0.1"</code> in <code>/etc/default/docker</code>, but my laptop frequently switches networks. It seems like there should be a systematic way of solving this problem. </p>
<docker><dns><dnsmasq>
2016-09-08 22:05:15
HQ
39,400,997
Angular 2 New Router: Change / Set Query Params
<p>I have a component registered at <code>/contacts</code>, which displays a list of contacts. I've added an <code>&lt;input [value]="searchString"&gt;</code> for filtering the displayed list.</p> <hr> <p>Now I'd like to display the <code>searchString</code> within the URL in form of a Query Param. (Using the New Router 3.0.0 RC2)</p> <p>The official docs ( <a href="https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters" rel="noreferrer">https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters</a> ) show how to use <code>router.navigate</code> for changing the <code>queryParams</code>. But this seems awkward, because I just want to change the <code>queryParams</code> without having to know which route I'm currently at: <code>router.navigate(['/contacts'], {queryParams:{foo:42}})</code></p> <p>(I know that it doesn't reload the component if I'm just changing the <code>queryParams</code>, but still this doesn't feel right to write)</p> <hr> <p>After some attempts I figured out that <code>router.navigate([], {queryParams:{foo:42}})</code> works. This feels way better.</p> <p>But I'm still not sure if that's the right way. Or if I missed some method for this.</p> <hr> <p>How do you change your <code>queryParams</code>?</p>
<angular><angular2-routing>
2016-09-08 22:16:05
HQ
39,401,003
Why there are two buttons in GUI Configure and Generate when CLI does all in one command
<p>I understand that cmake is build generator. It mean that it can generate appropriate builds (makefiles, Visual Studio project etc.) based on instructions from CMakeLists.txt. But I do not understand two things which I guess are related:</p> <ol> <li><p>Why there are two buttons "Configure" and "Generate" in cmake-gui? In command line tutorials that I've read (e.g. <a href="http://derekmolloy.ie/hello-world-introductions-to-cmake/" rel="noreferrer">this one</a>) usual process was done with one <code>cmake</code> command.</p></li> <li><p>What is cache in cmake world? AFAIK it is state when "Configure" button was pressed but "Generate" button was not pressed. But why is this useful? What all those variables that pops-up after pressing "Configure" mean? Why I'm supposed to edit them? Isn't the only allowed configuration done via CMakeLists.txt?</p></li> </ol> <p>Thanks</p>
<cmake><cmake-gui>
2016-09-08 22:16:33
HQ
39,401,098
Creating Stored Proc getting Incorrect syntax near the keyword 'Declare'
I have no idea why I am getting this error > Msg 156, Level 15, State 1, Procedure usp_cloud_ClientAllSearch, Line 2 Incorrect syntax near the keyword 'Declare'. Because I have declared the variable. USE [The_Cloud] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create PROCEDURE [dbo].[usp_cloud_ClientAllSearch] Declare @Search NVARCHAR(30) SELECT client_Name, client_Surname, client_CompanyName, clientContact_TelephoneNo, clientContact_MobileNo, clientAddress_PostalCode FROM cloud_Client Inner Join dbo.cloud_ClientAddresses ON cloud_Client.client_ID = cloud_ClientAddresses.client_ID LEFT JOIN cloud_ClientContact ON cloud_Client.client_ID = cloud_ClientContact.client_ID WHERE cloud_Client.client_Name LIKE @Search + '%' or cloud_Client.client_Surname LIKE @Search + '%' or cloud_ClientContact.clientContact_MobileNo LIKE @Search + '%' or cloud_ClientAddresses.clientAddress_PostalCode LIKE @Search + '%'
<sql><sql-server>
2016-09-08 22:26:49
LQ_EDIT
39,401,504
javascript/react dynamic height textarea (stop at a max)
<p>What I'm trying to achieve is a textarea that starts out as a single line but will grow up to 4 lines and at that point start to scroll if the user continues to type. I have a partial solution kinda working, it grows and then stops when it hits the max, but if you delete text it doesn't shrink like I want it to.</p> <p>This is what I have so far.</p> <pre><code>export class foo extends React.Component { constructor(props) { super(props); this.state = { textareaHeight: 38 }; } handleKeyUp(evt) { // Max: 75px Min: 38px let newHeight = Math.max(Math.min(evt.target.scrollHeight + 2, 75), 38); if (newHeight !== this.state.textareaHeight) { this.setState({ textareaHeight: newHeight }); } } render() { let textareaStyle = { height: this.state.textareaHeight }; return ( &lt;div&gt; &lt;textarea onKeyUp={this.handleKeyUp.bind(this)} style={textareaStyle}/&gt; &lt;/div&gt; ); } } </code></pre> <p>Obviously the problem is <code>scrollHeight</code> doesn't shrink back down when <code>height</code> is set to something larger. Any suggestion for how I might be able to fix this so it will also shrink back down if text is deleted? </p>
<javascript><html><css><reactjs>
2016-09-08 23:14:26
HQ
39,401,535
DOS command to copy only files and not folders in a folder tree
Let's assume the following folder structure, c:\tab\file1.txt c:\tab\insidetab1\file2.txt c:\tab\insidetab2\file3.txt c:\tab\insidetab3\insidetab4\file4.txt I want to copy only files file1.txt,file2.txt,file3.txt,file4.txt to some destination. Basically i want to remove all folders and keep only files is my requirment. Is it even possible ?
<batch-file><cmd>
2016-09-08 23:18:49
LQ_EDIT
39,402,011
Proper usage of AsyncTask?
<p>I'm trying to use AsyncTask in the main class of the app as exercise. I included the basic code that i'm trying to understand.The error is the <code>DownloadFilesTask must be declared abstract or implement abstract method doInBackground</code></p> <p>Java code;</p> <pre><code>import android.media.Image; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.os.AsyncTask; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { ImageView image = (ImageView)findViewById(R.id.BackGroundForAll); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } private class DownloadFilesTask extends AsyncTask&lt;Void, Void, Void&gt; { protected Long doInBackground(Void....Void) { } protected void onProgressUpdate(Integer... progress) { } protected void onPostExecute(Long result) { } } } </code></pre>
<java><android><android-studio><android-asynctask>
2016-09-09 00:22:17
LQ_CLOSE
39,403,387
R subset based on range of dates
<p>Say I have a data set with 3 columns, A, B and C, that contain dates for a large number of rows. How can I create a subset that omits the rows where the date in C is not within the range of the dates in A and B?</p>
<r><conditional-statements><subset>
2016-09-09 03:27:08
LQ_CLOSE
39,403,798
Haskell: Variable not in scope
<p>I have a code as:</p> <pre><code>main = interact $ show . maxsubseq . map read . words maxsubseq :: (Ord a,Num a) =&gt; [a] -&gt; (a,[a]) maxsubseq = snd . foldl f ((0,[]),(0,[])) where f ((h1,h2),sofar) x = (a,b) where a = max (0,[]) (h1 + x ,h2 ++ [x]) b = max sofar a </code></pre> <p>But I am getting error:</p> <pre><code>maxSub.hs:6:17: error: Variable not in scope: h1 maxSub.hs:6:22: error: Variable not in scope: x maxSub.hs:6:25: error: Variable not in scope: h2 :: [t1] maxSub.hs:6:32: error: Variable not in scope: x maxSub.hs:7:9: error: Variable not in scope: sofar :: (t, [t1]) </code></pre> <p>Not able to figure out why??</p> <p>Any ideas??</p> <p>Thanks.</p>
<haskell>
2016-09-09 04:17:58
HQ
39,404,086
Simple Java programm runs slow on Windows 2008 Server
<p>Why is my simple Java programm runs quickly on my local computer and too slow on Windows 2008 Server?</p> <p>Programm code:</p> <pre><code>public static void main(String[] args) { long startTime; long endTime; long totalTime; startTime = System.currentTimeMillis(); for (int a=1; a &lt; 100000; a++) { System.out.println("Checking"); } endTime = System.currentTimeMillis(); totalTime = endTime - startTime; System.out.println("TEST1 time:"+totalTime); startTime = System.currentTimeMillis(); double sum = 0; for (int a=1; a &lt; 1000000; a++) { int input = 100; for(int counter=1;counter&lt;input;counter++){ sum += Math.pow(-1,counter + 1)/((2*counter) - 1); } } endTime = System.currentTimeMillis(); totalTime = endTime - startTime; System.out.println("TEST2 time:"+totalTime+" pi="+sum); } </code></pre> <p>Local computer output:</p> <pre><code>Checking Checking Checking Checking TEST1 time:427 TEST2 time:7261 pi=787922.5634628027 </code></pre> <p>Windows server output:</p> <pre><code>Checking Checking Checking Checking Checking Checking TEST1 time:15688 TEST2 time:25280 pi=787922.5634628027 </code></pre> <p>Local computer hardware and soft: Intel Core (TM) i7-2600 CPU @ 3.40GHz Windows 7 Professional 8G RAM</p> <p>Server hardware and soft:</p> <p>Intel Xeon(R) CPU E5-2603 @ 1.60GHz 8G RAM Windows Server 2008 Standart Version 6.0</p> <p>Both computer and server are free from another processes.</p> <p>May be I have to apply some parametrs to java vm? </p>
<java><jvm><windows-server-2008-r2>
2016-09-09 04:55:06
LQ_CLOSE
39,404,474
How to remove the similar text from one column by comparing with other column in SQL Server
<p>I have the following example</p> <pre><code>addressid 23915031 customerid 13154569 address1 FLAT NO 23 3Road Floor KRISH BUILDING ANUSHKTI address2 GAR BARC COLONY Near SECTOR MARKET address3 MANKHURoad MUMBAI landmark ANUOHAKTING zipcode 400094 addresstype RESIDENCE ADDRESS cityname MUMBAI statedesc MAHARASHTRA </code></pre> <p>In the above example I want to remove Mumbai from address3 field by comapring with cityname field. How to perform this in SQL server. Please help! </p>
<sql><sql-server>
2016-09-09 05:34:04
LQ_CLOSE
39,404,715
How to return a value from JSON function?
I have a JSON object with a few functions. I am not able to retrieve the returned value when I access the utils.run function, Please help. var utils = { "init" : function(){ console.log("init"); }, "run" : function(value1){ return "hello"+value1; } }
<javascript><function>
2016-09-09 05:55:08
LQ_EDIT
39,406,546
How to move jenkins job to sub folder?
<p>I have 10 jenkins job in folder <code>foo</code>. I have created a new sub folder <code>baar</code> in folder <code>foo</code>. How to move the 10 jobs from folder <code>foo</code> to the subfolder <code>baar</code>?</p>
<jenkins>
2016-09-09 07:54:00
HQ
39,408,668
System.NullReferenceException: Object reference not set to an instance of an object..
<p>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <blockquote> <p>System.NullReferenceException: Object reference not set to an instance of an object.</p> </blockquote> <pre><code> contentpath = Server.MapPath("Message/" + rnd.Next() + contentfile.FileName); contentfile.PostedFile.SaveAs(contentpath); message = TextBox1.Text; </code></pre>
<c#><.net><nullreferenceexception>
2016-09-09 09:48:31
LQ_CLOSE
39,408,816
Linux- how to find a file with a certain string in its name?
<p>If I want to find all files with the string "test" in their name, how do I do so? </p>
<linux><string><file>
2016-09-09 09:54:56
LQ_CLOSE
39,409,328
Storing injector instance for use in components
<p>Before RC5 I was using appref injector as a service locator like this:</p> <p>Startup.ts</p> <pre><code>bootstrap(...) .then((appRef: any) =&gt; { ServiceLocator.injector = appRef.injector; }); </code></pre> <p>ServiceLocator.ts</p> <pre><code>export class ServiceLocator { static injector: Injector; } </code></pre> <p>components:</p> <pre><code>let myServiceInstance = &lt;MyService&gt;ServiceLocator.injector.get(MyService) </code></pre> <p>Now doing the same in bootstrapModule().then() doesn't work because components seems to start to execute before the promise. </p> <p>Is there a way to store the injector instance before components load?</p> <p>I don't want to use constructor injection because I'm using the injector in a base component which derived by many components and I rather not inject the injector to all of them.</p>
<angular>
2016-09-09 10:21:06
HQ
39,410,183
Hibernate 5.2.2: No Persistence provider for EntityManager
<p>What has changed between Hibernate 5.1.1 and 5.2.2? If I use 5.2.2 I'll get an error message "No Persistence provider for EntityManager named pu". Exactly the same configuration works with 5.1.1. How should I change my code to get 5.2.2 to work?</p> <p>pom.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;jpatest&lt;/groupId&gt; &lt;artifactId&gt;jpatest&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;properties&gt; &lt;hibernate.version&gt;5.2.2.Final&lt;/hibernate.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;!-- https://mvnrepository.com/artifact/junit/junit --&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.12&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --&gt; &lt;dependency&gt; &lt;groupId&gt;org.postgresql&lt;/groupId&gt; &lt;artifactId&gt;postgresql&lt;/artifactId&gt; &lt;version&gt;9.4.1209.jre7&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt; &lt;version&gt;${hibernate.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt; &lt;version&gt;${hibernate.version}&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p>persistence.xml in src/main/resources/META-INF</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt; &lt;persistence-unit name="pu" &gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;properties&gt; &lt;property name="hibernate.archive.autodetection" value="class" /&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt; &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /&gt; &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mydb" /&gt; &lt;property name="hibernate.default_schema" value="myschema" /&gt; &lt;property name="hibernate.connection.username" value="xxx" /&gt; &lt;property name="hibernate.connection.password" value="zzz" /&gt; &lt;!-- &lt;property name="hibernate.show_sql" value="true"/&gt; --&gt; &lt;property name="hibernate.flushMode" value="FLUSH_AUTO" /&gt; &lt;property name="hibernate.hbm2ddl.auto" value="validate" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>creating EntityManager </p> <pre><code>factory = Persistence.createEntityManagerFactory("pu"); em = factory.createEntityManager(); tx = em.getTransaction(); </code></pre>
<java><hibernate>
2016-09-09 11:07:31
HQ
39,410,223
Horizontal layout of patches in legend (matplotlib)
<p>I create legend in my chart this way:</p> <pre><code>legend_handles.append(matplotlib.patches.Patch(color=color1, label='group1')) legend_handles.append(matplotlib.patches.Patch(color=color2, label='group2')) ax.legend(loc='upper center', handles=legend_handles, fontsize='small') </code></pre> <p>This results in the legend items stacked vertically (top-bottom), while I would like to put them horizontally left to right.</p> <p>How can I do that?</p> <p>(<code>matplotlib</code> v1.4.3)</p>
<python><matplotlib>
2016-09-09 11:10:25
HQ
39,410,277
dashcode error with java array se.mebe.Lion@7852e922, se.mebe.Zebra@4e25154f, se.mebe.Monkey@70dea4e
<p>public void addAnimalsToZoo() {</p> <pre><code> Animal[] zoo = new Animal[animals.length + 5]; System.arraycopy(animals, 0, zoo, 0, animals.length); for (count = 0; count &lt; zoo.length; count++) System.out.println("new animals with new array" + "\t" + zoo[count]); } </code></pre>
<java>
2016-09-09 11:12:41
LQ_CLOSE
39,410,446
How to loop the following inside a script, till they all deleted then continue? [Python] [Selenium] [Helium]
How to loop the following inside a script, till they all deleted then continue? e.g. if there are X, then deleted X and conitue ( X = dynamic ) and so on. if Text("Remove").exists(): click("Remove")
<python><selenium><helium>
2016-09-09 11:22:01
LQ_EDIT
39,410,942
Apple push notification curl: (16) Error in the HTTP2 framing layer
<p>i do run this command on ubuntu terminal</p> <blockquote> <p>curl --verbose -H 'apns-topic: Skios.TripBruCACT' --header "Content-Type: application/json" --data '{"aps":{"content-available":1,"alert":"hi","sound":"default"}}' --cert /home/mohamed/Downloads/Prod2.pem:a1B23 --http2 '<a href="https://api.push.apple.com/3/device/19297dba97212ac6fd16b9cd50f2d86629aed0e49576b2b52ed05086087da802" rel="noreferrer">https://api.push.apple.com/3/device/19297dba97212ac6fd16b9cd50f2d86629aed0e49576b2b52ed05086087da802</a>'</p> </blockquote> <p>but it return <strong>curl: (16) Error in the HTTP2 framing layer</strong></p> <p>Here are the whole result</p> <pre><code>* Trying 17.188.145.163... * Connected to api.push.apple.com (17.188.145.163) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Request CERT (13): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Certificate (11): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS handshake, CERT verify (15): * TLSv1.2 (OUT), TLS change cipher, Client hello (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Client hello (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=api.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US * start date: Aug 28 19:03:46 2015 GMT * expire date: Sep 26 19:03:46 2017 GMT * subjectAltName: host "api.push.apple.com" matched cert's "api.push.apple.com" * issuer: CN=Apple IST CA 2 - G1; OU=Certification Authority; O=Apple Inc.; C=US * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * TCP_NODELAY set * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0xdb69a0) &gt; POST /3/device/19297dba97212ac6fd16b9cd50f2d86629aed0e49576b2b52ed05086087da802 HTTP/1.1 &gt; Host: api.push.apple.com &gt; User-Agent: curl/7.50.0 &gt; Accept: */* &gt; apns-topic: Skios.TripBruCACT &gt; Content-Type: application/json &gt; Content-Length: 62 &gt; * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * We are completely uploaded and fine * Closing connection 0 * TLSv1.2 (OUT), TLS alert, Client hello (1): curl: (16) Error in the HTTP2 framing layer </code></pre> <p>but i got in last line this error</p> <blockquote> <p>curl: (16) Error in the HTTP2 framing layer</p> </blockquote>
<curl><push-notification><apple-push-notifications>
2016-09-09 11:50:28
HQ
39,412,407
git-stash changes without reverting
<p>I work on a project using Git. Every once in a while I find myself wanting to save my changes, without committing them, just as a backup, and then continue working. What I usually do is <code>git stash</code> and then immediately <code>git stash apply</code> to bring the code back to the same state as before stashing. The problem I have with this is that git stash reverts my work directory so even though I apply the stash immediately files and projects have to be rebuilt because they appear to have changed. This is quite annoying because some of our projects take ages to build.</p> <p>So my question is, is there a way to stash my changes without reverting? If stash doesn't do that, is there any other command in git that can do it? Thank you.</p>
<git><git-stash>
2016-09-09 13:12:48
HQ
39,412,424
How to see logs from npm installation?
<p>I am unable to install ionic through npm. Are there any logs that I can check to see what's wrong and if yes, where are they located?</p> <p>What I see is the waiting stick dancing forever. I've waited for an hour or so but nothing changes.</p>
<npm-install>
2016-09-09 13:13:52
HQ
39,413,123
How add my application content with description and preview to Google search results?
<p>I found this article: <a href="https://search.googleblog.com/2016/08/a-new-way-to-search-for-content-in-your.html" rel="nofollow noreferrer">A new way to search for content in your apps</a> and I'm really excited for this opportunity. I want to show my application content in google search results, like this:</p> <p><a href="https://i.stack.imgur.com/ZVsJU.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZVsJU.gif" alt="Google In Apps Search"></a></p> <p>But this article doesn't have any information about how to implement this features in your app.</p> <p>I use <strong>App Indexing API</strong> in my application, as described in articles:</p> <ul> <li><a href="https://firebase.google.com/docs/app-indexing/android/activity" rel="nofollow noreferrer">Add the App Indexing API</a></li> <li><a href="https://developer.android.com/studio/write/app-link-indexing.html" rel="nofollow noreferrer">Add URL and App Indexing Support</a></li> </ul> <p>This is my code:</p> <pre><code>... private GoogleApiClient mClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ac_main); mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); } public Action getAction() { Thing object = new Thing.Builder() .setName("Test Content") .setDescription("Test Description") .setUrl(Uri.parse("myapp://com.example/")) .build(); return new Action.Builder(Action.TYPE_VIEW).setObject(object) .setActionStatus(Action.STATUS_TYPE_COMPLETED) .build(); } @Override public void onStart() { super.onStart(); mClient.connect(); AppIndex.AppIndexApi.start(mClient, getAction()); } @Override public void onStop() { AppIndex.AppIndexApi.end(mClient, getAction()); mClient.disconnect(); super.onStop(); } ... </code></pre> <p>And this is result:</p> <p><a href="https://i.stack.imgur.com/9Irt1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Irt1.jpg" alt="Search result"></a></p> <p>Google show my application's <em>Test Content</em> but without description and preview image. <strong>Is there any ways to add description and preview image in Google Search Results?</strong> (like Youtube or Twitter)</p>
<android><google-search><android-search><google-app-indexing>
2016-09-09 13:50:07
HQ
39,414,692
A javascript 'let' global variable is not a property of 'window' unlike a global 'var'
<p>I used to check if a global <code>var</code> has been defined with:</p> <pre><code>if (window['myvar']==null) ... </code></pre> <p>or</p> <pre><code>if (window.myvar==null) ... </code></pre> <p>It works with <code>var myvar</code></p> <p>Now that I am trying to switch to let, this does not work anymore.</p> <pre><code>var myvar='a'; console.log(window.myvar); // gives me a let mylet='b'; console.log(window.mylet); // gives me undefined </code></pre> <p>Question: With a global <code>let</code>, is there any place I can look if something has been defined like I could with <code>var</code> from the <code>window</code> object?</p> <p><b>More generally</b>:<br> Is <code>var myvar='a'</code> equivalent to <code>window.myvar='a'</code>?<br> I hear people say that at the global level, <code>let</code> and <code>var</code> are/behave the same, but this is not what I am seeing.</p>
<javascript><var><let>
2016-09-09 15:10:39
HQ
39,414,835
Calculating the average of only the odd numbers
<p>Given the case where I need to sum all the odd numbers from 1 to 100 and in the end print the result and also the average, how do I get to the average, once it's only adding the odd ones, so I cannot just divide it for the upperbound, which is 100? Many thanks!</p>
<java><average>
2016-09-09 15:18:22
LQ_CLOSE
39,416,004
matplotlib not displaying image on Jupyter Notebook
<p>I am using ubuntu 14.04 and coding in jupyter notebook using anaconda2.7 and everything else is up to date . Today I was coding, every thing worked fine. I closed the notebook and when I reopened it, every thing worked fine except that the image was not being displayed.</p> <pre><code>%matplotlib inline import numpy as np import skimage from skimage import data from matplotlib import pyplot as plt %pylab inline img = data.camera() plt.imshow(img,cmap='gray') </code></pre> <p>this is the code i am using, a really simple one but doesn't display the image</p> <pre><code>&lt;matplotlib.image.AxesImage at 0xaf7017ac&gt; </code></pre> <p>this is displayed in the output area please help</p>
<python><image><matplotlib><jupyter>
2016-09-09 16:30:36
HQ
39,416,333
Something wrong with PHP - facebook like count
<?php function fbLikeCount($id,$access_token){ //Request URL $retrievedID == 1633003770266238; // dynamic variable from another field $output["id"]; $json_url ='https://graph.facebook.com/'.$id.'?fields=fan_count&access_token='.$access_token; $json = file_get_contents($json_url); $json_output = json_decode($json); //Extract the likes count from the JSON object if($json_output->fan_count){ return $likes = $json_output->fan_count; }else{ return 0; } } echo fbLikeCount($retrievedID,'288268074855652|b36552b96683cbcfa794b4f6185e6daa'); ?> This code has been working since I want to use $retrievedID as a dynamic and get the value from other variable.. Now the count is not showing at all and gets the error. Please help
<php><facebook><facebook-like>
2016-09-09 16:50:50
LQ_EDIT
39,416,855
window.outerWidth is 0 in Safari on iOS 10 beta
<p>Using an iPad with iOS 10 installed, I entered <code>window.outerWidth</code> in the browser console and got a value of <code>0</code>. OTOH, <code>window.innerWidth</code> correctly produced <code>1024</code> (landscape mode).</p> <p>In iOS 9, <code>window.outerWidth</code> correctly produced <code>1024</code>, so is this just a bug in the iOS 10 beta or is there a subtlety to this property that I'm missing?</p>
<javascript><ios><ios9><ios10>
2016-09-09 17:28:00
HQ
39,417,407
getting error for resizing- 1428: error: (-215) ssize.area() > 0
while True: ret, frame = cap.read() frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
<python><opencv>
2016-09-09 18:08:31
LQ_EDIT
39,417,515
how to allow ECS task access to RDS
<p>I have an ECS task executed from a Lambda function. This task will perform some basic SQL operations (e.g. SELECT, INSERT, UPDATE) on an RDS instance running MySQL. What is the proper way to manage access from the ECS task to RDS?</p> <p>I am currently connecting to RDS using a security group rule where port 3306 allows a connection from a particular IP address (where an EC2 instance resides).</p> <p>I am in the process of moving this functionality from EC2 to the ECS task. I looked into IAM policies, but the actions appear to manage AWS CLI RDS operations, and are likely not the solution here. Thanks!</p>
<mysql><amazon-ec2><amazon-rds><amazon-iam><amazon-ecs>
2016-09-09 18:16:05
HQ
39,417,849
Visual Studio mouse click event
<p>I need a quick and simple (I hope) solution for my C# Windows Form application.</p> <p>How can I make a <code>Mouse Down</code> event that occurs every time I click anywhere in my form (not a specific object)?</p>
<c#><winforms><visual-studio>
2016-09-09 18:38:45
LQ_CLOSE
39,418,008
How to shift list indexes by a certain value in Python
<p>I need to create a python function that right shifts values in a list by a given value. </p> <p>For example if the list is [1,2,3,4] and the shift is 2 it will become [2,3,4,1]. the shift value must be a non negative integer. I can only use the len and range functions. </p> <p>This is what I have so far</p> <pre><code>def shift(array, value): if value &lt; 0: return for i in range(len(array)): arr[i] = arr[(i + shift_amount) % len(arr)] </code></pre>
<python><indexing>
2016-09-09 18:48:55
LQ_CLOSE
39,418,545
Chrome push notification - how to open URL adress after click?
<p>I am new to Google Chrome Push notifications and I was just reading some questions and answers here, on stackoverflow and I have ended with this easy push notification javascript.</p> <pre><code> navigator.serviceWorker.register('sw.js'); function notify() { Notification.requestPermission(function(result) { if (result === 'granted') { navigator.serviceWorker.ready.then(function(registration) { registration.showNotification('test notification', { body: 'Hey I am test!', icon: 'image.png', }); }); } }); } </code></pre> <p>Its just simple notification, but I need open a new window with other webpage after click on notification.</p> <p>I know it is possible, but I cant find examples using "serviceWorker" syntax.</p> <p>Please help. Thanks.</p>
<javascript><google-chrome><push-notification>
2016-09-09 19:30:18
HQ
39,418,668
C# Deserialize Multi-Dimentional JSON array
I am having an issue deserializing and defining this JSON structure would be great to get some assistance. I have reverted this back to last known working position because I am just going off the rails here. my JSON stucture is: [ { "name": "Name1", "description": "Description of this process", "Location": "ANY", "SubItems": [ { "name": "sub1", "required": true, "description": "This is a short description" }, { "name": "sub2", "required": true, "description": "This is a short description" }, { "name": "sub3", "required": true, "description": "This is a short description" } ], "outputs": [ { "name": "out1", "required": false }, { "name": "exit code", "required": false } ] }, { "name": "Name2", "description": "This is a short description", "Location": "ANY", "SubItems": [ { "name": "sub1", "required": false, "description": "This is a short description" }] }, ] } ] Here are my C# Json definitions that were last working. public class JsonObject { [JsonProperty("name")] public string ProcessName { get; set; } [JsonProperty("description")] public string ProcessDescription { get; set; } [JsonProperty("Location")] public string KnownLocation { get; set; } } I am only capturing a couple of definitions at the moment for testing. Here is my deserializing object var Object = JsonConvert.DeserializeObject <List<JsonObject>>(txt); foreach (JsonObject JsonObject in Object) { Console.WriteLine("Name: " + JsonObject.ProcessName); Console.WriteLine(); Console.WriteLine("Description: " +JsonObject.ProcessDescription); Console.WriteLine(); } So as I had stated, I can get at least the first 3 top-most level JSON elements in the output. The problem starts when I start trying to get the "SubItems" and "outputs" I followed the structure of the below linked post and tried very hard to understand it, but after a while I realized that solution is not for this issue. I simply have a multi-dimentional array JSON object. Literally has a top tier, and 2 sub tiers I attempted to try and do... List<List<JsonObject>>Object = JsonConvert.DeserializeObject <List<List<JsonObject>>>(txt); and tried to have 2 lists of the same with different names with 3 sets of JSON Definitions. and implemented the tiered foreach loops, but then I wasn't able to access the definitions for the top most JSON, and nothing was writing for the actual elements for "SubItems" What I need is to get to each object, really. http://stackoverflow.com/questions/32896228/how-to-deserialize-a-json-file-with-multidimensional-array-to-convert-it-to-obje Related Issue
<c#><json><multidimensional-array>
2016-09-09 19:38:51
LQ_EDIT
39,419,170
How do I check that a switch block is exhaustive in TypeScript?
<p>I have some code:</p> <pre><code>enum Color { Red, Green, Blue } function getColorName(c: Color): string { switch(c) { case Color.Red: return 'red'; case Color.Green: return 'green'; // Forgot about Blue } throw new Error('Did not expect to be here'); } </code></pre> <p>I forgot to handle the <code>Color.Blue</code> case and I'd prefer to have gotten a compile error. How can I structure my code such that TypeScript flags this as an error?</p>
<typescript>
2016-09-09 20:21:18
HQ
39,419,478
Compile Error CS1001. Converting Java to C#
<p>CS1001 = Identifier Expected</p> <p>I took a snippet of code from Java that I would like to test in C#. It has a formula for calculating Experience needed to level up in a Video Game project I would like to use. I have just recently began teaching myself code, so converting this was trial and error for me, but I have eliminated the other 13 Errors and this one has me stuck. </p> <p>Missing an identifier seems like a pretty rudimentary issue but it is also vague and i'm not sure when to begin to research. I have comment where the error occurs.</p> <p>Any hints?</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { float points = 0; double output = 0; // Output, XP total at level float minLevel = 2; // First level to Display int maxLevel = 100; // Last Level to Display int lvl = 0; void Main() { for (lvl = 1; lvl &lt;= maxLevel; lvl++) { points += Math.Floor(lvl + 300 * Math.Pow(2, lvl / 7.)); // Compile Error CS1001 at "));" if (lvl &gt;= minLevel) Console.WriteLine("Level " + (lvl) + " - " + output + " EXP"); output = Math.Floor(points / 4); } } } </code></pre> <p>}</p> <p>Original JavaScript Code:</p> <pre><code>&lt;SCRIPT LANGUAGE="JavaScript"&gt; &lt;!-- document.close(); document.open(); document.writeln('Begin JavaScript output:'); document.writeln('&lt;PRE&gt;'); points = 0; output = 0; minlevel = 2; // first level to display maxlevel = 200; // last level to display for (lvl = 1; lvl &lt;= maxlevel; lvl++) { points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.)); if (lvl &gt;= minlevel) document.writeln('Level ' + (lvl) + ' - ' + output + ' xp'); output = Math.floor(points / 4); } document.writeln('&lt;/PRE&gt;'); document.close(); // --&gt; &lt;/SCRIPT&gt; </code></pre>
<c#>
2016-09-09 20:47:25
LQ_CLOSE
39,419,846
What's wrong with this code?
This is the end of my script. I'm getting the error : print "[%s]\t %s " % (item.sharing['access'], item.title) ^ SyntaxError: invalid syntax `#List titles and sharing status for items in users'home folder for item in currentUser.items: print "[%s]\t %s " % (item.sharing['access'], item.title)` If you tell me how to correct this mistake as well as provide resources to avoid mistakes such as this one that would be greatly appreciated.
<python>
2016-09-09 21:18:54
LQ_EDIT
39,420,338
vertical center svg in div container
<p>Can you help me to understand why my svg refuse to resize the height for helping me to center vertically in a div container ?</p> <p>How can I process for align vertical svg in a container ? I seem to svg behaviour is not standard like div...</p> <p>The main idea is that center horizontally AND vertically svg into a div.</p> <p>I try this : <a href="https://jsfiddle.net/gbz7rp7u/1/#&amp;togetherjs=0n9iL62pHv" rel="noreferrer">https://jsfiddle.net/gbz7rp7u/1/#&amp;togetherjs=0n9iL62pHv</a></p> <pre><code>&lt;div id="svg-container"&gt; &lt;svg id="svg-1" height="50%" width="50%" viewBox="0 0 1000 1000" xmlns="http://www.w3.org/2000/svg" version="1.1"&gt; &lt;circle r="15" cx="350" cy="80"&gt;&lt;/circle&gt; &lt;/svg&gt; &lt;/div&gt; #svg-container { background-color: red; } #svg-1 { margin: auto auto; display: block; height: 30%; } </code></pre>
<html><css><svg>
2016-09-09 22:05:21
HQ
39,420,458
Adding offset to all elements in a structure
<p>Is there a way to add an offset to all elements in a structure in one go. </p> <pre><code>#include &lt;stdio.h&gt; struct date { /* global definition of type date */ int month; int day; int year; }; main() { struct date today; today.month = 10; today.day = 14; today.year = 1995; //I want to add 2 to month/day/year. today.month += 2; today.day += 2; today.year += 2; printf("Todays date is %d/%d/%d.\n", \ today.month, today.day, today.year ); } </code></pre>
<c>
2016-09-09 22:17:06
LQ_CLOSE
39,420,730
Merging two different applications JVM into one
I'm looking for a solution/suggestion to merge two different JVM into single JVM. Currently I have two different applications running on two different JVM. Say application1 has app1_Jvm & application2 has app2_Jvm. Now I need to utilize only one JVM say **app_Jvm for both application1 & application2**. Thanks!!
<java><jvm>
2016-09-09 22:52:43
LQ_EDIT
39,421,089
Convert std::chrono::system_clock::time_point to struct timeval and back
<p>I´m writing a C++ code that needs to access an old C library that uses timeval as a representation of the current time.</p> <p>In the old package to get the current date/time we used:</p> <pre><code>struct timeval dateTime; gettimeofday(&amp;dateTime, NULL); function(dateTime); // The function will do its task </code></pre> <p>Now I need to use C++ chrono, something as:</p> <pre><code> system_clock::time_point now = system_clock::now(); struct timeval dateTime; dateTime.tv_sec = ???? // Help appreaciated here dateTime.tv_usec = ???? // Help appreaciated here function(dateTime); </code></pre> <p>Later in code I need the way back, building a <code>time_point</code> variable from the returned <code>struct timeval</code>:</p> <pre><code> struct timeval dateTime; function(&amp;dateTime); system_clock::time_point returnedDateTime = ?? // Help appreacited </code></pre> <p>I´m using C++11. </p>
<c++><c><c++11>
2016-09-09 23:39:05
HQ
39,421,422
Line number in file
<p>I'm having some problem with getting line number.</p> <p>Here is what I got : </p> <pre><code> var lines = File.ReadLines(fileNameData, Encoding.Default); foreach (string line in lines) { if (line.Contains("()")) { MessageBox.Show(line ); } } </code></pre> <p>Which show me </p> <pre><code> MessageBox.Show(line ); </code></pre> <p>So it's shows me lanes which contains (), and it works correctly. Is there any possibitity to get this line number.</p> <pre><code> MessageBox.Show(line + lineIndex); </code></pre> <p>Does anyone know how to accomplish that?</p>
<c#><.net>
2016-09-10 00:42:10
LQ_CLOSE
39,421,948
Value printing in Python
""" Created on Fri Sep 9 22:15:11 2016 @author: WINDOWS 10 Purniah """ cnt = 0 s = 'aghe' s_len = len(s) s_len = s_len - 1 while s_len >= 0: if s[s_len] in ('aeiou'): cnt += 1 s_len -= 1 break; print ('numofVowels:'),cnt This does print the value of cnt. When debugging cnt has the correct value!
<python>
2016-09-10 02:31:01
LQ_EDIT
39,422,092
Error with OMP_NUM_THREADS when using dask distributed
<p>I am using <a href="http://distributed.readthedocs.io/en/latest/" rel="noreferrer">distributed</a>, a framework to allow parallel computation. In this, my primary use case is with NumPy. When I include NumPy code that relies on <code>np.linalg</code>, I get an error with <code>OMP_NUM_THREADS</code>, which is related to the <a href="https://en.wikipedia.org/wiki/OpenMP" rel="noreferrer">OpenMP library</a>.</p> <p>An minimal example:</p> <pre><code>from distributed import Executor import numpy as np e = Executor('144.92.142.192:8786') def f(x, m=200, n=1000): A = np.random.randn(m, n) x = np.random.randn(n) # return np.fft.fft(x) # tested; no errors # return np.random.randn(n) # tested; no errors return A.dot(y).sum() # tested; throws error below s = [e.submit(f, x) for x in [1, 2, 3, 4]] s = e.gather(s) </code></pre> <p>When I test with the linalg test, <code>e.gather</code> fails as each job throws the following error:</p> <pre><code>OMP: Error #34: System unable to allocate necessary resources for OMP thread: OMP: System error #11: Resource temporarily unavailable OMP: Hint: Try decreasing the value of OMP_NUM_THREADS. </code></pre> <p>What should I set <code>OMP_NUM_THREADS</code> to?</p>
<python><numpy><cluster-computing><dask>
2016-09-10 03:01:53
HQ
39,422,621
Visual C++ application deployment that involves openCV: Proper Guideine needed
<p>I have written large amount code using Visual C++ on Visual Studio IDE(VS 2015 Enterprise).My application depends heavily on openCV(x64-vc14). It runs perfectly on my computer. But when I tried to deploy using install shield limited(in debug build mode) to another computer, it shows the .exe file depends many .dll files. I had gone through google, found about dependency walker but when I run dependency walker it gives a dependency list with thousands of .dll files. It's time consuming manual process to copy each of the dll files from my computer and add it in the directory of the application. Is there any other better way to do this automatically? Is there anything I am missing during the building process or in the project property set up? I need a guideline because, in future my application will be even bigger and might also depend on more dll files.</p>
<opencv><visual-c++><dll><deployment><opencv3.0>
2016-09-10 04:39:38
LQ_CLOSE
39,422,694
confusion with the following selection sort code
int i,j,t; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } } My question is whether the above code is correct selection sort code or not? Got this code in various book. if it is incorrect then please explain reason.
<c><selection-sort>
2016-09-10 04:52:58
LQ_EDIT
39,423,054
React JSX file giving error "Cannot read property 'createElement' of undefined"
<p>I have a file test_stuff.js that I am running with <code>npm test</code></p> <p>It pretty much looks like this:</p> <pre><code>import { assert } from 'assert'; import { MyProvider } from '../src/index'; import { React } from 'react'; const myProvider = ( &lt;MyProvider&gt; &lt;/MyProvider&gt; ); describe('Array', function() { describe('#indexOf()', function() { it('should return -1 when the value is not present', function() { assert.equal(-1, [1,2,3].indexOf(4)); }); }); }); </code></pre> <p>Unfortunately, I get the error</p> <pre><code>/Users/me/projects/myproj/test/test_stuff.js:11 var myProvider = _react.React.createElement(_index.MyProvider, null); ^ TypeError: Cannot read property 'createElement' of undefined at Object.&lt;anonymous&gt; (/Users/me/projects/myproj/test/test_stuff.js:7:7) </code></pre> <p>What does that mean? I am importing React from 'react' successfully, so why would React be undefined? It is _react.React, whatever that means...</p>
<javascript><reactjs><npm><react-jsx>
2016-09-10 05:54:15
HQ
39,423,476
Using a list in a function python
<pre><code>file = open('Info.txt', 'r') x = str(file.read()) file.close() info = re.findall(r'\w+', x) j = len(info) Fname = [0] * j def FirstName(info, j, FName): i = 0 n = 0 while i&lt;j: name = info[i] name = name.upper() name = list(name) Fname[n] = name[0] i = i + 3 n = n + 1 </code></pre> <p>I am trying to use the list "FName" in the function I defined as "Firstname". But when i run the program, I get an error stating that "Fname is not defined".</p> <p>The solution is probably very simple but I am new to python.</p> <p>Thanks</p>
<python><python-3.x>
2016-09-10 06:56:06
LQ_CLOSE
39,423,508
Cyrillic / Russian characters SQL Server
Im getting data in Cyrillic formats (russian characters) and loaded perfectly in tables with nvarchar datatype. But i have a function which will convert cyrillic into english. That function on table to be applied on fields if its containing russian characters. Please help.
<sql-server><cyrillic>
2016-09-10 07:01:21
LQ_EDIT
39,425,089
i have a button it should work on from 09.00 Am to 04.00 pm and rest of time it should not work
i have a button it should work according to time from 09.00 Am to 04.00 pm and rest of time it should not work. i am developing an app. i am new in android.... i have three buttons namely register, events, gallery. when i click register button it should work according to time mentioned above... if the user click register on that time it should pass on to the next activity.... and rest of times the button click action should not work.... i am stuck in this... plz help for me.....
<android><android-view><timed>
2016-09-10 10:24:27
LQ_EDIT
39,425,510
SceneKit SCNNode init(mdlObject:) missing?
<p>I'm using Xcode 7.3.1, Swift 2.x, iOS target is 9.3. I can find convenience init <code>init(MDLObject mdlObject: MDLObject)</code> in <a href="https://developer.apple.com/library/ios/documentation/SceneKit/Reference/SCNNode_Class/#//apple_ref/occ/clm/SCNNode/nodeWithMDLObject:" rel="noreferrer" title="docs">Apple docs</a>, but I don't see it in my project. I opened standard game project starter, SceneKit is imported. I've tried:</p> <ul> <li>Double checking iOS version</li> <li>Adding <code>import ModelIO</code></li> <li>Finding "mdlObject:" in header files in SceneKit.framework - not found</li> <li>Looking for alternative methods (maybe Apple moved it somewhere) but there are no other inits with that parameter, no class function, nor I found any corresponding export function in <code>MDLObject</code></li> <li>Cleaning project...</li> </ul> <p>I can see all SceneKit classes, and I can create MDLAsset (part of ModelIO, can return MDLObjects) instance. Any ideas, maybe I've overlooked something obvious?</p>
<ios><swift><scenekit>
2016-09-10 11:18:57
HQ
39,425,546
Add Java import statements automatically via script
<p>Eclipse Java IDE has a shortcut <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>O</kbd> to automatically add unused imports. Where I can find script (bash, python or something other that can be executed via shell) to do this IDE-agnostically, for example, in text editor that can use scripted external tools like gedit?</p>
<java><ide><gedit><gedit-plugin>
2016-09-10 11:23:56
LQ_CLOSE
39,425,572
Formula and running time
I have spent so much time trying to find the formula for this code, but still nothing .. I know the running time but the question really is, what if n = 100 for example, how many line of output will this code print without tracing through ? So, if I found the exact formula, I would answer the question without tracing. This is the code int i, j, k; for( i = 1; i <= n; i++ ) for ( j = i+1; j <= n; j++ ) for( k = j+1; k <= n; k++ ) { System.out.println( i + " " + j + " " + k); }
<java><loops>
2016-09-10 11:28:03
LQ_EDIT
39,425,770
Retreiving Date value through constructor and storing it in variable of type Date.
It throws exception while trying to parse String to Date after getting Date value as a string from the user. What should be done in order to store the Date value (or) is there any any specific method to retrieve date. Medicine.java package Medicine; import java.util.Date; public abstract class Medicine { public int price; Date expiryDate; Medicine() { } Medicine(int price, Date expiryDate) { this.price=price; this.expiryDate=expiryDate; } public void getDetails() { System.out.println("The price is "+this.price); System.out.println("The expiry Date for the product is "+this.expiryDate); } abstract void displayLabel(); } -------------------------------------------------------------------- Tablet.java package Medicine; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Tablet extends Medicine{ Date expDate; void displayLabel() { System.out.println("Store in a cool and dry place"); } Tablet() { } Tablet(int price, Date expDate) { this.price=price; this.expDate=expDate; } } ---------------------------------------------------------------------------- Execution Class int price; Date expDate=new Date();; Scanner reader = new Scanner(System.in); Medicine[] medicineArray =new Medicine[5]; DateFormat df=new SimpleDateFormat("dd-mm-yyyy"); System.out.println("Enter Tablet's price"); price = reader.nextInt(); System.out.println("Enter Tablet's expiry date in yyyy-dd-mm format"); String stringExpDate=reader.nextLine(); try { expDate=df.parse(stringExpDate); } catch(Exception e){ System.out.println("Date format not parsed"); } Medicine med1=new Tablet(price,expDate); med1.getDetails(); med1.displayLabel();
<java><date>
2016-09-10 11:51:44
LQ_EDIT
39,426,287
Xcode 8 cannot run on device, provisioning profile problems mentioning Apple Watch
<p>I am running OS X El Capitan and using the Xcode 8 GM seed (8A218a) and I am trying to run my app on my iPhone 6 with iOS 10 GM seed, 10.01 (14A403), which is paired to my Apple Watch running watchOS 3 GM seed (14S326).</p> <p>I am using Match for handling provisioning profiles and certificates, it has been working beautifully so far.</p> <p>I recently changed the bundle identifier, so created a new App Id in member center and reconfigured match etc. I have the development certificate and provisioning profile installed on my Mac. I have deleted the old certificates and the old provisioning profiles.</p> <p>Everything is just working fine running on the simulator. But when I try to run it on my iPhone Xcode 8 is displaying on error:</p> <blockquote> <p>Provisioning profile "match Development com.XXX.YYY" doesn't include the currently selected device "ZZZ's Apple Watch".</p> </blockquote> <p>It shows another error as well:</p> <blockquote> <p>Code signing is required for product type 'Application' in SDK 'iOS 10.0'</p> </blockquote> <p>This is under <em>Target -> General</em>: <a href="https://i.stack.imgur.com/pSvC5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pSvC5.png" alt="enter image description here"></a></p> <p><em>Target -> Build Settings</em> looks like this: <a href="https://i.stack.imgur.com/UXmSz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UXmSz.png" alt="target_build_settings"></a></p> <p>I don't have an Apple Watch extension for this app. So why is Xcode 8 giving me errors relating to my Apple Watch?</p> <p>Also what does the second error mean? <em>Code signing is required for product type 'Application' in SDK 'iOS 10.0'</em>? </p> <p>Thanks!!</p>
<ios><swift><ios10><xcode8><fastlane-match>
2016-09-10 12:56:35
HQ
39,426,466
css to properly align header image?
I need to align the lifestyle furniture ad image in the header for http://test.wizs.com/. I need it to be flush against the right side. See how it is vertically aligned to the top? I want it to be in line with the logo. Everything that I have tried is not working. Some of the css that I have tried makes the image go halfway off the page... :/ currently, the css is: #header .widget { left: 50%; padding-top: 0; position: absolute; top: 0; z-index: 999; } Any advice on this would be greatly appreciated! :)
<css><alignment><css-position><vertical-alignment>
2016-09-10 13:19:06
LQ_EDIT
39,426,977
Difference between generators and functions returning generators
<p>I was debugging some code with generators and came to this question. Assume I have a generator function</p> <pre><code>def f(x): yield x </code></pre> <p>and a function returning a generator:</p> <pre><code>def g(x): return f(x) </code></pre> <p>They surely return the same thing. Can there be any differences when using them interchangeably in Python code? Is there any way to distinguish the two (without <code>inspect</code>)?</p>
<python><generator>
2016-09-10 14:22:10
HQ
39,427,092
RISC-V: Immediate Encoding Variants
<p>In the RISC-V Instruction Set Manual, User-Level ISA, I couldn't understand section 2.3 Immediate Encoding Variants page 11.</p> <p>There is four types of instruction formats R, I, S, and U, then there is a variants of S and U types which are SB and UJ which I suppose mean Branch and Jump as shown in figure 2.3. Then there is the types of Immediate produced by RISC-V instructions shown in figure 2.4.</p> <p>So my questions are, why the SB and UJ are needed? and why shuffle the Immediate bits in that way? what does it mean to say "the Immediate produced by RISC-V instructions"? and how are they produced in this manner?</p> <p><a href="https://i.stack.imgur.com/Gkjuc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Gkjuc.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/IlZmZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IlZmZ.png" alt="enter image description here"></a></p>
<cpu-architecture><riscv>
2016-09-10 14:35:43
HQ
39,427,178
How to bind method on RadioGroup on checkChanged event with data-binding
<p>I was searching over the internet for how to perform the new cool android data-binding over the <code>RadioGroup</code> and I didn't find a single blog post about it. </p> <p>Its a simple scenario, based on the radio button selected, I want to attach a callback event using android data binding. I don't find any method on the xml part which allows me to define a callback.</p> <p>Like here is my RadioGroup:</p> <pre><code> &lt;RadioGroup android:id="@+id/split_type_radio" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:checkedButton="@+id/split_type_equal" android:gravity="center" &lt;!-- which tag ? --&gt; android:orientation="horizontal"&gt; ... &lt;/RadioGroup&gt; </code></pre> <p>How do I attach a handler method which will be called on <code>RadioGroup</code>'s <code>checkChnged</code> event will fire using data-binding?</p> <p>I have tried using <code>onClick</code> (don't know if it is the same) in layout file and defining method in the Activity and located it using this in the layout file:</p> <pre><code> &lt;variable name="handler" type="com.example.MainActivity"/&gt; ... &lt;RadioGroup android:onClick="handler.onCustomCheckChanged" .. &gt; </code></pre> <p>And defined method <code>onCustomCheckChanged</code> like this:</p> <pre><code>public void onCustomCheckChanged(RadioGroup radio, int id) { // ... } </code></pre> <p>But, it gives me the compilation error:</p> <blockquote> <p>Error:(58, 36) Listener class android.view.View.OnClickListener with method onClick did not match signature of any method handler.onCustomCheckChanged </p> </blockquote> <p>I have seen many blogs mentioning it is possible with <code>RadioGroup</code> but non of them really say how. How can I handle this with <code>data-binding</code> ? </p>
<android><android-databinding><android-radiogroup>
2016-09-10 14:45:37
HQ
39,428,151
Python how to find and group similar permutations of 4 digits
I am not good at these, but please bear with me. I have a set of numbers from my database / list, all is 4 digit numbers with the numbers between and include 0000 through 9999. Say the `list = [1234, 4354, 6554, 2134, 3214, 5456, 9911, 1199]` Basically i want to group them in such a way: 1234, 2134, 3214 is group A 6554, 5456 is group B 9911, 1199 is group C 4354 is group D Then i will find the len(group A), len(group B), len(group C), len(group D)... and then sort them in decreasing manner. How to do it? And if list is huge, is the method still works ok?
<python><permutation>
2016-09-10 16:24:40
LQ_EDIT
39,428,406
How do I make a batch web browser?
<p>I am trying to make a batch web browser for my own mini os. I have tried using the type command but that won't work. How do I embed websites into batch files? Here is what I have so far:</p> <pre><code> @echo off set /p website=What site do you want to read? type %website% pause </code></pre>
<batch-file>
2016-09-10 16:52:37
LQ_CLOSE
39,428,409
Rename deployment in Kubernetes
<p>If I do <code>kubectl get deployments</code>, I get:</p> <pre><code>$ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE analytics-rethinkdb 1 1 1 1 18h frontend 1 1 1 1 6h queue 1 1 1 1 6h </code></pre> <p>Is it possible to rename the deployment to <code>rethinkdb</code>? I have tried googling <code>kubectl edit analytics-rethinkdb</code> and changing the name in the yaml, but that results in an error:</p> <pre><code>$ kubectl edit deployments/analytics-rethinkdb error: metadata.name should not be changed </code></pre> <p>I realize I can just <code>kubectl delete deployments/analytics-rethinkdb</code> and then do <code>kubectl run analytics --image=rethinkdb --command -- rethinkdb etc etc</code> but I feel like it should be possible to simply rename it, no?</p>
<kubernetes>
2016-09-10 16:52:50
HQ
39,429,077
Parsing a line from file
<p>I have a file with the following line:</p> <pre><code> numOfItems = 100 </code></pre> <p>I want to read the line from file and initialize the attribute "numOfItems" to 100. How could I do it, i.e, deleting the unnecessary spaces and read only the values I need?</p> <p>Also, I have another line which is:</p> <pre><code>num Of Items = 100 </code></pre> <p>which I need to parse as error (attributes and values cannot contain spaces).</p> <p>In the first case I know how to remove the spaces at the beginning, but not the intervening spaces. In second case I don't know what to do.</p> <p>I thought to use <code>strtok</code>, but couldn't manage to get what I needed.</p> <p>Please help, thanks!</p>
<c>
2016-09-10 18:06:55
LQ_CLOSE
39,429,122
ASP.NET Core middleware or OWIN middleware?
<p>As I understand it, ASP.NET Core has support for OWIN middleware (via <code>app.UseOwin()</code>) in addition to its own native middleware.</p> <p>What is the difference between ASP.NET Core middleware and OWIN middleware?</p> <p>When designing a new middleware, how do I know if I should design it as a ASP.NET Core middleware or a OWIN middleware?</p>
<asp.net-core><owin-middleware>
2016-09-10 18:11:36
HQ
39,429,565
Please suggest on below vba code, which steps can be remove/omit to run more faster
I wrote below vba coding for automation purpose. But could you suggest me which steps can i remove to run more faster. Sub listof() LQCC = Sheets(1).Cells(Rows.Count, 6).End(xlUp).Row - 1 ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1 tr = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1 tqcp = Sheets(1).Cells(Rows.Count, 6).End(xlUp).Row - 1 ssel = Int(tr / tqcp) Dim ListofQCUsers() As Variant ReDim ListofQCUsers(LQCC) As Variant For y = 1 To UBound(ListofQCUsers) ListofQCUsers(y) = Range("f" & y + 1).Value Next y sampleselection = 0 If ListofQCUsers(UBound(ListofQCUsers)) = Range("a2").Value Then Range("f2").Value = ListofQCUsers(UBound(ListofQCUsers)) Range("f" & LQCC + 1).Value = ListofQCUsers(1) For y = 1 To UBound(ListofQCUsers) ListofQCUsers(y) = Range("f" & y + 1).Value Next y End If Range("f2", "f" & LQCC + 1).Delete For Z = ytqcl To 1 Step -1 For x = 1 To UBound(ListofQCUsers) For d = 1 To ssel And Z <> 0 If Z > 0 Then If ListofQCUsers(x) <> Range("a" & Z).Offset(1, 0).Value Then LSN = Sheets(3).Cells(Rows.Count, 1).End(xlUp).Row + 1 Range("a" & Z).Offset(1, 0).Resize(1, 3).Copy Sheets(3).Range("a" & LSN).PasteSpecial xlPasteAll Sheets(3).Range("a" & LSN).Value = ListofQCUsers(x) Range("a" & Z).Offset(1, 0).Resize(1, 3).Delete sampleselection = sampleselection + 1 End If Z = Z - 1 End If Next d sampleselection = 1 Z = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1 If x = 1 Then Exit Sub End If Next x ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1 Next Z ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row Range("a2", "a" & ytqcl).Resize(1, 3).EntireRow.Delete End Sub I want to assign processed claims for qc to different persons i.e., process person should not get the same claim for to do qc. Above code giving 100% accurate data but i want to know where which steps are not required again and again.
<excel><vba>
2016-09-10 19:01:55
LQ_EDIT
39,429,612
Ordering and Renaming files by a certain criteria ?
So I have a lot of files (hundreds of them) in a folder, and I like to order them and rename them with an automated process. the names of those files are in a form similar to this : " Learning Java 46578.avi " and " learning python 46579.avi" and so on, the numbers on the end of each file name are successive. So my problem is I cant order the files alphabetically because each one starts with a different letter. What I want is to write a script that checks automatically the number at the end of the file name and order the files accordingly and/or place those number in the beginning of all file names so they can be ordered Alphabetically I hope that my question is good Thank you
<windows>
2016-09-10 19:06:43
LQ_EDIT
39,429,897
Any way (Best way) to alter user's IP address before passing query onto remote server
<p>We have a script running on a managed server (LAMP) that uses php/curl to post a user's query to a remote server and then display the results that are returned. What we would like to do is anonymize the users by passing our server IP to the remote server instead of the user IP. How can we implement this? Any suggestions will be appreciated and tried with no hard feelings or snide comments if it doesn't work. We're out of ideas. Thank you.</p>
<php><curl><proxy><header><ip>
2016-09-10 19:36:01
LQ_CLOSE
39,430,176
Is it bad to have 100+ classes in one element
<p>I am making some website and I thought if I make css for everything as each class it can be easier to change after something like extended bootstrap...</p> <p>So I would have <code>font-size.css, text_colors.css etc</code></p> <pre><code>.1px{font-size: 1px;} .2px{font-size: 2px;}.... .red{color: red;} .B4040{color: #B40404;}.... </code></pre> <p>And then when I make div:</p> <pre><code>&lt;div class="2px B40404 something_else"&gt;&lt;/div&gt; </code></pre>
<html><css>
2016-09-10 20:12:29
LQ_CLOSE
39,430,422
how to properly specify database schema in spring boot?
<p>in my spring boot / hibernate application, I need to connect to a Postgres database "ax2012_1", which belong to the "dbo" schema.</p> <p>I have the following application.properties:</p> <pre><code># Database db.driver: org.postgresql.Driver db.url: jdbc:postgresql://localhost:5432/ax2012_1 db.username: my_user_name db.password: my_password spring.datasource.url= jdbc:postgresql://localhost:5432/ax2012_1 spring.datasource.username=my_user_name spring.datasource.password=my_password spring.datasource.schema=dbo spring.jpa.hibernate.ddl-auto=validate # Hibernate hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect hibernate.show_sql: true hibernate.hbm2ddl.auto: update entitymanager.packagesToScan: com.mycompany.myproduct.data </code></pre> <p>my DatabaseConfig.java looks like this:</p> <pre><code>package com.uptake.symphony.data.configs; import java.util.Properties; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement public class DatabaseConfig { // ------------------------ // PUBLIC METHODS // ------------------------ /** * DataSource definition for database connection. Settings are read from * the application.properties file (using the env object). */ @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(env.getProperty("db.driver")); dataSource.setUrl(env.getProperty("db.url")); dataSource.setUsername(env.getProperty("db.username")); dataSource.setPassword(env.getProperty("db.password")); return dataSource; } /** * Declare the JPA entity manager factory. */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); entityManagerFactory.setDataSource(dataSource); // Classpath scanning of @Component, @Service, etc annotated class entityManagerFactory.setPackagesToScan( env.getProperty("entitymanager.packagesToScan")); // Vendor adapter HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); entityManagerFactory.setJpaVendorAdapter(vendorAdapter); // Hibernate properties Properties additionalProperties = new Properties(); additionalProperties.put( "hibernate.dialect", env.getProperty("hibernate.dialect")); additionalProperties.put( "hibernate.show_sql", env.getProperty("hibernate.show_sql")); additionalProperties.put( "hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); entityManagerFactory.setJpaProperties(additionalProperties); additionalProperties.put("hibernate.default_schema", "dbo"); return entityManagerFactory; } /** * Declare the transaction manager. */ @Bean public JpaTransactionManager transactionManager() { JpaTransactionManager transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory( entityManagerFactory.getObject()); return transactionManager; } @Bean public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { return new PersistenceExceptionTranslationPostProcessor(); } @Autowired private Environment env; @Autowired private DataSource dataSource; @Autowired private LocalContainerEntityManagerFactoryBean entityManagerFactory; } </code></pre> <p>From the startup log, I can tell, that hibernate is, in fact, discovering my table "custtable":</p> <pre><code>Hibernate Core {4.3.8.Final} 2016-09-10 15:27:15.866 INFO 69384 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2016-09-10 15:27:15.867 INFO 69384 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2016-09-10 15:27:16.096 INFO 69384 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 2016-09-10 15:27:18.367 INFO 69384 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect 2016-09-10 15:27:18.378 INFO 69384 --- [ main] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException 2016-09-10 15:27:18.499 WARN 69384 --- [ main] org.hibernate.mapping.RootClass : HHH000038: Composite-id class does not override equals(): com.myconpany.myproduct.data.CusttableCompositeKey 2016-09-10 15:27:18.499 WARN 69384 --- [ main] org.hibernate.mapping.RootClass : HHH000039: Composite-id class does not override hashCode(): com.myconpany.myproduct.data.CusttableCompositeKey 2016-09-10 15:27:18.508 INFO 69384 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory 2016-09-10 15:27:18.932 INFO 69384 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update 2016-09-10 15:27:18.933 INFO 69384 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata 2016-09-10 15:27:18.943 INFO 69384 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema 2016-09-10 15:27:18.993 INFO 69384 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: dbo.custtable 2016-09-10 15:27:18.993 INFO 69384 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [custexcludecollectionfee, interestcode_br, servicecodeondlvaddress_br, stateinscription_mx, insscei_br, memo, inventprofiletype_ru, rfidcasetagging, irs1099cindicator, agencylocationcode, enterprisecode, issueownentrycertificate_w, invoicepostingtype_ru, affiliated_ru, contactpersonid, creditcardaddressverification, taxgstreliefgroupheading_my, rfidpallettagging, ccmnum_br, custfinaluser_br, orderentrydeadlinegroupid, accountnum, subsegmentid, entrycertificaterequired_w, salesgroup, bankcentralbankpurposetext, suppitemgroupid, curp_mx, pdscustrebategroupid, commercialregisterinsetnumber, mandatoryvatdate_pl, usecashdisc, inventsiteid, custitemgroupid, defaultdirectdebitmandate, taxwithholdcalculate_th, mcrmergedroot, exportsales_pl, cashdisc, syncversion, federalcomments, girotypeprojinvoice, syncentityid, intercompanyautocreateorders, icmscontributor_br, finecode_br, del_modifiedtime, rfiditemtagging, companynafcode, ienum_br, dataareaid, inventlocation, consday_jp, unitedvatinvoice_lt, foreignerid_br, partition, blocked, vatnum, markupgroup, incltax, custwhtcontributiontype_br, salesdistrictid, girotypefreetextinvoice, currency, maincontactworker, taxgroup, authorityoffice_it, pdsrebatetmagroup, salespoolid, intercompanydirectdelivery, presencetype_br, paymentreference_ee, mcrmergedparent, linedisc, partycountry, commercialregister, multilinedisc, isresident_lv, numbersequencegroup, rfc_mx, paymspec, suframapiscofins_br, fednonfedindicator, invoiceaddress, ouraccountnum, shipcarrierfuelsurcharge, segmentid, defaultdimension, vendaccount, dlvmode, identificationnumber, suframa_br, fiscalcode, taxlicensenum, shipcarrieraccount, destinationcodeid, einvoice, nit_br, cnae_br, paymmode, paymsched, companychainid, girotypeinterestnote, cashdiscbasedays, freightzone, birthcountycode_it, daxintegrationid, packmaterialfeelicensenum, girotypeaccountstatement, defaultinventstatusid, pdsfreightaccrued, shipcarrierid, modifieddatetime, custtradingpartnercode, lvpaymtranscodes, birthplace_it, clearingperiod, enterprisenumber, mandatorycreditlimit, companytype_mx, salescalendarid, einvoiceeannum, websalesorderdisplay, custgroup, dlvreason, factoringaccount, orgid, commercialregistersection, creditcardaddressverificationvoid, paymidtype, dlvterm, residenceforeigncountryregionid_it, paymtermid, statisticsgroup, packagedepositexcempt_pl, forecastdmpinclude, companyidsiret, modifiedby, girotype, birthdate_it, createddatetime, party, taxwithholdgroup_th, shipcarrierblindshipment, onetimecustomer, accountstatement, del_createdtime, lineofbusinessid, taxbordernumber_fi, partystate, expressbilloflading, bankaccount, regnum_w, enddisc, commissiongroup, intercompanyallowindirectcreation, paymdayid, passportno_hu, creditrating, custclassificationid, generateincomingfiscaldocument_br, pbacustgroupid, shipcarrieraccountcode, recid, einvoiceregister_it, intbank_lv, bankcentralbankpurposecode, taxwithholdcalculate_in, usepurchrequest, fiscaldoctype_pl, girotypecollectionletter, pricegroup, invoiceaccount, creditcardaddressverificationlevel, recversion, foreignresident_ru, creditcardcvc, bankcustpaymidtable, cnpjcpfnum_br, inventprofileid_ru, taxperiodpaymentcode_pl, custexcludeinterestcharges, issuercountry_hu, creditmax, suframanumber_br] 2016-09-10 15:27:18.994 INFO 69384 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000108: Foreign keys: [] </code></pre> <p>However, when I run "findById" from my DAO:</p> <pre><code>public Custtable getById(Class&lt;Custtable&gt; class1, CusttableCompositeKey custtableCompositeKey) { Custtable ct = entityManager.find(Custtable.class, custtableCompositeKey); LOG.debug("customer.ct.accountNum: " + ct.getAccountnum()); return entityManager.find(Custtable.class, custtableCompositeKey); } </code></pre> <p>I get this error:</p> <pre><code>Hibernate: select custtable0_.accountnum as accountn1_0_0_, custtable0_.dataareaid as dataarea2_0_0_, custtable0_.partition as partitio3_0_0_, custtable0_.accountstatement as accounts4_0_0_, custtable0_.affiliated_ru as affiliat5_0_0_, custtable0_.agencylocationcode as agencylo6_0_0_, custtable0_.authorityoffice_it as authorit7_0_0_, custtable0_.bankaccount as bankacco8_0_0_, custtable0_.bankcentralbankpurposecode as bankcent9_0_0_, custtable0_.bankcentralbankpurposetext as bankcen10_0_0_, custtable0_.bankcustpaymidtable as bankcus11_0_0_, custtable0_.birthcountycode_it as birthco12_0_0_, custtable0_.birthdate_it as birthda13_0_0_, custtable0_.birthplace_it as birthpl14_0_0_, custtable0_.blocked as blocked15_0_0_, custtable0_.cashdisc as cashdis16_0_0_, custtable0_.cashdiscbasedays as cashdis17_0_0_, custtable0_.ccmnum_br as ccmnum_18_0_0_, custtable0_.clearingperiod as clearin19_0_0_, custtable0_.cnae_br as cnae_br20_0_0_, custtable0_.cnpjcpfnum_br as cnpjcpf21_0_0_, custtable0_.commercialregister as commerc22_0_0_, custtable0_.commercialregisterinsetnumber as commerc23_0_0_, custtable0_.commercialregistersection as commerc24_0_0_, custtable0_.commissiongroup as commiss25_0_0_, custtable0_.companychainid as company26_0_0_, custtable0_.companyidsiret as company27_0_0_, custtable0_.companynafcode as company28_0_0_, custtable0_.companytype_mx as company29_0_0_, custtable0_.consday_jp as consday30_0_0_, custtable0_.contactpersonid as contact31_0_0_, custtable0_.createddatetime as created32_0_0_, custtable0_.creditcardaddressverification as creditc33_0_0_, custtable0_.creditcardaddressverificationlevel as creditc34_0_0_, custtable0_.creditcardaddressverificationvoid as creditc35_0_0_, custtable0_.creditcardcvc as creditc36_0_0_, custtable0_.creditmax as creditm37_0_0_, custtable0_.creditrating as creditr38_0_0_, custtable0_.curp_mx as curp_mx39_0_0_, custtable0_.currency as currenc40_0_0_, custtable0_.custclassificationid as custcla41_0_0_, custtable0_.custexcludecollectionfee as custexc42_0_0_, custtable0_.custexcludeinterestcharges as custexc43_0_0_, custtable0_.custfinaluser_br as custfin44_0_0_, custtable0_.custgroup as custgro45_0_0_, custtable0_.custitemgroupid as custite46_0_0_, custtable0_.custtradingpartnercode as custtra47_0_0_, custtable0_.custwhtcontributiontype_br as custwht48_0_0_, custtable0_.daxintegrationid as daxinte49_0_0_, custtable0_.defaultdimension as default50_0_0_, custtable0_.defaultdirectdebitmandate as default51_0_0_, custtable0_.defaultinventstatusid as default52_0_0_, custtable0_.del_createdtime as del_cre53_0_0_, custtable0_.del_modifiedtime as del_mod54_0_0_, custtable0_.destinationcodeid as destina55_0_0_, custtable0_.dlvmode as dlvmode56_0_0_, custtable0_.dlvreason as dlvreas57_0_0_, custtable0_.dlvterm as dlvterm58_0_0_, custtable0_.einvoice as einvoic59_0_0_, custtable0_.einvoiceeannum as einvoic60_0_0_, custtable0_.einvoiceregister_it as einvoic61_0_0_, custtable0_.enddisc as enddisc62_0_0_, custtable0_.enterprisecode as enterpr63_0_0_, custtable0_.enterprisenumber as enterpr64_0_0_, custtable0_.entrycertificaterequired_w as entryce65_0_0_, custtable0_.exportsales_pl as exports66_0_0_, custtable0_.expressbilloflading as express67_0_0_, custtable0_.factoringaccount as factori68_0_0_, custtable0_.federalcomments as federal69_0_0_, custtable0_.fednonfedindicator as fednonf70_0_0_, custtable0_.finecode_br as finecod71_0_0_, custtable0_.fiscalcode as fiscalc72_0_0_, custtable0_.fiscaldoctype_pl as fiscald73_0_0_, custtable0_.forecastdmpinclude as forecas74_0_0_, custtable0_.foreignerid_br as foreign75_0_0_, custtable0_.foreignresident_ru as foreign76_0_0_, custtable0_.freightzone as freight77_0_0_, custtable0_.generateincomingfiscaldocument_br as generat78_0_0_, custtable0_.girotype as girotyp79_0_0_, custtable0_.girotypeaccountstatement as girotyp80_0_0_, custtable0_.girotypecollectionletter as girotyp81_0_0_, custtable0_.girotypefreetextinvoice as girotyp82_0_0_, custtable0_.girotypeinterestnote as girotyp83_0_0_, custtable0_.girotypeprojinvoice as girotyp84_0_0_, custtable0_.icmscontributor_br as icmscon85_0_0_, custtable0_.identificationnumber as identif86_0_0_, custtable0_.ienum_br as ienum_b87_0_0_, custtable0_.incltax as incltax88_0_0_, custtable0_.insscei_br as insscei89_0_0_, custtable0_.intbank_lv as intbank90_0_0_, custtable0_.intercompanyallowindirectcreation as interco91_0_0_, custtable0_.intercompanyautocreateorders as interco92_0_0_, custtable0_.intercompanydirectdelivery as interco93_0_0_, custtable0_.interestcode_br as interes94_0_0_, custtable0_.inventlocation as inventl95_0_0_, custtable0_.inventprofileid_ru as inventp96_0_0_, custtable0_.inventprofiletype_ru as inventp97_0_0_, custtable0_.inventsiteid as invents98_0_0_, custtable0_.invoiceaccount as invoice99_0_0_, custtable0_.invoiceaddress as invoic100_0_0_, custtable0_.invoicepostingtype_ru as invoic101_0_0_, custtable0_.irs1099cindicator as irs102_0_0_, custtable0_.isresident_lv as isresi103_0_0_, custtable0_.issueownentrycertificate_w as issueo104_0_0_, custtable0_.issuercountry_hu as issuer105_0_0_, custtable0_.linedisc as linedi106_0_0_, custtable0_.lineofbusinessid as lineof107_0_0_, custtable0_.lvpaymtranscodes as lvpaym108_0_0_, custtable0_.maincontactworker as mainco109_0_0_, custtable0_.mandatorycreditlimit as mandat110_0_0_, custtable0_.mandatoryvatdate_pl as mandat111_0_0_, custtable0_.markupgroup as markup112_0_0_, custtable0_.mcrmergedparent as mcrmer113_0_0_, custtable0_.mcrmergedroot as mcrmer114_0_0_, custtable0_.memo as memo115_0_0_, custtable0_.modifiedby as modifi116_0_0_, custtable0_.modifieddatetime as modifi117_0_0_, custtable0_.multilinedisc as multil118_0_0_, custtable0_.nit_br as nit_br119_0_0_, custtable0_.numbersequencegroup as number120_0_0_, custtable0_.onetimecustomer as onetim121_0_0_, custtable0_.orderentrydeadlinegroupid as ordere122_0_0_, custtable0_.orgid as orgid123_0_0_, custtable0_.ouraccountnum as ouracc124_0_0_, custtable0_.packagedepositexcempt_pl as packag125_0_0_, custtable0_.packmaterialfeelicensenum as packma126_0_0_, custtable0_.party as party127_0_0_, custtable0_.partycountry as partyc128_0_0_, custtable0_.partystate as partys129_0_0_, custtable0_.passportno_hu as passpo130_0_0_, custtable0_.paymdayid as paymda131_0_0_, custtable0_.paymentreference_ee as paymen132_0_0_, custtable0_.paymidtype as paymid133_0_0_, custtable0_.paymmode as paymmo134_0_0_, custtable0_.paymsched as paymsc135_0_0_, custtable0_.paymspec as paymsp136_0_0_, custtable0_.paymtermid as paymte137_0_0_, custtable0_.pbacustgroupid as pbacus138_0_0_, custtable0_.pdscustrebategroupid as pdscus139_0_0_, custtable0_.pdsfreightaccrued as pdsfre140_0_0_, custtable0_.pdsrebatetmagroup as pdsreb141_0_0_, custtable0_.presencetype_br as presen142_0_0_, custtable0_.pricegroup as priceg143_0_0_, custtable0_.recid as recid144_0_0_, custtable0_.recversion as recver145_0_0_, custtable0_.regnum_w as regnum146_0_0_, custtable0_.residenceforeigncountryregionid_it as reside147_0_0_, custtable0_.rfc_mx as rfc_mx148_0_0_, custtable0_.rfidcasetagging as rfidca149_0_0_, custtable0_.rfiditemtagging as rfidit150_0_0_, custtable0_.rfidpallettagging as rfidpa151_0_0_, custtable0_.salescalendarid as salesc152_0_0_, custtable0_.salesdistrictid as salesd153_0_0_, custtable0_.salesgroup as salesg154_0_0_, custtable0_.salespoolid as salesp155_0_0_, custtable0_.segmentid as segmen156_0_0_, custtable0_.servicecodeondlvaddress_br as servic157_0_0_, custtable0_.shipcarrieraccount as shipca158_0_0_, custtable0_.shipcarrieraccountcode as shipca159_0_0_, custtable0_.shipcarrierblindshipment as shipca160_0_0_, custtable0_.shipcarrierfuelsurcharge as shipca161_0_0_, custtable0_.shipcarrierid as shipca162_0_0_, custtable0_.stateinscription_mx as statei163_0_0_, custtable0_.statisticsgroup as statis164_0_0_, custtable0_.subsegmentid as subseg165_0_0_, custtable0_.suframa_br as sufram166_0_0_, custtable0_.suframanumber_br as sufram167_0_0_, custtable0_.suframapiscofins_br as sufram168_0_0_, custtable0_.suppitemgroupid as suppit169_0_0_, custtable0_.syncentityid as syncen170_0_0_, custtable0_.syncversion as syncve171_0_0_, custtable0_.taxbordernumber_fi as taxbor172_0_0_, custtable0_.taxgroup as taxgro173_0_0_, custtable0_.taxgstreliefgroupheading_my as taxgst174_0_0_, custtable0_.taxlicensenum as taxlic175_0_0_, custtable0_.taxperiodpaymentcode_pl as taxper176_0_0_, custtable0_.taxwithholdcalculate_in as taxwit177_0_0_, custtable0_.taxwithholdcalculate_th as taxwit178_0_0_, custtable0_.taxwithholdgroup_th as taxwit179_0_0_, custtable0_.unitedvatinvoice_lt as united180_0_0_, custtable0_.usecashdisc as usecas181_0_0_, custtable0_.usepurchrequest as usepur182_0_0_, custtable0_.vatnum as vatnum183_0_0_, custtable0_.vendaccount as vendac184_0_0_, custtable0_.websalesorderdisplay as websal185_0_0_ from Custtable custtable0_ where custtable0_.accountnum=? and custtable0_.dataareaid=? and custtable0_.partition=? 2016-09-10 15:28:54.967 WARN 69384 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42P01 2016-09-10 15:28:54.967 ERROR 69384 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: relation "custtable" does not exist </code></pre> <p>What can I do to fix this?</p>
<java><spring><postgresql><hibernate><spring-boot>
2016-09-10 20:44:23
HQ
39,431,055
How to implement this exercise (dynamic array)?
<p>I'm having like an assesment exercise.</p> <p>So given a Number, for example 12345, I must find out the sum sequence of the digits of the given number (1 + 2 +3 + 4 +5) and then add to it the result (15), and repeat this till the sum sequence of the last number is a digit (in this case is 6).</p> <p><strong>Example :</strong> 12345 + 15 + 6 = 12366;</p> <p>666 + 24 + 6 = 696;</p> <p>I've been thinkig to store the digits in an array, but then I realized the array's size is static. Now I'm thinking to make a linked list, but I'm not really sure. Does it involve linked lists?</p> <p>Just guide me to the right path. What should I use?</p>
<c++><c><algorithm><data-structures><linked-list>
2016-09-10 22:12:48
LQ_CLOSE
39,431,211
How to fix this? undefined method `links' for #<Mechanize::Image:0x120a7e38> (NoMethodError)
My spider script is stuck at this error: mySpiderScript.rb:119:in ` block (3 levels) in <main>': undefined method `links' for #<Mechanize::Image:0x120a7e38> (NoMethodError) Some code: page2 = agent2.get('http://www.mywebsite.net') page2.links.each do |link2| #line 119 name = link2.href.to_s How do I fix this so that the script keeps running?
<ruby><loops><hyperlink><mechanize><nomethoderror>
2016-09-10 22:38:25
LQ_EDIT
39,431,407
com.apple.CoreData.SQLDebug not working
<p>I'm working with Xcode 8 with swift on MacOS Sierra in an iOS app. I realized a few months ago that the SQLDebug stops working... (It used to worked in my app)...</p> <p>I have created a new empty project with the coredata flag enabled..Then I created an entity with attributes and I executed this func in the ViewDidLoad and Xcode is NOT logging the sql</p> <pre><code>func fetchAllData(){ //1 delegate let appDelegate = UIApplication.shared.delegate as! AppDelegate let managedContext = appDelegate.persistentContainer.viewContext //2 prepare fetch request let fetchRequest: NSFetchRequest&lt;NSFetchRequestResult&gt; = NSFetchRequest(entityName:"Entrenamientos") //3 make fetch do{ let fetchedResults = try managedContext.fetch(fetchRequest) as! [NSManagedObject] } catch{ } } </code></pre>
<ios><xcode><core-data>
2016-09-10 23:13:38
HQ
39,431,688
<function setDegreesAndMinutes at 0x10e7cf6e0> on python
when i run my code i got this answer: "<function setDegreesAndMinutes at 0x10e7cf6e0>" my code is below : def setDegreesAndMinutes(self, degrees,minutes): self.degrees = int(input()) self.minutes = float(input()) if(not(isinstance(degrees, int))): raise ValueError("degrees shoule be int") if(not(isinstance(minutes(int,float)))): raise ValueError("minutes shoule be int or float") x = degrees y = minutes return str(x)+'d'+str(y) returnValue = setDegreesAndMinutes print returnValue it will be great if anyone know what is happened , thanks!
<python><function>
2016-09-11 00:07:00
LQ_EDIT
39,432,059
Has angular been replaced with typescript?
<p>So I went through a good tutorial of Angular 1.x. I visited angular.io to have a look at Angular 2. All I can see is Typescript, Javascript, and Dart references. Is what I learnt about Angular pointless now and should I start learning Typescript?</p> <p>Thanks</p>
<angularjs><angular><typescript>
2016-09-11 01:30:19
LQ_CLOSE
39,432,141
Javascript array value as HTML src value
I'm a complete beginner to HTML and Javascript and I've encountered this problem. I have a button and under `onclick`, I have : onclick="document.getElementById('slideCurrent').src=images[1]" and in the Javascript portion, I have : var images = [ "PATH BLABLABLA_1", "PATH BLABLABLA_2", "PATH BLABLABLA_3" ]; and for some reason, it won't display the image. However, if I put the path directly there, it will work normally. What can I do to fix this? Thanks.
<javascript><jquery><html><dom>
2016-09-11 01:47:13
LQ_EDIT
39,432,171
Swft: IOS: How to create a clickable button with image over an ImageView
I'm a stater for IOS trying to design a small application. I have an ImageView as the Background a smaller imageView as panel. Now I'm trying to add a button with image on the panel, but the button is totally not visible. Then I remove the image and set a background color to it, the button becomes visible but not clickable. Below is the code I wrote: [enter image description here][1] [1]: http://i.stack.imgur.com/kBYDV.jpg
<ios><swift>
2016-09-11 01:55:06
LQ_EDIT
39,432,537
Multithreaded is slower than singlethreaded
<p>It is not faster - it's also much slower .</p> <p>I have cpu with 4 core.</p> <p>==================================================================</p> <pre><code>Private Sub btn_Singelthreaded_Click(sender As Object, e As EventArgs) Handles btn_Singelthreaded.Click Dim Num As Long Dim sw As New Stopwatch Dim TimeAvrg As Double For i = 0 To 8 Num = 0 sw.Restart() Do Until Num &gt; 500000000 '500,000,000 Num += 1 Loop TimeAvrg += sw.Elapsed.TotalSeconds 'sw.Stop() Next Console.WriteLine($"[Singelthreaded] Avrg Time: {TimeAvrg / 8}{Environment.NewLine}") End Sub Private NumThrd As Long Private swThrd As New Stopwatch Private Sub btn_Multithreaded_Click(sender As Object, e As EventArgs) Handles btn_Multithreaded.Click Dim T1 As New Threading.Thread(AddressOf ForLoop) : T1.Start() Dim T2 As New Threading.Thread(AddressOf ForLoop) : T2.Start() Dim T3 As New Threading.Thread(AddressOf ForLoop) : T3.Start() End Sub Private Sub ForLoop() Dim TimeAvrg As Double For i = 0 To 2 TimeAvrg = 0 NumThrd = 0 swThrd.Start() Do Until NumThrd &gt; '500,000,000 NumThrd += 1 Loop TimeAvrg += swThrd.Elapsed.TotalSeconds 'swThrd.Stop() Next Console.WriteLine($"[Multithreaded] Avrg Time: {TimeAvrg / 3}{Environment.NewLine}") End Sub </code></pre> <p>Result: [Singelthreaded] Avrg Time: 2.1183545</p> <p>[Multithreaded] Avrg Time: 11.6677879333333</p>
<vb.net><multithreading><cpu><cpu-usage>
2016-09-11 03:21:46
LQ_CLOSE
39,432,717
How can I cache external URLs using service worker?
<p>I've been playing with the Google Web Starter Kit (<a href="https://github.com/google/web-starter-kit" rel="noreferrer">https://github.com/google/web-starter-kit</a>) and have got a little progressive web app working but am stuck on one thing: caching static files from external CDNs. E.g. I'm using MDL icons from <a href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="noreferrer">https://fonts.googleapis.com/icon?family=Material+Icons</a> I can't see a way to cache the request as the service worker only responds to URLs within my app domain.</p> <p>Options I see: 1. Download the file and put it in a vendor folder. Advantages: easy to set up SW cache. Disadvantages: file won't stay up to date as new icons are added (though that won't really matter as my code will only use the icons available).</p> <ol start="2"> <li><p>Use the NPM repo: <a href="https://www.npmjs.com/package/material-design-icons" rel="noreferrer">https://www.npmjs.com/package/material-design-icons</a> and use build step to copy CSS file from node_modules. Advantages: will allow auto-updating from NPM. Disadvantages: slightly more complex to set up.</p></li> <li><p>Some fancy proxy method that would allow me to use the SW to cache an external URL. e.g. myapp.com/loadExternal?url=<a href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="noreferrer">https://fonts.googleapis.com/icon?family=Material+Icons</a></p></li> </ol> <p>I'm leaning towards 2 right now but would be cool to know if 3 is possible.</p>
<javascript><caching><service-worker>
2016-09-11 03:59:37
HQ
39,433,761
How to make While Loops continue for a certain number?
I want to know how to make a While Loop to a certain number, which will be 52. import random ydeal = random.randint(1,9) adeal = random.randint(1,9) yscore = 0 ascore = 0 def roll(): if deal == "!": print(ydeal) print(adeal) if ydeal > adeal: yscore + 1 elif ydeal < adeal: ascore + 1 print(yscore, ascore) deal = input("Your Turn: ") roll() Also, I noticed that when I want to print yscore and ascore it returns the old variable value, 0, and not with the scores added. I know this will probably get an out of topic, but I just need an answer, not add a new questions.
<python>
2016-09-11 07:18:25
LQ_EDIT
39,433,922
socket.io connection event not firing in firefox
<p>Im having something like the below code.</p> <pre><code>&lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt; &lt;script&gt; var socket = io('http://localhost:8080'); socket.on('connect', function(){ socket.on('some-event', function(data) {}); }); socket.on('disconnect', function(){}); &lt;/script&gt; </code></pre> <p>Inside the connect callback I have some code that responds to messages. This works perfectly fine on chrome. On first page load it works fine on firefox. If you reload the page then the connect event does not get called.</p> <p>Im using 1.4.8 version of server and js client</p>
<socket.io><socket.io-1.0>
2016-09-11 07:43:41
HQ
39,434,136
How to achieve replacement using regualr expression?
$test="111222333345555"; How to replace the digit of same repeated digits to 't'? That is how to get the `"11t22t333t34555t"` using regualr expression?
<perl>
2016-09-11 08:15:38
LQ_EDIT
39,434,346
React native takes very long to load on device
<p>I've been developing a react-native app using the simulator for a while. On the simulator (iOS), the app loads very fast (on reload for eg). However, when I tried to load the app to the device, it spends between 1-3 minutes in the splash screen before loading into the app. </p> <p>My project is fairly small, and has no extra resources other than the javascript. Looking at the documentation I couldn't find what might be the cause of the issue, though I suspect it has to do with the fact that it is not getting the JS from the packager local server.</p> <p>What am I doing wrong? </p> <p>(btw - react-native v0.31)</p>
<react-native>
2016-09-11 08:45:34
HQ
39,434,795
I need the code for creating the repository class in case of entity framework
What methods I need : 1) performing all CRUD operations . 2) retrieving data from two or more tables which may or may not present in the database . 3) able to perform transactions
<c#><entity-framework><linq><lambda><repository-pattern>
2016-09-11 09:41:42
LQ_EDIT
39,434,806
Android Studio not stopping for asking to update Gradle
<p>Since the latest version, Android Studio is annoying me that</p> <blockquote> <p>It is strongly recommended that you update Gradle to version 2.14.1 or later.</p> </blockquote> <p><a href="https://i.stack.imgur.com/d6tTk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d6tTk.png" alt="enter image description here"></a></p> <p>Sadly I can´t update it currently, because it breaks my project completely and I need to do research to get it working, so I´m pressing </p> <blockquote> <p>"Don´t remind me again for this project"</p> </blockquote> <p>But it ignores it and it pops up over and over again.</p> <p>Is there any trick to get rid of it?</p>
<android-studio><gradle><android-gradle-plugin>
2016-09-11 09:42:40
HQ
39,435,038
C compiler and arrays
#include <stdio.h> int main(void){ double arr[] = { 1.1, 2.2, 3.3, 4.4 }; int i; for (i=0; i<=4; i++) { printf("%d\n", i); arr[i] = 0; } return 0; } Compiling with gcc(c90) gives an infinite loop(1,2,3,4,1,2,3,4...) while compiling with gcc(c99) produces only (0, 1, 2, 3, 4). What can be attributed to the difference?
<c>
2016-09-11 10:17:20
LQ_EDIT
39,435,395
ReactJS: How to determine if the application is being viewed on mobile or desktop browser
<p>In ReactJS, is there a way to determine if the website is being viewed on mobile or desktop? Because, depending on which device I would like to render different things.</p> <p>Thank you</p>
<javascript><html><reactjs><react-jsx>
2016-09-11 11:02:20
HQ
39,435,443
Why is Python 3 http.client so much faster than python-requests?
<p>I was testing different Python HTTP libraries today and I realized that <a href="https://docs.python.org/3/library/http.client.html" rel="noreferrer"><code>http.client</code></a> library seems to perform much much faster than <a href="http://docs.python-requests.org/en/master/" rel="noreferrer"><code>requests</code></a>. </p> <p>To test it you can run following two code samples.</p> <pre><code>import http.client conn = http.client.HTTPConnection("localhost", port=8000) for i in range(1000): conn.request("GET", "/") r1 = conn.getresponse() body = r1.read() print(r1.status) conn.close() </code></pre> <p>and here is code doing same thing with python-requests:</p> <pre><code>import requests with requests.Session() as session: for i in range(1000): r = session.get("http://localhost:8000") print(r.status_code) </code></pre> <p>If I start SimpleHTTPServer:</p> <pre><code>&gt; python -m http.server </code></pre> <p>and run above code samples (I'm using Python 3.5.2). I get following results:</p> <p>http.client:</p> <pre><code>0.35user 0.10system 0:00.71elapsed 64%CPU </code></pre> <p>python-requests:</p> <pre><code>1.76user 0.10system 0:02.17elapsed 85%CPU </code></pre> <p>Are my measurements and tests correct? Can you reproduce them too? If yes does anyone know what's going on inside <code>http.client</code> that make it so much faster? Why is there such big difference in processing time?</p>
<python><http><python-requests>
2016-09-11 11:09:45
HQ
39,435,749
Where condition in timestamp to date. i want only date based results from timestamp
<p><a href="https://i.stack.imgur.com/MVzgo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MVzgo.jpg" alt="enter image description here"></a></p> <p>Where created_date = 2016-09-11. like that kind of result i want. any solution is there for that?</p>
<php><mysql><select><where-clause>
2016-09-11 11:48:05
LQ_CLOSE
39,435,842
JavaScript fetch API - Why does response.json() return a promise object (instead of JSON)?
<p>I've just started to learn the Fetch API: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch</a></p> <p>Here's a code snippet which I wrote to tinker around with it:</p> <pre><code>fetch('http://swapi.co/api/people/1') .then(function(response) { var json = response.json(); console.log(json); // Expected : { "name": "Luke Skywalker","height": "1.72 m", ... } // Get : Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined} }); </code></pre> <p>I would have expected to get an JSON object out of response.json().</p> <p>Similar to what you get when using JSON.parse(). </p> <p>Instead I get a promise object. </p> <p>If I enlarge the promise chain like shown here ... </p> <pre><code>return response.json().then(function(json) { // process your JSON further }); </code></pre> <p>... then it works: Within the then method of the following promise it appears as json.</p> <p><strong>Why can't I retrieve the JSON data within the then() of the first promise?</strong></p> <p>Can anyone please explain what is going on here?</p> <p>I would really much appreciate it.</p>
<javascript><json><asynchronous>
2016-09-11 12:01:36
HQ
39,436,845
multiple command in postStart hook of a container
<p>in a kubernetes Deployment yaml file is there a simple way to run multiple commands in the postStart hook of a container?</p> <p>I'm trying to do something like this:</p> <pre><code>lifecycle: postStart: exec: command: ["/bin/cp", "/webapps/myapp.war", "/apps/"] command: ["/bin/mkdir", "-p", "/conf/myapp"] command: ["touch", "/conf/myapp/ready.txt"] </code></pre> <p>But it doesn't work. (looks like only the last command is executed)</p> <p>I know I could embed a script in the container image and simply call it there... But I would like to be able to customize those commands in the yaml file without touching the container image.</p> <p>thanks</p>
<kubernetes>
2016-09-11 13:58:32
HQ