title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
How do i uninstall composer on Mac?
<p>I have installed <a href="https://getcomposer.org" rel="noreferrer">Composer</a> with this commands:</p> <pre><code>php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" </code></pre> <p>How can i uninstall it?</p>
0
What is a NoSuchBeanDefinitionException and how do I fix it?
<p>Please explain the following about <code>NoSuchBeanDefinitionException</code> exception in Spring:</p> <ul> <li>What does it mean?</li> <li>Under what conditions will it be thrown?</li> <li>How can I prevent it?</li> </ul> <hr> <p><em>This post is designed to be a comprehensive Q&amp;A about occurrences of <code>NoSuchBeanDefinitionException</code> in applications using Spring.</em></p>
0
Loading application configuration properties from database in spring based application using java based configuration
<p>Its better to store the configuration properties in a database table so that it can be managed easily for different environments. The approach to store and retrieve the configuration properties from database table in xml based configuration is like below :</p> <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /&gt; &lt;property name="properties"&gt; &lt;bean class="org.apache.commons.configuration.ConfigurationConverter" factory-method="getProperties"&gt; &lt;constructor-arg&gt; &lt;bean class="org.apache.commons.configuration.DatabaseConfiguration"&gt; &lt;constructor-arg&gt; &lt;ref bean="dbDataSource" /&gt; &lt;/constructor-arg&gt; &lt;constructor-arg value="DOMAIN_CONFIG" /&gt; &lt;!-- DB Table --&gt; &lt;constructor-arg value="CONFIG_NAME" /&gt; &lt;!-- DB Key Column --&gt; &lt;constructor-arg value="CONFIG_VALUE" /&gt; &lt;!-- DB Value Column --&gt; &lt;/bean&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>But the same thing i'm trying to achieve using java based configuration but no luck. Can anyone please help me.</p>
0
Convert Uint8Array[n] into integer in node.js
<p>I have a variable Uint8Arr of type Uint8Array[4].</p> <pre><code>Uint8Arr[0]=0x12; Uint8Arr[1]=0x19; Uint8Arr[2]=0x21; Uint8Arr[3]=0x47; </code></pre> <p>I want to convert <code>Uint8Arr</code> into its equivalent integer which is <code>0x12192147</code> or <code>303636807</code>.</p> <p>I would like to have a function that can convert Uint8Arr[n] into its equivalent integer and return the result in decimal.</p>
0
Filter rows by distinct values in one column in PySpark
<p>Let's say I have the following table:</p> <pre><code>+--------------------+--------------------+------+------------+--------------------+ | host| path|status|content_size| time| +--------------------+--------------------+------+------------+--------------------+ |js002.cc.utsunomi...|/shuttle/resource...| 404| 0|1995-08-01 00:07:...| | tia1.eskimo.com |/pub/winvn/releas...| 404| 0|1995-08-01 00:28:...| |grimnet23.idirect...|/www/software/win...| 404| 0|1995-08-01 00:50:...| |miriworld.its.uni...|/history/history.htm| 404| 0|1995-08-01 01:04:...| | ras38.srv.net |/elv/DELTA/uncons...| 404| 0|1995-08-01 01:05:...| | cs1-06.leh.ptd.net | | 404| 0|1995-08-01 01:17:...| |dialip-24.athenet...|/history/apollo/a...| 404| 0|1995-08-01 01:33:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:35:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:36:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:37:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:37:...| | h96-158.ccnet.com |/history/apollo/a...| 404| 0|1995-08-01 01:37:...| |hsccs_gatorbox07....|/pub/winvn/releas...| 404| 0|1995-08-01 01:44:...| |www-b2.proxy.aol....|/pub/winvn/readme...| 404| 0|1995-08-01 01:48:...| |www-b2.proxy.aol....|/pub/winvn/releas...| 404| 0|1995-08-01 01:48:...| +--------------------+--------------------+------+------------+--------------------+ </code></pre> <p>How I would filter this table to have only distinct paths in PySpark? But the table should contains all columns.</p>
0
Weak self in closures and consequences example
<p>I have done abit of research on stackoverflow and apple's documentation about ARC and Weak/Unowned self (<a href="https://stackoverflow.com/questions/24320347/shall-we-always-use-unowned-self-inside-closure-in-swift">Shall we always use [unowned self] inside closure in Swift</a>). I get the basic idea about strong reference cycle and how it is not good as they cause memory leaks. However, I am trying to get my head around when to use Weak/Unowned self in closures. Rather then going into the "theory", I think it would really really help if someone could kindly explain them in terms of the bottom three cases that I have. My questions is </p> <ol> <li><p>Is it OK to put weak self in all of them (I think for case two there is no need because I saw somewhere that UIView is not associated with self?. However, what if I put weak self there, is there anything that can cause me headache?</p></li> <li><p>Say if the answer is No, you cant put weak self everywhere in all three cases, what would happen if I do (example response would be much appreciated...For example, the program will crash when this VC ....</p></li> <li><p>This is how I am planning to use weakSelf Outside the closure, I put weak var weakSelf = self Then replace all self in closure with weakSelf? Is that OK to do?</p> <pre><code>Case 1: FIRAuth.auth()?.signInWithCredential(credential, completion: { (user: FIRUser?, error: NSError?) in self.activityIndicatorEnd() self.performSegueWithIdentifier(SEGUE_DISCOVER_VC, sender: self) }) Case 2: UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 0.1, animations: { self.messageLbl.alpha = 0.5 }) Case 3: //checkUserLoggedIn sends a request to firebase and waits for a response to see if the user is still authorised checkUserLoggedIn { (success) in if success == false { // We should go back to login VC automatically } else { self.discoverTableView.delegate = self self.discoverTableView.dataSource = self // Create dropdown menu let menuView = BTNavigationDropdownMenu(navigationController: self.navigationController, title: self.dropDownItems.first!, items: self.dropDownItems) menuView.didSelectItemAtIndexHandler = {[weak self] (indexPath: Int) -&gt; () in if indexPath == 0 { self?.mode = .Closest self?.sortByDistance() } else if indexPath == 1 { self?.mode = .Popular self?.sortByPopularity() } else if indexPath == 2 { self?.mode = .MyPosts self?.loadMyPosts() } else { print("Shouldnt get here saoihasiof") } } // Xib let nib = UINib(nibName: "TableSectionHeader", bundle: nil) self.xibRef = nib.instantiateWithOwner(self, options: nil)[0] as? TableSectionHeader self.discoverTableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: "TableSectionHeader") // Set location Manager data self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest // Check location service status if self.locationAuthStatus == CLAuthorizationStatus.AuthorizedWhenInUse { // Already authorised self.displayMessage.hidden = false } else if self.locationAuthStatus == CLAuthorizationStatus.NotDetermined { // Have not asked for location service before let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("LocationVC") as! LocationVC vc.locationVCDelegate = self self.presentViewController(vc, animated: true, completion: nil) } else { let alertController = UIAlertController(title: "Enable Location", message: "location is required to load nearby posts", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil) let settingsAction = UIAlertAction(title: "Settings", style: .Default, handler: { (action: UIAlertAction) in let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString) if let url = settingsUrl { UIApplication.sharedApplication().openURL(url) } }) alertController.addAction(settingsAction) alertController.addAction(cancelAction) self.presentViewController(alertController, animated: true, completion: nil) self.displayMessage.hidden = false self.displayMessage.text = "Could not determine your location to find nearby posts. Please enable location Service from settings" } // Styling self.refreshBtn.tintColor = COLOR_NAVIGATION_BUTTONS self.discoverTableView.backgroundColor = COLOR_DISCOVERVC_TABLEVIEW_BACKGROUND // Allow navigation bar to hide when scrolling down self.hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: self.discoverTableView) // Allow location to start updating as soon as we have permission self.locationManager.startUpdatingLocation() } } </code></pre></li> </ol> <p>--Update-- Most of my code looks like case 3 where everything is wrapped inside a closure that either check if there is internet connectivity before any of the action is taken place. So I might have weak self everywhere??</p> <p>--Update 2--</p> <pre><code>Case 4: // The haveInternetConnectivity function checks to see if we can reach google within 20 seconds and return true if we can haveInternetConnectivity { (success) in if success == false { self.dismissViewControllerAnimated() } else { self.label.text = "You are logged in" self.performSegueWithIdentifier("GoToNextVC") } } </code></pre> <p>Question about case 4. Am I correct to say that even though this closure does not have weak/unowned self, it will never create strong reference (and memory leak) because even if the VC is dismissed before the completion block is executed, Xcode will try to run the code inside the completion block when we have confirmed internet status and will just do nothing (No crash) because self doesn't exist anymore. And once the code reached the last line inside the closure, the strong reference to self would be destroyed hence deallocate the VC? </p> <p>So putting [weak Self] in that case would just mean that xcode would ignore those lines (as oppose to try and run it and nothing happens) which would mean a better practice but no issues on my hand either way </p>
0
Open activity on firebase notification received in foreground
<p>When my application is open and I receive a notification I want to be able to open the activity associated immediately without the need of the user to tap on the notification. </p> <p>This question is very similar: <a href="https://stackoverflow.com/questions/37554274/open-app-on-firebase-notification-received-fcm">Open app on firebase notification received (FCM)</a></p> <p>But it opens the app when it is in background, I need to do it when my app is in foreground.</p> <p>From the <a href="https://firebase.google.com/docs/notifications/android/console-device" rel="noreferrer">firebase documentation</a>:</p> <blockquote> <p>Notifications delivered when your app is in the background. In this case, the notification is delivered to the device’s system tray. A user tap on a notification opens the app launcher by default. Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.</p> </blockquote> <p>This is my implmentation of <code>onMessageReceived</code></p> <pre><code>@Override public void onMessageReceived(RemoteMessage remoteMessage) { // Check if message contains a data payload. if (remoteMessage.getData().size() &gt; 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); } // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); sendNotification( remoteMessage); } } /** * Create and show a simple notification containing the received FCM message. * * @param remoteMessage FCM message message received. */ private void sendNotification(RemoteMessage remoteMessage) { Intent intent = new Intent(this, MyActivity.class); Map&lt;String, String&gt; hmap ; hmap = remoteMessage.getData(); hmap.get("data_info"); intent.putExtra("data_info", hmap.get("data_info")); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); } </code></pre> <p>I am able to get the notification correctly but the activity only starts once I tap the notification on the system tray.</p> <p>Is there a way to start the activity without tapping the notification while in foreground?</p> <p>The method <code>onMessageReceived()</code> from the class <code>MyFirebaseMessagingService</code> that <code>extends FirebaseMessagingService</code> is getting called correctly while in foreground, but the activity is not getting started. I have also tried with the flag <code>FLAG_ACTIVITY_NEW_TASK</code> also with no luck. Thanks in advance.</p>
0
Is the editor Atom able to open projects on a remote server?
<p>Atom is able to open a project, and to show the whole tree of the project on the left side, a really nice feature.</p> <p>Now I'm using SSH on Host OS to access a Guest OS (say Red Hat Enterprise Linux, RHEL) on Virtualbox, is there a way of Atom located in Host OS to open a project located on RHEL?</p>
0
the realm is already in a write transaction
<p>the realm is already in a write transaction. </p> <p>How can i avoid this error? is there a way to check realm is in write traction? if realm is in write transaction then closed first then do other work. Now after getting this error "the realm is already in a write transaction." then other tasks connected with realm also not working.</p>
0
Where do I see log entries in Application Insights?
<p>I got Application Insights up and running for my ASP.NET application. Then, I installed <a href="https://www.nuget.org/packages/Microsoft.ApplicationInsights.NLogTarget/" rel="noreferrer">Microsoft.ApplicationInsights.NLogTarget</a> package and added <code>ApplicationInsightsTarget</code> to my NLog configuration. It seems to be working fine. At least I can see outgoing requests to <code>dc.services.visualstudio.com:443</code>. Now, where on Azure Portal do I see my log entries? <strong>APPLICATION INSIGHTS -> Activity log</strong> page is always empty.</p> <p><strong>Update:</strong> The issue was I thought all regular NLog messages should appear as they were in terms of event category, i.e. Info, Warn, etc. But the reality was ANY NLog messages went as TRACE entries in Application Insights. Kind of disappointing.</p>
0
select with single case blocks, adding default: unblocks
<p>While testing some code with something like this:</p> <pre class="lang-golang prettyprint-override"><code>// ch := make(chan error) for { select { case &lt;- ch: println("here") } } </code></pre> <p>I notice that if I don't add a <code>default</code> the code blocks:</p> <pre class="lang-golang prettyprint-override"><code>for { select { case &lt;- ch: println("here") default: } } </code></pre> <p>In case that the block is required, could't be better then just use <code>range</code>, something like:</p> <pre class="lang-golang prettyprint-override"><code>for { for _ = range &lt;- ch { println("here") } } </code></pre> <p>Or is there any difference/advantage of using <code>select</code> over <code>range</code> for this case ?</p>
0
How to set connection timeout for Mongodb using pymongo?
<p>I tried setting <code>connectTimeoutMS</code> and <code>socketTimeoutMS</code> to a low value but it still takes about 20 seconds before my script times out. Am I not using the options correctly? I want the script to exit after 5 seconds.</p> <pre><code>def init_mongo(): mongo_connection = MongoClient('%s' %MONGO_SERVER, connectTimeoutMS=5000, socketTimeoutMS=5000) if mongo_connection is None: return try: &lt;code&gt; except: &lt;code&gt; </code></pre>
0
Get .tld from URL via PHP
<p>How to get the .tld from an URL via PHP?</p> <p>E.g. www.domain.com/site, the PHP should post: tld is: .com.</p>
0
How do I copy a Go string to a C char * via CGO in golang?
<p>I want to copy a Go string into a char * via CGO.</p> <p>Am I allowed to do this something like this?</p> <pre><code>func copy_string(cstr *C.char) { str := "foo" C.GoString(cstr) = str } </code></pre>
0
How can I scroll an application using adb?
<p>I am looking for a way to scroll up or down with <code>adb</code> for different types of apps.</p> <p>How can I scroll apps like Facebook or CNN using an <code>adb</code> command?</p>
0
what onEndReachedThreshold really means in react-native
<p><a href="https://facebook.github.io/react-native/docs/listview.html" rel="noreferrer">from documentation</a>:</p> <blockquote> <p>onEndReachedThreshold number </p> </blockquote> <p>Threshold in pixels (virtual, not physical) for calling onEndReached. so I just wanted to know what it means, is it threshold from the top, or is it threshold from the bottom.</p> <p>From the top? - if I set a value of onEndReachedThreshold ={10}, is my onEndReached called as soon as I scrolled to 10 pixel, or something else.</p> <p>From the bottom? - if I set value of onEndReachedThreshold ={listview height -10}, will my onEndReached called as soon as I scrolled to 10 pixel, or something else.</p>
0
Angular2 ng2-bootstrap collapse add transition/animation
<p>I m using this <a href="https://valor-software.com/ng2-bootstrap/#/collapse" rel="noreferrer">https://valor-software.com/ng2-bootstrap/#/collapse</a> and i would like to add an animation/transition on height 0 - auto but we all know that you can't add transition on height auto. I would like to add a slideToggle efect with a duration on it. tried to look for a solution for over 3 days...</p> <p>is there a known solution for this?</p>
0
Using CURL with TOR as a Proxy on CentOs
<p>I want to use Tor as a proxy for HTTP-requests with <em>curl</em> or <em>wget</em> on a <em>CentOS</em> Machine. I used this How-to and I looked for some answers on stackexchange and stackoverflow. <a href="https://medium.com/the-sysadmin/using-tor-for-your-shell-script-fee9d8bdef5c#.9ixz30jbn" rel="noreferrer">https://medium.com/the-sysadmin/using-tor-for-your-shell-script-fee9d8bdef5c#.9ixz30jbn</a></p> <p>If I typing into my shell 'tor' I get this:</p> <pre><code>Aug 31 21:01:29.871 [notice] Tor v0.2.8.6 running on Linux with Libevent 2.0.22-stable, OpenSSL 1.0.2h and Zlib 1.2.8. Aug 31 21:01:29.871 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Aug 31 21:01:29.871 [notice] Read configuration file "/home/wmjio5f6/.linuxbrew/etc/tor/torrc". Aug 31 21:01:29.909 [warn] ControlPort is open, but no authentication method has been configured. This means that any program on your computer can reconfigure your Tor. That's bad! You should upgrade your Tor controller as soon as possible. Aug 31 21:01:29.937 [notice] Opening Socks listener on 127.0.0.1:9050 Aug 31 21:01:29.939 [notice] Opening Control listener on 127.0.0.1:9151 Aug 31 21:01:29.000 [notice] Parsing GEOIP IPv4 file /home/wmjio5f6/.linuxbrew/Cellar/tor/0.2.8.6/share/tor/geoip. Aug 31 21:01:30.000 [notice] Parsing GEOIP IPv6 file /home/wmjio5f6/.linuxbrew/Cellar/tor/0.2.8.6/share/tor/geoip6. Aug 31 21:01:30.000 [notice] Bootstrapped 0%: Starting Aug 31 21:01:31.000 [notice] Bootstrapped 80%: Connecting to the Tor network Aug 31 21:01:32.000 [notice] Bootstrapped 85%: Finishing handshake with first hop Aug 31 21:01:32.000 [notice] Bootstrapped 90%: Establishing a Tor circuit Aug 31 21:01:32.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. Aug 31 21:01:32.000 [notice] Bootstrapped 100%: Done </code></pre> <p>Where is my error, or wich command is the right?</p>
0
Inserting data into Oracle database using c#
<p>I get this error "ora-00928 missing select keyword" when using a button to submit the query. I have other queries on other buttons and the select statements work but for some reason the insert statement doesnt work. I've seen other posts on this error but nothing seems to help mine</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.OleDb; namespace Oracle { public partial class Register : Form { string name; int pass; int repass; string email; public Register() { InitializeComponent(); } OleDbConnection con = new OleDbConnection("Provider=MSDAORA;Data Source=DESKTOP-HQCK6F1:1521/CTECH;Persist Security Info=True;User ID=system;Password=G4ming404;Unicode=True"); OleDbCommand cmd = new OleDbCommand(); private void button1_Click(object sender, EventArgs e) { name = txtname.Text; pass = Convert.ToInt32(txtpass.Text); repass = Convert.ToInt32(txtrepass.Text); email = txtemail.Text; cmd.Connection = con; cmd.CommandText = "INSERT INTO SYSTEM.CUSTOMER('CUSTOMER_ID', 'CUSTOMER_NAME', 'CUSTOMER_EMAIL', 'CUSTOMER_PASSWORD')" + "VALUES('%"+ null + "%','%'" + txtname.Text + "%','%'" + txtemail.Text + "%','%'" + txtpass.Text + "%')"; con.Open(); if (pass == repass) { int rowsUpdated = cmd.ExecuteNonQuery(); if (rowsUpdated == 0) { MessageBox.Show("Record not inserted"); } else { MessageBox.Show("Success!"); } MessageBox.Show("User has been created"); this.Close(); Form1 login = new Form1(); login.Show(); } else { MessageBox.Show("Password mismatch"); } con.Dispose(); } </code></pre>
0
MS Access 2013 to show only startup form and nothing else
<p>While starting up my MS Access 2013 database, I only need it to show the startup form and nothing else. Desired result would be something like below. The background is my desktop.</p> <p>Desired:</p> <p><a href="https://i.stack.imgur.com/SApXd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SApXd.jpg" alt="enter image description here"></a></p> <p>However when I open the DB, the form opens taking the entire screen.</p> <p>The below VBA code runs when the startup form loads and initially it works, but if I minimize the window I can see the background again.</p> <pre><code>Option Compare Database Option Explicit Global Const SW_HIDE = 0 Global Const SW_SHOWNORMAL = 1 Global Const SW_SHOWMINIMIZED = 2 Global Const SW_SHOWMAXIMIZED = 3 Private Declare Function apiShowWindow Lib "user32" _ Alias "ShowWindow" (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Function fSetAccessWindow(nCmdShow As Long) Dim loX As Long Dim loForm As Form On Error Resume Next Set loForm = Screen.ActiveForm If Err &lt;&gt; 0 Then loX = apiShowWindow(hWndAccessApp, nCmdShow) Err.Clear End If If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then MsgBox "Cannot minimize Access with " _ &amp; (loForm.Caption + " ") _ &amp; "form on screen" ElseIf nCmdShow = SW_HIDE And loForm.PopUp &lt;&gt; True Then MsgBox "Cannot hide Access with " _ &amp; (loForm.Caption + " ") _ &amp; "form on screen" Else loX = apiShowWindow(hWndAccessApp, nCmdShow) End If fSetAccessWindow = (loX &lt;&gt; 0) End Function </code></pre> <p>I have hidden ribbons, navigation pane and all access user interfaces, but I need to remove the Access background also.</p> <p>Current:</p> <p><a href="https://i.stack.imgur.com/fKDJ6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fKDJ6.jpg" alt="enter image description here"></a></p> <p>Any help / advice would be appreciated. Thanks in advace !!!</p>
0
How to clear focus from an inputfield in React Native?
<p>I have an inputfield and I want to get rid of the focus on it, after i click the submit button.</p> <p>Any suggestions on how I would go about this?</p>
0
Multiple subdomains with lets encrypt
<p>I have an attractive message indicating me that it is unfortunately not possible to generate a certificate for multiple subdomains:</p> <pre><code>Wildcard domains are not supported: *.mynewsiteweb.com </code></pre> <p>On the other hand it would be possible to generate it one by one for each subdomain. </p> <p>Is there a better solution? Thank you :)</p> <p><br></p> <hr> <p><br></p> <h2>Edit</h2> <p>Now Certbot supports the Wildcard since 0.22.0 version <em>(2018-03-07)</em></p> <h3>Links</h3> <ul> <li>Automatic script: <a href="https://certbot.eff.org" rel="noreferrer">https://certbot.eff.org</a></li> <li>Documentation: <a href="https://certbot.eff.org/docs" rel="noreferrer">https://certbot.eff.org/docs</a></li> </ul> <h3>Thanks</h3> <ul> <li>Certbot ❤</li> <li><a href="https://stackoverflow.com/users/3744681/jahid">Jahid</a></li> <li><a href="https://stackoverflow.com/users/9155658/ozzy-tashtepe">Ozzy Tashtepe</a></li> <li><a href="https://stackoverflow.com/users/1838098/trojan">trojan</a></li> <li><a href="https://stackoverflow.com/users/2177974/jay-riley">Jay Riley</a></li> </ul>
0
WooCommerce - Remove downloads from menu in my account page
<p>I would like to remove downloads menu from <strong>my account page</strong>.</p> <p>How can I do this? Is it any hook to remove a specific item from the menu? </p> <p>Thanks.</p>
0
Log4J intergration with Tomcat - catalina.out log file rotation
<p>I'm using log4j version 2 as logger for Tomcat 8 and now the problem is catalina.out file is not rotating daily.My log4j.property file as follow,</p> <pre><code>log4j.rootLogger = INFO, CATALINA, CONSOLE # Define all the appenders log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender log4j.appender.CATALINA.File = ${catalina.base}/logs/catalina log4j.appender.CATALINA.Append = true log4j.appender.CATALINA.Encoding = UTF-8 # Roll-over the log once per day log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n log4j.appender.LOCALHOST = org.apache.log4j.DailyRollingFileAppender log4j.appender.LOCALHOST.File = ${catalina.base}/logs/localhost log4j.appender.LOCALHOST.Append = true log4j.appender.LOCALHOST.Encoding = UTF-8 log4j.appender.LOCALHOST.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n log4j.appender.MANAGER = org.apache.log4j.DailyRollingFileAppender log4j.appender.MANAGER.File = ${catalina.base}/logs/manager log4j.appender.MANAGER.Append = true log4j.appender.MANAGER.Encoding = UTF-8 log4j.appender.MANAGER.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n log4j.appender.HOST-MANAGER = org.apache.log4j.DailyRollingFileAppender log4j.appender.HOST-MANAGER.File = ${catalina.base}/logs/host-manager log4j.appender.HOST-MANAGER.Append = true log4j.appender.HOST-MANAGER.Encoding = UTF-8 log4j.appender.HOST-MANAGER.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n log4j.appender.CONSOLE = org.apache.log4j.DailyRollingFileAppender log4j.appender.CONSOLE.File = ${catalina.base}/logs/catalina.out log4j.appender.CONSOLE.Append = true log4j.appender.CONSOLE.Encoding = UTF-8 log4j.appender.CONSOLE.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n # Configure which loggers log to which appenders log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost] = INFO, LOCALHOST log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] =\ INFO, MANAGER log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager] =\ INFO, HOST-MANAGER </code></pre> <p>I changed this lines </p> <p><code>log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.Encoding = UTF-8 log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n</code></p> <p>to </p> <pre><code>log4j.appender.CONSOLE = org.apache.log4j.DailyRollingFileAppender log4j.appender.CONSOLE.File = ${catalina.base}/logs/catalina.out log4j.appender.CONSOLE.Append = true log4j.appender.CONSOLE.Encoding = UTF-8 log4j.appender.CONSOLE.DatePattern = '.'yyyy-MM-dd'.log' log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n </code></pre> <p>As suggested by augustin ghauratto in <a href="https://stackoverflow.com/questions/10447866/log4j-daily-rolling-catalina-out-without-restarting-tomcat">this link</a>. But it didn't work for me.</p> <p>How can i make catalina.out file to split and make new file daily.</p>
0
How to stream AWS Lambda response in node?
<p>I have an AWS Lambda function, and I need to invoke it from my node app and stream the result back to the client. I've looked in <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property" rel="noreferrer">the docs</a> but can't see a way. I want to do something like this:</p> <pre><code>lambda.invoke(params).then(data =&gt; data.pipe(res)) </code></pre> <p>or even </p> <pre><code>lambda.invoke(params, (err, data) =&gt; { // data should be a pipeable stream instead of buffered data.pipe(res) }) </code></pre>
0
How to add C++ library in a .NET Core project
<p>How is the way to add a C++ Library in a .NET Core project (Class Library). I tried creating a nuget package but doesn't work. I got this error: </p> <p><code>An unhandled exception of type 'System.DllNotFoundException' occurred in "NameOfDll.dll"</code></p> <p>When I add the nuget package the project.json add the following reference:</p> <pre><code> "dependencies": { "Core": "1.0.0-*", "NETStandard.Library": "1.6.0", "NameOfDll.dll": "1.0.0" }, </code></pre>
0
Uploading multiple files with Multer
<p>I'm trying to upload multiple images using Multer. It all works as expected except that only one file is being uploaded (the last file selected).</p> <p>HTML</p> <pre><code>&lt;form class='new-project' action='/projects' method='POST' enctype="multipart/form-data"&gt; &lt;label for='file'&gt;Select your image:&lt;/label&gt; &lt;input type='file' multiple='multiple' accept='image/*' name='uploadedImages' id='file' /&gt; &lt;span class='hint'&gt;Supported files: jpg, jpeg, png.&lt;/span&gt; &lt;button type='submit'&gt;upload&lt;/button&gt; &lt;/form&gt; </code></pre> <p>JS</p> <pre><code>//Define where project photos will be stored var storage = multer.diskStorage({ destination: function (request, file, callback) { callback(null, './public/uploads'); }, filename: function (request, file, callback) { console.log(file); callback(null, file.originalname) } }); // Function to upload project images var upload = multer({storage: storage}).any('uploadedImages'); // add new photos to the DB app.post('/projects', function(req, res){ upload(req, res, function(err){ if(err){ console.log(err); return; } console.log(req.files); res.end('Your files uploaded.'); console.log('Yep yep!'); }); }); </code></pre> <p>I get the feeling I'm missing something obvious...</p> <p><strong>EDIT</strong></p> <p>Code I tried following Syed's help:</p> <p>HTML</p> <pre><code>&lt;label for='file'&gt;Select your image:&lt;/label&gt; &lt;input type='file' accept='image/*' name='uploadedImages' multiple/&gt; &lt;span class='hint'&gt;Supported files: jpg, jpeg, png.&lt;/span&gt; &lt;input type="submit" value="uploading_img"&gt; </code></pre> <p>JS</p> <pre><code>multer = require('multer'), var upload = multer(); app.post('/projects', upload.array('uploadedImages', 10), function(req, res, err) { if (err) { console.log('error'); console.log(err); } var file = req.files; res.end(); console.log(req.files); }); </code></pre>
0
Handling ConnectionResetError
<p>I have a question on handling ConnectionResetError in Python3. This usually happens when I use the urllib.request.Request function. I would like to know if it is ok to redo the request if we come across such error. For example</p> <pre><code>def get_html(url): try: request = Request(url) response = urlopen(request) html = response.read() except ConectionReserError as e: get_html(url) </code></pre>
0
Spring catch all route for index.html
<p>I'm developing a spring backend for a react-based single page application where I'm using react-router for client-side routing.</p> <p>Beside the index.html page the backend serves data on the path <code>/api/**</code>.</p> <p>In order to serve my index.html from <code>src/main/resources/public/index.html</code> on the root path <code>/</code> of my application I added a resource handler</p> <pre><code>@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/").addResourceLocations("/index.html"); } </code></pre> <p>What I want to is to serve the index.html page whenever no other route matches, e.g. when I call a path other than <code>/api</code>.</p> <p>How do I configure such catch-all route in spring?</p>
0
Process large JSON stream with jq
<p>I get a very large JSON stream (several GB) from <code>curl</code> and try to process it with <code>jq</code>.</p> <p>The relevant output I want to parse with <code>jq</code> is packed in a document representing the result structure:</p> <pre><code>{ "results":[ { "columns": ["n"], // get this "data": [ {"row": [{"key1": "row1", "key2": "row1"}], "meta": [{"key": "value"}]}, {"row": [{"key1": "row2", "key2": "row2"}], "meta": [{"key": "value"}]} // ... millions of rows ] } ], "errors": [] } </code></pre> <p>I want to extract the <code>row</code> data with <code>jq</code>. This is simple:</p> <pre><code>curl XYZ | jq -r -c '.results[0].data[0].row[]' </code></pre> <p>Result:</p> <pre><code>{"key1": "row1", "key2": "row1"} {"key1": "row2", "key2": "row2"} </code></pre> <p>However, this always waits until <code>curl</code> is completed.</p> <p>I played with the <code>--stream</code> option which is made for dealing with this. I tried the following command but is also waits until the full object is returned from <code>curl</code>:</p> <pre><code>curl XYZ | jq -n --stream 'fromstream(1|truncate_stream(inputs)) | .[].data[].row[]' </code></pre> <p>Is there a way to 'jump' to the <code>data</code> field and start parsing <code>row</code> one by one without waiting for closing tags?</p>
0
ADFS as OAuth2 provider / Authentication server possible?
<p>We want to setup ADFS 3.0 to enable OAuth2 based authentication. I have read lots of documentation, but am still unclear if this is supported.</p> <p>Can ADFS be used as an authorization server for oauth, or is oauth2 support in ADFS only meant to work as a client to another authorization server?</p> <p>Any help for setting up adfs as oauth provider/server is appreciated.</p>
0
Using Data from Environment in R Markdown
<p>I'm trying to use data from Global Environment in <strong>R Markdown</strong>. When I call a <code>'summary(mydata)'</code> it gives me this error:</p> <blockquote> <p>object 'mydata' not found</p> </blockquote> <p>I got all my work in many different scripts, so that is not easy for me to create a <code>.R</code> file for each result. </p> <p>So, can I call data defined on Global Environment in <strong>R Markdown</strong>?</p> <p>Thank You.</p>
0
Aggregate over column arrays in DataFrame in PySpark?
<p>Let's say I have the following <code>DataFrame</code>:</p> <pre><code>[Row(user='bob', values=[0.5, 0.3, 0.2]), Row(user='bob', values=[0.1, 0.3, 0.6]), Row(user='bob', values=[0.8, 0.1, 0.1])] </code></pre> <p>I would like to <code>groupBy</code> <code>user</code> and do something like <code>avg(values)</code> where the average is taken over each index of the array <code>values</code> like this:</p> <pre><code>[Row(user='bob', avgerages=[0.466667, 0.233333, 0.3])] </code></pre> <p>How can I do this in PySpark?</p>
0
Why we use Redis and what is the right way to implement Redis with MySql in PHP?
<p>I have large amount data in database, sometimes server not responding when execution of result is more than the server response time. So, is there any way to reduce the load of mysql server with redis and how to implement it with right way.</p>
0
How to access laravel flash data/message in ajax?
<p>I'm trying to access laravel flash messages in the ajax request. I searched about it there are some solutions available, but i want to show them without reloading the page.</p> <p><strong>What I'm Trying :</strong></p> <p>In my controller i'm setting flash message</p> <pre><code>Session::flash('success', 'Record has been inserted successfully'); </code></pre> <p>And</p> <pre><code>return response()-&gt;json([ 'success' =&gt; 'ok' // for status 200 ]); </code></pre> <p>In Ajax</p> <pre><code>success: function(data){ if(data.success){ // reload the current page window.location.href = 'http://localhost/Framework/augLaravel3/public/index.php/user/add'; } } </code></pre> <p>In View</p> <pre><code> @if (Session::has("success")) {{ Session::get("success") }} @endif </code></pre> <p>Above code is working properly, i just want to remove the reloading step, because i'm think it will be more convenient for complex or big application if i show the message through ajax (without page reload). But as i'm new to laravel so i don't know can i convert <code>session::flash</code> to json or not?</p> <p>Can anyone guide me about this, that its possible? and it will be correct way if we access <code>session::flash</code> in ajax? I would like to appreciate if someone guide me. Thank You.</p>
0
how to stack LSTM layers using TensorFlow
<p>what I have is the following, which I believe is a network with one hidden LSTM layer:</p> <pre><code># Parameters learning rate = 0.001 training_iters = 100000 batch_size = 128 display_step = 10 # Network Parameters n_input = 13 n_steps = 10 n_hidden = 512 n_classes = 13 # tf Graph input x = tf.placeholder("float", [None, n_steps, n_input]) y = tf.placeholder("float", [None, n_classes]) # Define weights weights = { 'out' : tf.Variable(tf.random_normal([n_hidden, n_classes])) } biases = { 'out' : tf.Variable(tf.random_normal([n_classes])) } </code></pre> <p>However, I am trying to build an LSTM network using TensorFlow to predict power consumption. I have been looking around to find a good example, but I could not find any model with 2 hidden LSTM layers. Here's the model that I would like to build:</p> <p>1 input layer, 1 output layer, 2 hidden LSTM layers(with 512 neurons in each), time step(sequence length): 10</p> <p>Could anyone guide me to build this using TensorFlow? ( from defining weights, building input shape, training, predicting, use of optimizer or cost function, etc), any help would be much appreciated.</p> <p>Thank you so much in advance!</p>
0
WebClient error when downloading file from https URL
<p>Trying to download XML file from an HTTPS URL (<a href="https://nvd.nist.gov/download/nvd-rss.xml" rel="nofollow noreferrer">https://nvd.nist.gov/download/nvd-rss.xml</a>)</p> <p>This URL is openly accessible through browser.</p> <p>Using C# Webclient with console project.</p> <p>But getting Exception as below</p> <pre class="lang-cs prettyprint-override"><code>using (WebClient client = new WebClient()) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3; client.DownloadFile(uri, @&quot;c:\test\nvd-rss.xml&quot;); } </code></pre> <blockquote> <p>$exception {&quot;The underlying connection was closed: An unexpected error occurred on a send.&quot;} System.Net.WebException</p> </blockquote> <p>Tried adding all properties like SSL etc to system.Net, but did not solve it.</p>
0
How do I replace all spaces, commas and periods in a variable using javascript
<p>I have tried <code>var res = str.replace(/ |,|.|/g, "");</code> and <code>var res = str.replace(/ |,|.|/gi, "");</code>. What am I missing here?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var str = "Text with comma, space, and period."; var res = str.replace(/ |,|.|/g, ""); document.write(res);</code></pre> </div> </div> </p>
0
How to resize an image set as an icon in java netbeans IDE 8.1
<p>I am very new to Java, I have learned how to add images in a <code>jLabel</code> as an icon in <code>netbeans</code>, but the image acts in a notorious way that is it becomes too big in a way that only part of it can be seen.</p> <p>I have tried various ways but I didn't solve it, and most of the answers explain it by coding, a way which I am not familiar with.</p> <p>So I am humbly asking for help on how i can make that image to fit on a small jLabel or if there is any other way to accomplish this. (The images are for a computer voting system that has has an image a check box and name.)</p>
0
H2 database: NULL not allowed for column "ID" when inserting record using jdbcTemplate
<p>I use hibernate's hbm2ddl to generate schema automatically. Here is my domain:</p> <pre><code>@Entity public class Reader { @Id @GeneratedValue(strategy=GenerationType.AUTO) Long id; @Column(nullable=false,unique=true) String name; @Enumerated(EnumType.STRING) Gender gender; int age; Date registeredDate = new Date(); // getter and setter ... } </code></pre> <p>When I using hibernate to save a <code>reader</code>, it works fine as expected as it generats a id to the <code>reader</code> . However when I use jdbcTemplate to insert a record with pure SQL, it report an error:</p> <pre><code>org.springframework.dao.DataIntegrityViolationException: StatementCallback; SQL [insert into reader(name,gender,age) values('Lily','FEMALE',21)]; NULL not allowed for column "ID"; SQL statement:insert into reader(name,gender,age) values('Lily','FEMALE',21) [23502-192]; nested exception is org.h2.jdbc.JdbcSQLException: NULL not allowed for column "ID"; SQL statement: insert into reader(name,gender,age) values('Lily','FEMALE',21) [23502-192] </code></pre> <p>How to solve this?</p> <ol> <li>I debug to find that the DDL of hb2ddl generated is <code>create table Book (id bigint not null, author varchar(255), name varchar(255), price double not null, type varchar(255), primary key (id))</code>. It seems that the hiberate handle the id stratege in its own way but how?</li> <li>The <code>@GeneratedValue(strategy=GenerationType.AUTO)</code> should generate <code>auto increment</code> in the statement of the DDL but I didn't find that. Did I miss it?</li> </ol>
0
Extract data from System.Data.DataRow in powershell
<p>I have a powershell script that executes an sql command and returns a list of ID numbers. </p> <p>When I iterate through the list, this is what it returns. </p> <pre><code>System.Data.DataRow System.Data.DataRow System.Data.DataRow System.Data.DataRow System.Data.DataRow System.Data.DataRow </code></pre> <p>I tried adding <code>Out-String</code> to my list, </p> <pre><code>$q_result = $db.ExecuteWithResults($int_cmd2) $table = $q_result.Tables[0] | Out-String foreach ($user_info in $table) { write-host $user_info } </code></pre> <p>but that returns a poorly formatted list of numbers, everything is tabbed to the very right. see below.</p> <pre><code> GroupID ------------- 381 382 383 384 385 386 </code></pre> <p>I tried using, <code>$user_info.Item[0]</code> in the loop, but that returns nothing. </p> <p>How can I extract just the numbers from the list?. </p>
0
ts-node programmatic usage with require('ts-node/register')
<p><a href="https://github.com/TypeStrong/ts-node#programmatic-usage" rel="noreferrer"><code>ts-node</code> suggests</a> to use <code>require('ts-node/register')</code>. And this can be seen in <code>angular2-webpack-starter</code> <a href="https://github.com/TypeStrong/ts-node#programmatic-usage" rel="noreferrer">Protractor configuration</a>.</p> <p>What is <code>require('ts-node/register')</code> supposed to do? Does it patch <code>require</code> to transpile TS files, so a part of Node.js application could be written in TypeScript?</p>
0
Logstash config, "if string contains..."
<p>So, let's assume that I have a portion of a log line that looks something like this:</p> <pre><code>GET /restAPI/callMethod1/8675309 </code></pre> <p>The GET matches a http method, and get's extracted, the remainder matches a URI, and also gets extracted. Now in the logstash config let's assume that I wanted to do something like this...</p> <pre><code>if [METHOD] == "GET" { if [URI] (CONTAINS &lt;--Is there a way to do this?) =="restAPI/callMethod1"{ .... </code></pre> <p>Is there some way to do this? If so how would I go about doing that?</p> <p>Thanks </p>
0
whats the meaning of curl "-s" and "-m"
<p>I have found following in crontab</p> <pre><code>* * * * * sleep 5; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 10; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 15; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 20; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 25; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 30; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 35; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 40; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 45; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 50; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 * * * * * sleep 55; curl -s -m 10 http://url &gt; /dev/null 2&gt;&amp;1 </code></pre> <p>so whats the meaning of <code>curl -s -m 10</code> here ?</p>
0
Check if record exists with Dapper ORM
<p>What is the simplest way to check if record exists using the Dapper ORM?</p> <p>Do I really need to define POCO objects for a query where I only want to check if a record exists?</p>
0
Select row from a DataFrame based on the type of the object(i.e. str)
<p>So there's a DataFrame say:</p> <pre><code>&gt;&gt;&gt; df = pd.DataFrame({ ... 'A':[1,2,'Three',4], ... 'B':[1,'Two',3,4]}) &gt;&gt;&gt; df A B 0 1 1 1 2 Two 2 Three 3 3 4 4 </code></pre> <p>I want to select the rows whose datatype of particular row of a particular column is of type <code>str</code>.</p> <p>For example I want to select the row where <code>type</code> of data in the column <code>A</code> is a <code>str</code>. so it should print something like:</p> <pre><code> A B 2 Three 3 </code></pre> <p>Whose intuitive code would be like:</p> <pre><code>df[type(df.A) == str] </code></pre> <p>Which obviously doesn't works!</p> <p>Thanks please help!</p>
0
Error 1067- on start OpenSSH by net start opensshd in windows cmd
<p>I try to start opensshd app by following command line: net start opensshd but i encounter below message after press enter in CMD:</p> <blockquote> <pre><code> The OpenSSH Server service is starting. The OpenSSH Server service could not be started. A system error has occurred. System error 1067 has occurred. The process terminated unexpectedly. </code></pre> </blockquote> <p>i install openssh. please Help Me!</p>
0
How do you display a QChartView in a Custom Widget?
<p>I have a QChart that I've assigned to a QChartView. In the example I've been following the chart is displayed, in main.cpp, as: </p> <pre><code>window.setCentralWidget(chartView); </code></pre> <p>In my project I want to utilize the designer and as such have created a custom widget, but it's not displaying the QChart. I found an example where they assigned they assigned the view to a layout and then set the layout, as such:</p> <pre><code>mainLayout = new QGridLayout; mainLayout-&gt;addWidget(chartView, 0, 0); setLayout(mainLayout); </code></pre> <p>But this seems to mess with the layout of all the other widgets within the window. How do I get the Custom Widget to display my chartView?</p> <p>Thank you!</p>
0
Psycopg2 insert python dictionary in postgres database
<p>In python 3+, I want to insert values from a dictionary (or pandas dataframe) into a database. I have opted for psycopg2 with a postgres database.</p> <p>The problems is that I cannot figure out the proper way to do this. I can easily concatenate a SQL string to execute, but the psycopg2 documentation explicitly warns against this. Ideally I wanted to do something like this:</p> <pre><code>cur.execute("INSERT INTO table VALUES (%s);", dict_data) </code></pre> <p>and hoped that the execute could figure out that the keys of the dict matches the columns in the table. This did not work. From the examples of the psycopg2 documentation I got to this approach</p> <pre><code>cur.execute("INSERT INTO table (" + ", ".join(dict_data.keys()) + ") VALUES (" + ", ".join(["%s" for pair in dict_data]) + ");", dict_data) </code></pre> <p>from which I get a</p> <pre><code>TypeError: 'dict' object does not support indexing </code></pre> <p>What is the most phytonic way of inserting a dictionary into a table with matching column names?</p>
0
error TS2349: Cannot invoke an expression whose type lacks a call signature
<p>I am using Angular 2 with TypeScript 2.</p> <p>When I use</p> <pre><code>let labels: string[] | number[] = []; // let labels: Array&lt;number&gt; | Array&lt;string&gt; = []; labels.push(1); </code></pre> <p>it gives me error:</p> <blockquote> <p>error TS2349: Cannot invoke an expression whose type lacks a call signature.</p> </blockquote>
0
Can't find bundle.js
<p>I know this question has been asked before, but I honestly can't find the answer anywhere-- it appears as if I'm doing everything I should however bundle is not created. So I have this <code>webpack.config.js</code> file that's supposed to handle HMR + React, and typescript (with tsx syntax), but it's not creating the bundle. Throws no errors on compilation, and seems to be doing alright, but the bundle returns a 404 when I try to fetch it. Here's my file structure:</p> <pre><code>someApp/ src/ index.tsx components/ Hello.tsx dist/ webpack.config.js ... </code></pre> <p>And here's my webpack config:</p> <pre><code>var path = require('path') var webpack = require('webpack') module.exports = { entry: [ 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server', './src/index.tsx' ], output: { path: path.join(__dirname, '/dist'), filename: 'bundle.js', publicPath: '/public/' }, plugins: [ new webpack.HotModuleReplacementPlugin() ], devtool: 'eval', resolve: { extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js'] }, module: { loaders: [ { test: /\.tsx?$/, loaders: [ 'react-hot-loader', 'ts-loader' ], include: path.join(__dirname, '/src') } ], preLoaders: [ { test: /\.js$/, loader: 'source-map-loader' } ] }, externals: { 'react': 'React', 'react-dom': 'ReactDOM' }, }; </code></pre> <p>Another strange thing is that I think it might have something to do with executing this through node, since when I just run <code>webpack</code> by itself it compiles the bundle. Here's my code for starting up the server:</p> <pre><code>var webpack = require('webpack'); var WebpackDevServer = require('webpack-dev-server'); var config = require('./webpack.config'); new WebpackDevServer(webpack(config), { publicPath: config.output.publicPath, hot: true, historyApiFallback: true }).listen(3000, 'localhost', function (err, result) { if (err) { return console.log(err) } console.log('Listening at http://localhost:3000/') }) </code></pre> <p>Maybe I'm missing something, but I'm pretty new to webpack so any help would be amazing!</p>
0
Cannot find save handler 'redis' - Ubuntu
<p>I am running LAMPP on ubuntu with PHP 5.6.23. </p> <p>I decided to store my sessions in the Redis and I installed it. I also installed Predis too.</p> <p>As a searched in the web I changed my php.ini to :</p> <pre><code>session.save_handler = redis session.save_path = "127.0.0.1:6379" </code></pre> <p>But when tried create a session I am taking this error:</p> <pre><code>Warning: session_start(): Cannot find save handler 'redis' - session startup failed in /path/to/the/Untitled.php </code></pre> <p>You can think that there is a problem in Redis but it's not. It's working properly I can set something and I can check it with Redis-CLI :</p> <p>My redis 'set' PHP code is :</p> <pre><code>&lt;?php require "predis/autoload.php"; $redis = new Predis\Client([ 'scheme' =&gt; 'tcp', 'host' =&gt; '127.0.0.1', 'port' =&gt; 6379, ]); $redis-&gt;set('x', '42'); $redis-&gt;set('name','test'); ?&gt; </code></pre> <p>Results in telnet:</p> <pre><code>Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. MONITOR +OK KEYS * +1471853424.389215 [0 127.0.0.1:36912] "KEYS" "*" *2 $4 name $1 x </code></pre> <p>Session php code:</p> <pre><code>&lt;?php session_start(); $count = isset($_SESSION['cont']) ? $_SESSION['cont'] : 1; echo $count; $_SESSION['cont'] = ++$count; ?&gt; </code></pre> <p>It must increase the number every refresh but It just displays an error.</p> <p>I re-Installed Redis again (v 3.2.3) but still no difference. </p> <p>Is there any way to solve it?</p> <p>Could LAMPP be the reason of problem?</p> <p>EDIT:</p> <p>I started to use phpredis instead of predis.</p>
0
Json Deserialize a webclient response C#
<p>I am new in C# and I know there are hundreds of examples on the google for Json deserialization. I tried many but could not understand how C# works for deserialization.</p> <pre><code>using (var client = new WebClient()) { client.Headers.Add("Content-Type", "text/json"); result = client.UploadString(url, "POST", json); } </code></pre> <p>result looks like this:</p> <pre><code>{"Products":[{"ProductId":259959,"StockCount":83},{"ProductId":420124,"StockCount":158}]} </code></pre> <p>First I created a class:</p> <pre><code>public class ProductDetails { public string ProductId { get; set; } public string StockCount { get; set; } } </code></pre> <p>Then I tried to deserialize using this statement but couldn't understand.</p> <pre><code>var jsonresult = JsonConvert.DeserializeObject&lt;ProductDetails&gt;(result); Debug.WriteLine(jsonresult.ProductId); </code></pre> <p>The above worked fine in visual basic with the following code but how to do this similar in C#</p> <pre><code>Dim Json As Object Set Json = JsonConverter.ParseJson(xmlHttp.responseText) For Each Product In Json("Products") Debug.Print = Product("ProductId") Debug.Print = Product("StockCount") Next Product </code></pre>
0
How to properly style the Select2 outline on :focus?
<p>I'm using <a href="https://select2.github.io/" rel="noreferrer">Select2</a> to style my <code>&lt;select&gt;</code> boxes, but I can't seem to style the forced outline which Chrome applies to the style:</p> <p>Problem: <a href="https://i.stack.imgur.com/Q1irg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q1irg.png" alt="enter image description here"></a></p> <p>I've tried several lines of (very unprofessionally, <code>!important</code>) CSS code, but so far I haven't come up with the solution, this is what i'm at right now:</p> <p>CSS:</p> <pre><code>.select2 &gt; *:focus, .select2:focus .select2 &gt; *, .select2 { outline-width: 0px !important; } </code></pre> <p>For the sake of excluding potential problems, i'm definitely including this CSS file, <em>after</em> my regular select2.css</p> <p>Also, a fiddle would be problematic, but I could provide one if really necessary</p>
0
Spring boot, how to use @Valid with List<T>
<p>I am trying to put validation to a Spring Boot project. So I put <code>@NotNull</code> annotation to Entity fields. In controller I check it like this:</p> <pre><code>@RequestMapping(value="", method = RequestMethod.POST) public DataResponse add(@RequestBody @Valid Status status, BindingResult bindingResult) { if(bindingResult.hasErrors()) { return new DataResponse(false, bindingResult.toString()); } statusService.add(status); return new DataResponse(true, ""); } </code></pre> <p>This works. But when I make it with input <code>List&lt;Status&gt; statuses</code>, it doesn't work.</p> <pre><code>@RequestMapping(value="/bulk", method = RequestMethod.POST) public List&lt;DataResponse&gt; bulkAdd(@RequestBody @Valid List&lt;Status&gt; statuses, BindingResult bindingResult) { // some code here } </code></pre> <p>Basically, what I want is to apply validation check like in the add method to each Status object in the requestbody list. So, the sender will now which objects have fault and which has not.</p> <p>How can I do this in a simple, fast way?</p>
0
How to configure UTF-8 encoding on incoming emails in MS Outlook?
<p>I checked the MS Outlook (office 365, 2013 and 2010) for options to configure UTF-8 character encoding.</p> <p>I found the options for out going email in: File > Options > Advanced > International Options.</p> <p>BUT</p> <p>I am not able to find the option to configure of incoming emails. Does anybody have any idea about this?</p>
0
Download multiple files using "download.file" function
<p>I am trying to download PDFs from a website using R. </p> <p>I have a vector of the PDF-URLs (<em>pdfurls</em>) and a vector of destination file names (<em>destinations</em>):</p> <p>e.g.:</p> <pre><code>pdfurls &lt;- c("http://website/name1.pdf", "http://website/name2.pdf") destinations &lt;- c("C:/username/name1.pdf", "C:/username/name2.pdf") </code></pre> <p>The code I am using is:</p> <pre><code>for(i in 1:length(urls)){ download.file(urls, destinations, mode="wb")} </code></pre> <p>However, when I run the code, R accesses the URL, downloads the first PDF, and repeats downloading the same PDF over and over again.</p> <p>I have read this post: <a href="https://stackoverflow.com/questions/16625377/for-loop-on-r-function">for loop on R function</a> and was wondering if this has something to do with the function itself or is there a problem with my loop?</p> <p>The code is similar to the post here: <a href="https://stackoverflow.com/questions/32241713/how-to-download-multiple-files-using-loop-in-r">How to download multiple files using loop in R?</a> so I was wondering why it is not working and if there is a better way to download multiple files using R. </p>
0
Django template, send two arguments to template tag?
<p>Can anyone tell me if its possible to send multiple variables from field names to a template tag?</p> <p>this question <a href="https://stackoverflow.com/questions/420703/how-do-i-add-multiple-arguments-to-my-custom-template-filter-in-a-django-templat">How do I add multiple arguments to my custom template filter in a django template?</a> is almost there, but i dont know how to send my two field names as a string.</p> <p>my template:</p> <pre><code> &lt;th&gt;{{ item.cost_per_month|remaining_cost:item.install_date + ',' + item.contract_length }}&lt;/th&gt; </code></pre> <p>the above didnt work</p> <p>my template tags:</p> <pre><code>@register.filter('contract_remainder') def contract_remainder(install_date, contract_term): months = 0 now = datetime.now().date() end_date = install_date + relativedelta(years=contract_term) while True: mdays = monthrange(now.year, now.month)[1] now += timedelta(days=mdays) if now &lt;= end_date: months += 1 else: break return months @register.filter('remaining_cost') def remaining_cost(cost_per_month, remainder_vars): dates = remainder_vars.split(',') cost = contract_remainder(dates[0], dates[1]) * cost_per_month return cost </code></pre>
0
How I can send mouse click in powershell?
<p>How I can send mouse click on this position with this code. I want my mouse to go there and click.</p> <pre><code>[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($xposi,$yposi) </code></pre>
0
Get full screen preview with Android camera2
<p>I'm building a custom camera using the new camera2 API. My code is based on the code sample provided by Google <a href="https://github.com/googlesamples/android-Camera2Video" rel="noreferrer">here</a>. </p> <p>I can't find a way to get the camera preview in full screen. In the code sample, they use ratio optimization to adapt to all screens but it's only taking around 3/4 of the screen's height.</p> <p>Here is my code of <code>AutoFitTextureView</code> :</p> <pre><code>public class AutoFitTextureView extends TextureView { private int mRatioWidth = 0; private int mRatioHeight = 0; public AutoFitTextureView(Context context) { this(context, null); } public AutoFitTextureView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public AutoFitTextureView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * Sets the aspect ratio for this view. The size of the view will be measured based on the ratio * calculated from the parameters. Note that the actual sizes of parameters don't matter, that * is, calling setAspectRatio(2, 3) and setAspectRatio(4, 6) make the same result. * * @param width Relative horizontal size * @param height Relative vertical size */ public void setAspectRatio(int width, int height) { if (width &lt; 0 || height &lt; 0) { throw new IllegalArgumentException("Size cannot be negative."); } mRatioWidth = width; mRatioHeight = height; requestLayout(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); if (0 == mRatioWidth || 0 == mRatioHeight) { setMeasuredDimension(width, height); } else { if (width &lt; height * mRatioWidth / mRatioHeight) { setMeasuredDimension(width, width * mRatioHeight / mRatioWidth); } else { setMeasuredDimension(height * mRatioWidth / mRatioHeight, height); } } } </code></pre> <p>}</p> <p>Thank you very much for your help.</p>
0
how to handle sinon.stub().throws() in unit test by Sinon JS
<p>Am trying to invoke <code>fail</code> condition in my snippet. But when I use <code>sinon.stub().throws()</code> method It shows me error. Am unable to handle it in code. <strong>Here is my snippet:</strong></p> <pre><code>login() { let loginData = this.loginData; return this.authService.login(loginData).then(userData =&gt; { let msg = `${this.niceToSeeYouAgain} ${userData.email}!`; this.userAlertsService.showSuccessToast(msg); this.navigationService.afterLoggedIn(); //above lines are covered in test cases }, errorInfo =&gt; { // below line are needed to test this.userAlertsService.showAlertToast(errorInfo); }); } </code></pre> <p>**And here is my unit-test snippet: **</p> <pre><code>it('.login() - should throw exception - in failure case', sinon.test(() =&gt; { let errorInfo = "some error"; let stub = sinon.stub(authService, 'login').throws(); let spy1 = sinon.spy(controller.userAlertsService, 'showAlertToast'); //call function controller.login(); // $timeout.flush(); // expect things console.log(stub.callCount, stub.args[0]); })); </code></pre> <p>Please let me know what am doing wrong</p>
0
How do you create multiple forms on the same page with redux-forms v6?
<p>I have a simple todo app in which my redux store contains an array of 'todos'. My 'Todo' component maps over every 'todo' in the store and renders a 'TodoForm' component that uses redux-forms v6.</p> <p>As it is now, every 'todo' shares the same form name/key, so every time I input something in the 'title' Field, it changes the 'title' of every todo. I found a work around by using unique Field names, but I fear it's going to over complicate things as the app grows, and would prefer to use unique Form names so every field can have the same name without interfering with the other forms </p> <p>(TodoForm1, TodoForm2, TodoForm3 can all have a unique 'title' Field instead of TodoForm containing 'title1', 'title2', 'title3' Fields).</p> <p>I tried accessing the TodoForm's props so I could set each form's key as the component's unique id, but it doesn't seem like the component receives props that early. </p> <p>I also tried making an immediately invoked function where it spits out a random number, and using that number as the form's name, but that also didn't work.</p> <p>How can I can map through all my todos and render a v6 redux-form with a unique form key?</p> <p>Here's a picture of the app, console, and redux devtools. There's 3 'todos', but there's only one form that connects them all, todo-926, even though each form key should have been randomly generated in an immediately invoked function:</p> <p><a href="https://i.stack.imgur.com/fWSij.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fWSij.png" alt="Todo Conundrums"></a></p> <p>HomePageMainSection.index.js</p> <pre><code>renderTodos(todo) { if (!todo) { return &lt;div&gt;No Todos&lt;/div&gt;; } return ( &lt;div key={todo.get('id')}&gt; &lt;Todo todo={todo} updateTodo={this.props.updateTodo} deleteTodo={this.props.deleteTodo} /&gt; &lt;/div&gt; ); } render() { if (!this.props.todos) { return &lt;div&gt;No Todos&lt;/div&gt;; } return ( &lt;div className={styles.homePageMainSection}&gt; &lt;h1&gt;Hey I'm the Main Section&lt;/h1&gt; &lt;div&gt; {this.props.todos.get('todos').map(this.renderTodos)} &lt;/div&gt; &lt;/div&gt; ); } </code></pre> <p>Todo.index.js:</p> <pre><code> renderTodo() { if (this.state.editMode) { return ( &lt;TodoForm todo={this.props.todo} changeTodoEditMode={this.changeTodoEditMode} updateTodo={this.props.updateTodo} /&gt; ); } return ( &lt;div className={styles.Todo} onClick={this.changeTodoEditMode}&gt; &lt;div className="card card-block"&gt; &lt;h4 className="card-title"&gt;{this.props.todo.get('author')}&lt;/h4&gt; &lt;p className="card-text"&gt;{this.props.todo.get('title')}&lt;/p&gt; &lt;i className={`${styles.deleteIcon} btn btn-danger fa fa-times`} onClick={this.deleteTodo} &gt;&lt;/i&gt; &lt;/div&gt; &lt;/div&gt; ); } render() { return ( &lt;div className="col-xs-6 col-sm-4"&gt; {this.renderTodo()} &lt;/div&gt; ); } </code></pre> <p>TodoForm.index.js:</p> <pre><code>class TodoForm extends React.Component { // eslint-disable-line react/prefer-stateless-function constructor(props) { super(props); this._handleSubmit = this._handleSubmit.bind(this); } _handleSubmit(formData) { console.log(''); console.log('OG: ', this.props.todo) console.log('formData: ', formData); const data = this.props.todo.update('title', formData.get('title')); console.log('data: ', data); console.log(''); // this.props.updateTodo(data); } render() { const { handleSubmit, pristine, submitting } = this.props; return ( &lt;form className={`${styles.todoForm} card`} onSubmit={handleSubmit(this._handleSubmit)}&gt; &lt;div className="card-block"&gt; &lt;label htmlFor="title"&gt;{this.props.todo.get('title')}&lt;/label&gt; &lt;div className={'form-group'}&gt; &lt;Field name={`title`} component="input" type="text" placeholder="Enter new title" className="form-control" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div className="card-block btn-group" role="group"&gt; &lt;button className="btn btn-success" type="submit" disabled={pristine || submitting} &gt; Submit &lt;/button&gt; &lt;button className="btn btn-danger fa fa-times" onClick={this.props.changeTodoEditMode} &gt; &lt;/button&gt; &lt;/div&gt; &lt;/form&gt; ); } } const randomNum = (() =&gt; { const thing = Math.floor(Math.random() * 1000) + 1; console.log('thing: ', thing); console.log('notThing: ', TodoForm.props); return thing; })(); export default reduxForm({ form: `todo-${randomNum}`, })(TodoForm); </code></pre>
0
long to wide with dplyr
<p>I have a data frame which is structured like this one:</p> <pre><code>dd &lt;- data.frame(round = c("round1", "round2", "round1", "round2"), var1 = c(22, 11, 22, 11), var2 = c(33, 44, 33, 44), nam = c("foo", "foo", "bar", "bar"), val = runif(4)) round var1 var2 nam val 1 round1 22 33 foo 0.32995729 2 round2 11 44 foo 0.89215038 3 round1 22 33 bar 0.09213526 4 round2 11 44 bar 0.82644723 </code></pre> <p>From this I would like to obtain a data frame with two lines, one for each value of <code>nam</code>, and variables <code>var1_round1</code>, <code>var1_round2</code>, <code>var2_round1</code>, <code>var2_round2</code>, <code>val_round1</code>, <code>val_round2</code>. I would <em>really</em> like to find a dplyr solution to this. </p> <pre><code> nam var1_round1 var1_round2 var2_round1 var2_round2 val_round1 val_round2 1 foo 22 11 33 44 0.32995729 0.8921504 2 bar 22 11 33 44 0.09213526 0.8264472 </code></pre> <p>The closest thing I can think of would be to use <code>spread()</code> in some creative way but I can't seem to figure it out. </p>
0
How to change hint text size without changing the text size in EditText
<p>I have a <code>EditText</code> input field. I have added a hint in it. Now i want to change the size of hint text, but when i do this, it also effects the size of the text. Kindly guide me how to change the size of hint and text separately, and give different fonts to both the hint and the text.</p> <pre><code>&lt;EditText android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="1" android:textSize="12sp" android:textColor="#ffffff" android:fontFamily="sans-serif-light" android:hint="MM/YY" android:textColorHint="@color/white" /&gt; </code></pre>
0
What is a good example to differentiate between fileprivate and private in Swift3
<p>This <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160328/013664.html" rel="noreferrer">article</a> has been helpful in understanding the new access specifiers in <code>Swift 3</code>. It also gives some examples of different usages of <code>fileprivate</code> and <code>private</code>. </p> <p>My question is - isn't using <code>fileprivate</code> on a function that is going to be used only in this file the same as using <code>private</code>?</p>
0
Exporting data from Google Cloud Storage to Amazon S3
<p>I would like to transfer data from a table in BigQuery, into another one in Redshift. My planned data flow is as follows:</p> <p>BigQuery -> Google Cloud Storage -> Amazon S3 -> Redshift</p> <p>I know about Google Cloud Storage Transfer Service, but I'm not sure it can help me. From Google Cloud documentation:</p> <blockquote> <p><strong>Cloud Storage Transfer Service</strong></p> <p>This page describes Cloud Storage Transfer Service, which you can use to quickly import online data into Google Cloud Storage.</p> </blockquote> <p>I understand that this service can be used to import data into Google Cloud Storage and not to export from it.</p> <p>Is there a way I can export data from Google Cloud Storage to Amazon S3?</p>
0
How to send JMS messages from WildFly 10 to remote ActiveMQ
<p>After so much fumbling around the internet, it's a surprise that I can't find a sample configuration for pushing to a remote message queue using JMS in WildFly 10 with ActiveMQ (Artemis). To worsen the situation <code>standalone-full.xml</code> is not bound to a schema (why???) and when I finally found the XSD for it <a href="https://github.com/wildfly/wildfly/blob/master/messaging-activemq/src/main/resources/schema/wildfly-messaging-activemq_1_0.xsd" rel="noreferrer">here on GitHub</a>, it contains no documentation stating what each node/attribute means and what values can be put in what.</p> <p>Below is the original configuration from standalone-full.xml.</p> <pre><code> &lt;subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"&gt; &lt;server name="default"&gt; &lt;security-setting name="#"&gt; &lt;role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/&gt; &lt;/security-setting&gt; &lt;address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/&gt; &lt;http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/&gt; &lt;http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http"&gt; &lt;param name="batch-delay" value="50"/&gt; &lt;/http-connector&gt; &lt;in-vm-connector name="in-vm" server-id="0"/&gt; &lt;http-acceptor name="http-acceptor" http-listener="default"/&gt; &lt;http-acceptor name="http-acceptor-throughput" http-listener="default"&gt; &lt;param name="batch-delay" value="50"/&gt; &lt;param name="direct-deliver" value="false"/&gt; &lt;/http-acceptor&gt; &lt;in-vm-acceptor name="in-vm" server-id="0"/&gt; &lt;jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/&gt; &lt;jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/&gt; &lt;connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/&gt; &lt;connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/&gt; &lt;pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/&gt; &lt;/server&gt; &lt;/subsystem&gt; </code></pre> <p>Below is my CDI queue client which is able to post messages to the local Artemis instance in the WildFly.</p> <pre><code>@ApplicationScoped public class QueueClient { private static final Gson GSON = new Gson(); @Resource(mappedName = "java:jboss/DefaultJMSConnectionFactory") private ConnectionFactory connectionFactory; public void sendMessage(String destinationName, Object message) throws JMSException { try (Connection conn = connectionFactory.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE)) { Queue queue = session.createQueue(destinationName); final Message consignment = session.createMessage(); consignment.setStringProperty("MEDIA_TYPE", "application/json"); consignment.setStringProperty("BODY", GSON.toJson(message)); session.createProducer(queue).send(consignment); } } } </code></pre> <p><strong>My goal</strong>: to post messages to a <strong><em>remote</em></strong> ActiveMQ instance.</p> <p><strong>What I have</strong>: <code>server url</code>, <code>topic name</code>, <code>username</code> and <code>password</code>.</p> <p><strong>My question</strong>: how do I modify the configuration to achieve this goal?</p> <p><strong>Alternative question</strong>: if the above can't be answered, how else do I achieve this goal?</p> <p>Thanks!</p>
0
Why subset doesn't mind missing subset argument for dataframes?
<p>Normally I wonder where mysterious errors come from but now my question is where a mysterious lack of error comes from.</p> <p>Let</p> <pre><code>numbers &lt;- c(1, 2, 3) frame &lt;- as.data.frame(numbers) </code></pre> <p>If I type</p> <pre><code>subset(numbers, ) </code></pre> <p>(so I want to take some subset but forget to specify the subset-argument of the subset function) then R reminds me (as it should):</p> <blockquote> <p>Error in subset.default(numbers, ) :<br> argument "subset" is missing, with no default</p> </blockquote> <p>However when I type</p> <pre><code>subset(frame,) </code></pre> <p>(so the same thing with a <code>data.frame</code> instead of a vector), it doesn't give an error but instead just returns the (full) dataframe.</p> <p>What is going on here? Why don't I get my well deserved error message?</p>
0
Typescript polymorphism
<p>Please have a look on this code:</p> <pre><code>class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } class Ge extends Greeter { constructor(message: string) { super(message); } greet() { return "walla " + super.greet(); } } let greeter = new Ge("world"); console.log(greeter.greet()); // walla Hello, world console.log((&lt;Greeter&gt; greeter).greet()); // walla Hello, world </code></pre> <p>I would expect the second log to print <code>Hello, world</code>. Looking at the transpiled <code>Javascript</code> code, I see the exact same command so it's not that a surprise.</p> <p>The real question is, how do you cast <code>greeter</code> to its extended class?</p>
0
node js Error while installing npm install express code UNABLE_TO_VERIFY_LEAF_SIGNATURE unable to verify the first certificate
<p>I have installed nodejs version node-v4.5.0-x64.msi</p> <p>I am installing express using <strong>npm install express</strong> in windows but getting following error </p> <pre><code>npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\ node_modules\\npm\\bin\\npm-cli.js" "install" "express" npm ERR! node v4.5.0 npm ERR! npm v2.15.9 npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE npm ERR! unable to verify the first certificate npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! &lt;https://github.com/npm/npm/issues&gt; npm ERR! Please include the following file with any support request: npm ERR! D:\user\Node\demo2\npm-debug.log </code></pre> <p><strong>Update</strong> not only express package I was not able to install any package </p>
0
Can not execute Findbugs Caused by: This project contains Java source files that are not compiled
<p>I am currently using the sonarqube server 5.6 with scanner 2.6.1 and I keep getting errors during analysis for a java project. It appears to complain about some java files not compiled in the binaries folder (there aren't any at all in the binaries folder). Once I add the -X parameter I get more exceptions (flagged as ignored), see below. any clues?</p> <p>sonar-project.properties followed by logs</p> <pre><code>sonar.projectKey=myproj sonar.projectName=myproj sonar.projectVersion=1.1 sonar.branch=1.1 sonar.sources=./java sonar.binaries=./deploy sonar.log.level=DEBUG sonar.verbose=false sonar.sourceEncoding=UTF-8 INFO: Execute Checkstyle 6.12.1 done: 2365 ms INFO: Sensor CheckstyleSensor (done) | time=2377ms INFO: Sensor SCM Sensor (wrapped) INFO: SCM provider for this project is: svn INFO: 9 files to be analyzed DEBUG: Working directory: D:\Apps\xxxx DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java DEBUG: Annotate file java/src/xxxx.java INFO: 9/9 files analyzed INFO: Sensor SCM Sensor (wrapped) (done) | time=3289ms INFO: Sensor FindBugs Sensor (wrapped) WARN: Findbugs needs sources to be compiled. Please build project before executing sonar or check the location of compiled classes to make it possible for Findbugs to analyse your project. INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE </code></pre> <hr> <p>execution without the -e param</p> <p>WARN: Findbugs needs sources to be compiled. Please build project before executing sonar or check the location of compiled classes to make it possible for Findbto analyse your project. then java.lang.IllegalStateException: Can not execute Findbugs</p> <p>Caused by: java.lang.IllegalStateException: This project contains Java source files that are not compiled. at org.sonar.plugins.findbugs.FindbugsConfiguration.getFindbugsProject(FindbugsConfiguration.java:120) at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.</p> <p>with the -X parameter</p> <p>com.puppycrawl.tools.checkstyle.api.CheckstyleException: missing key 'severity' in SuppressionCommentFilter</p> <p>then multiple exceptions DEBUG: Keep looking, ignoring exception com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to find class for com.puppycrawl.tools.checkstyle.checks.sizes.WhitespaceAroundCheck</p> <p>then WARN: Findbugs needs sources to be compiled. Please build project before executing sonar or check the location of compiled classes to make it possible for then INFO: EXECUTION FAILURE</p>
0
Disable redirect to /error for certain urls
<p>I have created a springboot application that contains some Rest API endpoints in .../api/myEndpoints... and thymeleaf templates for some UI forms the user can interact with. </p> <p>Since I added an errorController:</p> <pre><code>@Controller @RequestMapping("/error") public class ErrorController { @RequestMapping(method = RequestMethod.GET) public String index(Model model) { return "error"; } } </code></pre> <p>whenever an exception is being thrown in my RestControllers, I receive an empty white website containing the word "error". This maybe makes sense for the web frontend, but not for my api. For the API I want spring to output the standard JSON result e.g.:</p> <pre><code>{ "timestamp": 1473148776095, "status": 400, "error": "Bad request", "exception": "java.lang.IllegalArgumentException", "message": "A required parameter is missing (IllegalArgumentException)", "path": "/api/greet" } </code></pre> <p>When I remove the index method from the ErrorController, then I always receive the JSON output. My question is: Is it somehow possible to exclude the automatic redirection to /error for all api urls (../api/*) only?</p> <p>Thanks a lot. </p>
0
unable to get jsonEncode in magento2
<p>Magento has its own json encode and decode functions:</p> <pre><code>Mage::helper('core')-&gt;jsonEncode($array); </code></pre> <p>Above code in depreciated in Magento 2. So how to use jsonEncode, what I have to extend to use json Encode?</p>
0
Selenium AttributeError: list object has no attribute find_element_by_xpath
<p>I am attempting to perform some scraping of nutritional data from a website, and everything seems to be going swimmingly so far, until I run into pages that are formatted slightly different. </p> <p>Using selenium and a line like this, returns an empty list:</p> <pre><code>values = browser.find_elements_by_class_name('size-12-fl-oz' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value') </code></pre> <p>print would return this:</p> <pre><code>[] [] [] [] [] </code></pre> <p>But if I define out the element position, then it works fine:</p> <pre><code>kcal = data.find_elements_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=1]").text </code></pre> <p>The issue I have ran into, is when the elements are not the same from page to page as I iterate. So if a div does not exist in position 9, then an error is thrown. </p> <p>Now when I go back and try to edit my code to do a <code>try/catch</code>, I am getting:</p> <blockquote> <p>AttributeError: 'list' object has no attribute 'find_element_by_xpath'</p> </blockquote> <p>or</p> <blockquote> <p>AttributeError: 'list' object has no attribute 'find_elements_by_xpath'</p> </blockquote> <p>Here is the code, with my commented out areas from my testing back and forth. </p> <pre><code>import requests, bs4, urllib2, csv from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.support.ui import Select from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException browser = webdriver.Firefox() ... #Loop on URLs to get Nutritional Information from each one. with open('products.txt') as f: for line in f: url = line # url = 'http://www.tapintoyourbeer.com/index.cfm?id=3' browser.get(url) with open("output.csv", "a") as o: writeFile = csv.writer(o) browser.implicitly_wait(3) product_name = browser.find_element_by_tag_name('h1').text.title() #Get product name size = browser.find_element_by_xpath("(//div[@class='dotted-tab'])").text #Get product size data = browser.find_elements_by_xpath("//table[@class='beer-data-table']") # values=[] # values = browser.find_elements_by_class_name('size-12-fl-oz' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value') try: # values = data.find_elements_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])") kcal = data.find_element_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=1]").text kj = data.find_element_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=3]").text fat = data.find_element_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=5]").text carbs = data.find_element_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=7]").text protein = data.find_element_by_xpath("(.//div[@class='size-12-fl-oz nutrition-value' or 'size-330-ml hide nutrition-value' or 'size-8-fl-oz nutrition-value'])[position()=9]").text values = [kcal, kj, fat, carbs, protein] print values writeFile.writerow([product_name] + [size] + values) except NoSuchElementException: print("No Protein listed") browser.quit() </code></pre> <p>I had it working earlier to produce a list, and output to a CSV, but on occasion, the position count would come out wrong. </p> <pre><code>[u'Budweiser', u'12 FL OZ', u'145.00', u'', u'', u'', u''] [u"Beck'S", u'12 FL OZ', u'146.00', u'610.86', u'0.00', u'10.40', u'1.80'] [u'Bud Light', u'12 FL OZ', u'110.00', u'460.24', u'0.00', u'6.60', u'0.90'] [u'Michelob Ultra', u'12 FL OZ', u'95.00', u'397.48', u'0.00', u'2.60', u'0.60'] [u'Stella Artois', u'100 ML', u'43.30', u'KCAL/100 ML', u'181.17', u'KJ/100 ML', u'0.00'] </code></pre> <p>The problems started when position 9 didn't exist on a particular page. </p> <p>Are there any suggestions on how to fix this headache? Do I need to have cases set up for the different pages &amp; sizes? </p> <p>I appreciate the help. </p>
0
Laravel dispatch job doesn't run async, hinders execution
<p>so in laravel I have a function that posts some content and pushes a job onto a queue and returns some data from the function(not the queue). </p> <p>Now I thought that laravel queues were supposed to be some sort of async function that makes sure your code remains quick even though there is a lot of data to handle so you put it in a job. But I noticed that my code still needs to wait till the job is finished before it returns data to the user. Here's a log of the script called 2 times but one is with almost no data in the job, and the other has a lot:</p> <pre><code>[2016-09-08 13:26:50] production.INFO: New alert with Image [2016-09-08 13:26:50] production.INFO: Push is send. [2016-09-08 13:26:50] production.INFO: Alert data is send back. [2016-09-08 13:26:50] production.INFO: New image is valid [2016-09-08 13:26:50] production.INFO: Move file for upload [2016-09-08 13:26:50] production.INFO: Made it to upload [2016-09-08 13:28:50] production.INFO: New alert with Image [2016-09-08 13:31:19] production.INFO: Push is send. [2016-09-08 13:31:19] production.INFO: Alert data is send back. [2016-09-08 13:31:20] production.INFO: New image is valid [2016-09-08 13:31:20] production.INFO: Move file for upload [2016-09-08 13:31:20] production.INFO: Made it to upload </code></pre> <p>As you can see the second ones takes 4 minutes before the application receives further data. This is a deal breaker you can't make users wait so long. So how do I get the job to run async and the function doesn't have to wait for it to finish. </p> <p>Here's the line where I call the code:</p> <pre><code>if($isValid === true) { $this-&gt;dispatch(new SendPushNotificationAlert($alert)); Log::info('Push is send.'); } </code></pre> <p>And here is my job: </p> <pre><code>&lt;?php namespace App\Jobs; use DB; use Log; use App\Alerts; use App\Users; use App\Jobs\Job; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use App\Http\Controllers\PushNotificationsController as PushNotificationsController; class SendPushNotificationAlert extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels; Protected $alert; /** * Create a new job instance. * * @return void */ public function __construct(Alerts $alert) { // $this-&gt;alert = $alert; } /** * Execute the job. * * @return void */ public function handle() { $alert = $this-&gt;alert; $radius = 10000; $earthRadius = 6371000; // earth's mean radius, m // first-cut bounding box (in degrees) $maxLat = $alert-&gt;lat + rad2deg($radius/$earthRadius); $minLat = $alert-&gt;lat - rad2deg($radius/$earthRadius); // compensate for degrees longitude getting smaller with increasing latitude $maxLon = $alert-&gt;lon + rad2deg($radius/$earthRadius/cos(deg2rad($alert-&gt;lat))); $minLon = $alert-&gt;lon - rad2deg($radius/$earthRadius/cos(deg2rad($alert-&gt;lat))); $locations = DB::select(" SELECT id, lat, lon, user_id, name, radius, acos( sin(?)* sin(radians(lat))+ cos(?)* cos(radians(lat))* cos(radians(lon) - ?) ) * ? AS distance FROM ( SELECT id, lat, lon, user_id, name, radius FROM user__locations WHERE lat BETWEEN ? AND ? AND lon BETWEEN ? AND ? AND hide = 0 ) AS FirstCut WHERE acos( sin(?)* sin(radians(lat))+ cos(?)* cos(radians(lat) )* cos(radians(lon) - ?) ) * ? &lt; ? ORDER BY distance", [ deg2rad($alert-&gt;lat), deg2rad($alert-&gt;lat), deg2rad($alert-&gt;lon), $earthRadius, $minLat, $maxLat, $minLon, $maxLon, deg2rad($alert-&gt;lat), deg2rad($alert-&gt;lat), deg2rad($alert-&gt;lon), $earthRadius, $radius ]); if(count($locations &gt; 0)) { foreach ($locations as $location) { if($location-&gt;distance &lt; $location-&gt;radius) { if($alert-&gt;anoniem == 0) { $user = Users::find($alert-&gt;user_id); $pushuser = Users::find($location-&gt;user_id); $pushuser-&gt;type = 'location'; $pushuser-&gt;locationname = $location-&gt;name; $pushusers[] = $pushuser; } } } } if(isset($pushusers)) { PushNotificationsController::sendPushnotificationsAlert($pushusers, $user); } } } </code></pre> <p>Anyone knows why the job doesn't run async and what I could do to fix it? </p>
0
TextColor vs TextColorPrimary vs TextColorSecondary
<p>What do each of these encompass in terms of text throughout an app?</p> <p>More specifically, what would changing each of these in a theme change throughout my app? I'd like my buttons' texts to be a different color than my textviews; is one primary and the other secondary? </p> <p>Any info related to these terms is appreciated!</p>
0
About the GNU make dependency files *.d
<p>In the makefile of a program, one has to write rules that define the dependencies of each object file. Consider the object file <code>fileA.o</code>. It is obvious that this object file depends on the source file <code>fileA.c</code>. But it will also depend on all the header files that this source file includes. So the following rule should be added to the makefile:</p> <pre><code> # This rule states that fileA.o depends on fileA.c (obviously), but also # on the header files fileA.h, fileB.h and fileC.h fileA.o: fileA.c fileA.h fileB.h fileC.h </code></pre> <p>Note that the rule has no recipe. One could add a recipe to it, but it is strictly speaking not necessary, because GNU make can rely on an implicit rule (with recipe) to compile a <code>*.c</code> file into a <code>*.o</code> file.</p> <p>Anyway, writing such rules manually is a hellish task. Just imagine the work to keep the makefile rules in sync with the #include statements from the source code.</p> <p>The GNU make manual describes in chapter 4.14 "Generating Prerequisites Automatically" a methodology to automate this procedure. The procedure starts with the generation of a <code>*.d</code> file for each source file. I quote:</p> <blockquote> <p>For each source file <strong>name.c</strong> there is a makefile <strong>name.d</strong> which lists what files the object file <strong>name.o</strong> depends on.</p> </blockquote> <p>The manual proceeds:</p> <blockquote> <p>Here is the pattern rule to generate a file of prerequisites (i.e, a makefile) called <strong>name.d</strong> from a C source file called <strong>name.c</strong> :</p> </blockquote> <pre><code> %.d: %.c @set -e; rm -f $@; \ $(CC) -M $(CPPFLAGS) $&lt; &gt; $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' &lt; $@.$$$$ &gt; $@; \ rm -f $@.$$$$ </code></pre> <p>Sadly, the manual does not explain in detail how this rule actually works. Yes, it gives the desired <strong>name.d</strong> file, but why? The rule is very obfuscated..</p> <p>When looking at this rule, I get the feeling that its recipe will only run smoothly on Linux. Am I right? Is there a way to make this recipe run correctly on Windows as well?</p> <p>Any help is greatly appreciated :-)</p>
0
How to redirect HTTPS non-www to HTTPS www using .htaccess?
<p>When I visit my site at <a href="https://example.com" rel="noreferrer">https://example.com</a>, my browser responds with ERR_CONNECTION_REFUSED. Note that the following all work:</p> <ul> <li><a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li> <li><a href="http://example.com" rel="noreferrer">http://example.com</a> redirects to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li> <li><a href="http://www.example.com" rel="noreferrer">http://www.example.com</a> redirects to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li> </ul> <p>How can I redirect <a href="https://example.com" rel="noreferrer">https://example.com</a> requests to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a> using .htaccess?</p> <p>I've tried the following which doesn't seem to work:</p> <pre><code>// .htaccess RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] </code></pre>
0
creating a temporary file in memory and using it as input file of a command
<p>There is a command pdflatex, which I want to use in my bash script. It takes as input a filename on which content it will work. </p> <p>Now I have an algorithms that looks as follows:</p> <pre><code>for stuff in list of stuff; do echo "${stuff}" &gt; /tmp/tmpStuff pdflatex /tmp/tmpStuff done </code></pre> <p>Now this works as expected. But I was thinking I could speed that up by doing less disk I/O(as > redirection writes to a file). I wish I could write something like <code>echo "$stuff" | pdflatex /tmp/tmpStuff</code> but pdflatex uses a file and not stdin as its input. Is there any way of keeping <code>"$stuff"</code> in memory and passing it to pdflatex as a sort of file?</p> <p>TLDR: I would be happy if I could create a temporary file which could be named and be in memory.</p>
0
Regular Expression to find string starts with letter and ends with slash /
<p>I'm having a collection which has 1000 records has a string column.</p> <p>I'm using Jongo API for querying mongodb.</p> <p>I need to find the matching records where column string starts with letter "AB" and ends with slash "/"</p> <p>Need help on the query to query to select the same.</p> <p>Thanks.</p>
0
ASP.NET Core Request Localization Options
<p>Here is my custom request culture provider which returns "en" as a default culture if no culture specified in url (for example <a href="http://sypalo.com/ru" rel="noreferrer">http://sypalo.com/ru</a> or <a href="http://sypalo.com/en" rel="noreferrer">http://sypalo.com/en</a>). My idea to show website on that language which is default in user's browser, so I'm looking a way how to determine it and return it instead of: return Task.FromResult(new ProviderCultureResult("en", "en"));</p> <pre><code>services.Configure&lt;RequestLocalizationOptions&gt;(options =&gt; { var supportedCultures = new List&lt;CultureInfo&gt; { new CultureInfo("en"), new CultureInfo("ru") }; options.DefaultRequestCulture = new RequestCulture(culture: "en", uiCulture: "en"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(context =&gt; { var pathSegments = context.Request.Path.Value.Split('/'); if (pathSegments.Count() &gt; 0) if (supportedCultures.Select(x =&gt; x.TwoLetterISOLanguageName).Contains((pathSegments[1]))) return Task.FromResult(new ProviderCultureResult(pathSegments[1], pathSegments[1])); return Task.FromResult(new ProviderCultureResult("en", "en")); })); }); </code></pre>
0
How to style the react-native picker using android styles.xml?
<p>I wanted to know how to set the fontFamily. How to set the color &amp; background color on the Picker.items? </p> <pre><code>&lt;Picker style={styles.picker} // cannot set fontFamily here selectedValue={this.state.selected2} onValueChange={this.onValueChange.bind(this, 'selected2')} mode="dropdown"&gt; &lt;Item label="hello" value="key0" /&gt; // cannot set backgroundColor here &lt;Item label="world" value="key1" /&gt; &lt;/Picker&gt; </code></pre> <p>I <a href="https://github.com/facebook/react-native/issues/9430" rel="noreferrer">posted this on Github</a> and got the answer that only some of the attributes can be set in React Native via the style but some of the more core elements of the picker (like the font used) is driven by native Android. It needs to be done via native android using styles.xml etc. </p> <p>Unfortunately I am not a native android developer so I have trouble understanding the solution. I added the following snippet to /res/values/styles.xml but text color or background of the popup didn't change.</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme. --&gt; &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt; &lt;!-- Customize your theme here. --&gt; &lt;/style&gt; &lt;style name="SpinnerItem"&gt; &lt;item name="android:textColor"&gt;#ffffff&lt;/item&gt; &lt;item name="android:background"&gt;#993399&lt;/item&gt; &lt;/style&gt; &lt;style name="SpinnerDropDownItem"&gt; &lt;item name="android:textColor"&gt;#ffffff&lt;/item&gt; &lt;item name="android:background"&gt;#993399&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>What other changes do I need to make? How to set the fontFamily?</p>
0
How to execute SQL statement in Pipeline script of Jenkins?
<p>I have created on pipeline and I want to execute one sql query in it. I have written following statements(Only two Lines of code, no imports/Class etc.) and throws error while executing it.</p> <pre><code>import groovy.sql.Sql def sql = Sql.newInstance("jdbc:mysql://myIP:3306/dbName", "uname","password", "com.mysql.jdbc.Driver") sql.execute "select count(*) from TableName" </code></pre> <p>I am getting this error</p> <pre><code>org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod groovy.sql.Sql newInstance java.lang.String java.lang.String java.lang.String java.lang.String at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:174) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:142) at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:180) at org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:177) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:91) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15) at WorkflowScript.run(WorkflowScript:3) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79) at sun.reflect.GeneratedMethodAccessor841.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:58) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:277) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:77) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:186) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:184) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Finished: FAILURE </code></pre> <p>Pls help. Thanks in Advance.</p>
0
spark.sql.crossJoin.enabled for Spark 2.x
<p>I am using the 'preview' Google DataProc Image 1.1 with Spark 2.0.0. To complete one of my operations I have to complete a cartesian product. Since version 2.0.0 there has been a spark configuration parameter created (spark.sql.cross Join.enabled) that prohibits cartesian products and an Exception is thrown. How can I set spark.sql.crossJoin.enabled=true, preferably by using an initialization action? <code>spark.sql.crossJoin.enabled=true</code></p>
0
curl: (35) Server aborted the SSL handshake in Mac OS X El Capitan (10.11.4)
<p>When I run this command:</p> <pre><code>git clone &lt;bitbucket repo&gt;.git </code></pre> <p>I get the error:</p> <blockquote> <p>fatal: unable to access '.git/': Server aborted the SSL handshake</p> </blockquote> <p>When I run the command:</p> <pre><code>git --version </code></pre> <p>Output:</p> <blockquote> <p>git version 2.9.2</p> </blockquote> <p>I am unable to understand if the problem is with the <strong>git</strong> installed in my Mac or with my Mac.</p>
0
How to secure generated API documentation using swagger swashbuckle
<p>I have implemented API documentation using swagger swashbukle. Now I want to publish generated documentation as a help file in my website. How to secure this link and publish?</p>
0
python thrift error ```TSocket read 0 bytes```
<p>My python version:2.7.8 <br/> thrift version:0.9.2 <br/> python-thrift version:0.9.2 <br/> OS: centOS 6.8 <br/> My test.thrift file:</p> <pre><code>const string HELLO_IN_KOREAN = "an-nyoung-ha-se-yo" const string HELLO_IN_FRENCH = "bonjour!" const string HELLO_IN_JAPANESE = "konichiwa!" service HelloWorld { void ping(), string sayHello(), string sayMsg(1:string msg) } </code></pre> <p>client.py</p> <pre><code># -*-coding:utf-8-*- from test import HelloWorld from test.constants import * from thrift import Thrift from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol # Make socket transport = TSocket.TSocket('192.168.189.156', 30303) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = HelloWorld.Client(protocol) # Connect! transport.open() client.ping() print "ping()" msg = client.sayHello() print msg msg = client.sayMsg(HELLO_IN_KOREAN) print msg transport.close() </code></pre> <p>server.py:</p> <pre><code># -*-coding:utf-8-*- from test.HelloWorld import Processor from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol from thrift.server import TServer class HelloWorldHandler(object): def __init__(self): self.log = {} def ping(self): print "ping()" def sayHello(self): print "sayHello()" return "say hello from 156" def sayMsg(self, msg): print "sayMsg(" + msg + ")" return "say " + msg + " from 156" handler = HelloWorldHandler() processor = Processor(handler) transport = TSocket.TServerSocket("192.168.189.156", 30303) tfactory = TTransport.TBufferedTransportFactory() pfactory = TBinaryProtocol.TBinaryProtocolFactory() server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory) print "Starting python server..." server.serve() print "done!" </code></pre> <p>My error:</p> <pre><code>ping() Traceback (most recent call last): File "client.py", line 29, in &lt;module&gt; msg = client.sayHello() File "/home/zhihao/bfd_mf_report_warning_service/local_test/test/HelloWorld.py", line 68, in sayHello return self.recv_sayHello() File "/home/zhihao/bfd_mf_report_warning_service/local_test/test/HelloWorld.py", line 79, in recv_sayHello (fname, mtype, rseqid) = iprot.readMessageBegin() File "build/bdist.linux-x86_64/egg/thrift/protocol/TBinaryProtocol.py", line 126, in readMessageBegin File "build/bdist.linux-x86_64/egg/thrift/protocol/TBinaryProtocol.py", line 206, in readI32 File "build/bdist.linux-x86_64/egg/thrift/transport/TTransport.py", line 58, in readAll File "build/bdist.linux-x86_64/egg/thrift/transport/TTransport.py", line 159, in read File "build/bdist.linux-x86_64/egg/thrift/transport/TSocket.py", line 120, in read thrift.transport.TTransport.TTransportException: TSocket read 0 bytes </code></pre>
0
Generate PDF file from html using angular2/typescript
<p>I want to take a part of my HTML template and convert it to PDF file to give the user an option to download it. (After they click a button for example).</p> <p>I found a library called jsPDF, how would I use jsPDF in an Angular2 app (RC4)?</p> <p>thank you</p>
0
How do I apply the style to a TextField in QML? It seems "style" attribute isn't available
<p>I am trying to apply some styles to a new qt 5.7 application I am working on and the following is not working at all. It gives the error: qrc:/SignInView.qml:67 Cannot assign to non-existent property "style" And I can't edit it in design mode for the same reasons.</p> <pre><code>import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.4 Page { id: page1 ColumnLayout { id: columnLayout1 height: 100 anchors.right: parent.right anchors.left: parent.left anchors.top: parent.top Label { text: qsTr("Label") font.pointSize: 16 horizontalAlignment: Text.AlignHCenter Layout.fillWidth: true } Image { id: image1 width: 200 height: 200 Layout.alignment: Qt.AlignHCenter | Qt.AlignTop fillMode: Image.PreserveAspectCrop anchors.horizontalCenter: parent source: "qrc:/qtquickplugin/images/template_image.png" Button { id: button1 text: qsTr("Button") anchors.bottomMargin: 10 anchors.rightMargin: 10 anchors.bottom: parent.bottom anchors.right: parent.right } } Rectangle { id: field1 width: 200 height: 40 color: "#ffffff" Layout.fillWidth: true Label { id: label1 text: qsTr("Full Name") anchors.topMargin: 0 anchors.left: parent.left anchors.leftMargin: 5 anchors.top: parent.top } TextField { style: TextFieldStyle { textColor: "black" background: Rectangle { radius: 2 implicitWidth: 100 implicitHeight: 24 border.color: "#333" border.width: 1 } } } } } } </code></pre> <p>I have being trying to follow this example:</p> <p><a href="http://doc.qt.io/qt-5/qml-qtquick-controls-styles-textfieldstyle.html" rel="noreferrer">http://doc.qt.io/qt-5/qml-qtquick-controls-styles-textfieldstyle.html</a></p> <p>It fails at the style attribute in the Qt Creator giving the error that style doesn't exist. I assume it's something with my libraries not loading or maybe the environment I have setup. I don't have style in buttons or anywhere else either. I assumed if I had the imports it would work but it's not.</p> <p>A related issue on SO is here: <a href="https://stackoverflow.com/questions/24976887/qml-how-to-change-textfield-font-size">QML - How to change TextField font size</a> But here it seems to just work.</p>
0
How can i find admin panel URL of my prestashop
<p>I am new to prestashop. 2 days before i installed <code>prestashop Version 1.6.1.6</code> in my localhost. But now i forgot its admin panel URL. Is there any way to find out the URL. Any one please help me.</p>
0
how to end ng serve or firebase serve
<p>I've been doing web development with Angular2 and have been using both Angular2 and Firebase to run local servers. I haven't been able to find a command similar to typing quit when using Ionic to create a server, so I have to close the terminal tab each time. Is there a way to end the server and get my terminal tab back?</p> <p>Thanks.</p>
0
How to solve NullPointerException void com.google.android.gms.ads.AdView.loadAd(com.google.android.gms.ads.AdRequest) with Butterknife
<p>Actually, I am trying to make an app with free and paid flavors. When I use simple findViewById method to bind then it works fine. But when I trying to add butterKnife, I desperately stuck with butterKnife.</p> <p>I am trying to bind content (such as AdMob OR Button) by butterknife bind in MainActivity.java file. but it shows Nullpointer exception error first it shows on AdMob object nullpointer exception. I run clean project then it shows on button.onClickListener Nullpointer exception. </p> <p>Please help me... </p> <p>Here is the Error: which shows AdMob nullpointerException:</p> <pre><code>09-08 19:04:30.860 19466-19466/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.santossingh.jokeapp.free, PID: 19466 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.santossingh.jokeapp.free/com.santossingh.jokeapp.free.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.loadAd(com.google.android.gms.ads.AdRequest)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.loadAd(com.google.android.gms.ads.AdRequest)' on a null object reference at com.santossingh.jokeapp.free.MainActivity.onCreate(MainActivity.java:62) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  09-08 19:04:35.652 837-2192/system_process E/Surface: getSlotFromBufferLocked: unknown buffer: 0xf2cf6c90 09-08 19:04:56.030 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:06:20.986 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:07:41.011 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:09:01.042 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:10:20.982 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:11:46.019 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:13:06.051 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:14:41.018 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null 09-08 19:16:06.047 837-853/system_process E/BluetoothAdapter: Bluetooth binder is null </code></pre> <p>2-MainActivity.java</p> <pre><code>public class MainActivity extends AppCompatActivity implements AsyncResponse{ @BindView(R.id.avi) AVLoadingIndicatorView avLoadingIndicatorView; @BindView(R.id.button_jokeTeller) Button button_JokeTeller; @BindView(R.id.instruction_TextView) TextView instruction; @BindView(R.id.container) RelativeLayout relativeLayout; @BindView(R.id.adView) AdView adView; @BindView(R.id.progressBar) LinearLayout linearLayout; private InterstitialAd mInterstitialAd; EndpointsAsyncTask endpointsAsyncTask; private static final String JOKE_TAG="joke"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); endpointsAsyncTask = new EndpointsAsyncTask(this); AdRequest adRequestBanner = new AdRequest.Builder().build(); adView.loadAd(adRequestBanner); mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id)); AdRequest adRequestInterstitial = new AdRequest.Builder().build(); mInterstitialAd.loadAd(adRequestInterstitial); button_JokeTeller.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showInterstitial(); } }); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdClosed() { showProgressbar(true); showJoke(); } @Override public void onAdFailedToLoad(int errorCode) { Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { showProgressbar(true); Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show(); } }); } private void showInterstitial() { if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } } public void showJoke(){ endpointsAsyncTask.execute(getString(R.string.keyword)); } @Override public void processFinish(String result) { Intent intent = new Intent(this, JokeActivity .class) .putExtra(JOKE_TAG, result); showProgressbar(false); startActivity(intent); } public void showProgressbar(boolean a){ if(a==true){ relativeLayout.setVisibility(View.GONE); linearLayout.setVisibility(View.VISIBLE); }else{ linearLayout.setVisibility(View.GONE); relativeLayout.setVisibility(View.VISIBLE); } } } </code></pre> <p>3- activity_main.xml file </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0e73a6" android:padding="10dp" tools:context="com.santossingh.jokeapp.free.MainActivity" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"&gt; &lt;LinearLayout android:id="@+id/progressBar" android:layout_width="match_parent" android:gravity="center" android:layout_height="match_parent"&gt; &lt;com.wang.avi.AVLoadingIndicatorView android:id="@+id/avi" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/AVLoadingIndicatorView" android:visibility="visible" app:indicatorName="BallPulseIndicator" /&gt; &lt;/LinearLayout&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/container"&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/instructions" android:textColor="#fff" android:id="@+id/instruction_TextView" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button_jokeTeller" android:layout_below="@+id/instruction_TextView" android:text="@string/button_text" /&gt; &lt;!-- view for AdMob Banner Ad --&gt; &lt;com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" ads:adSize="BANNER" ads:adUnitId="@string/banner_ad_unit_id"/&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>4- manifest file </p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;application&gt; &lt;activity android:name="com.santossingh.jokeapp.free.MainActivity" &gt; &lt;!-- This meta-data tag is required to use Google Play Services. --&gt; &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN"/&gt; &lt;category android:name="android.intent.category.LAUNCHER"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent"/&gt; &lt;/manifest&gt; </code></pre>
0
Bind Vue on body or others element
<p>I've seen many times Vue instance is bind on <code>body</code> tag. Other times this is bind on a <code>div id</code></p> <p>I'm asking when i should use <code>body</code> tag or an <code>id</code> tag (that limit the scope of the Vue instance).</p> <p>Two examples:</p> <pre><code>new Vue({ el: 'body' }); </code></pre> <p>OR</p> <pre><code>new Vue({ el: '#a-div' }); </code></pre>
0
What is the difference between physical and logical backup?
<p>I was reading about backup. I understood what physical backup is. But I am not able understand what logical backup is? how does it work? </p> <p>Pictorial representation of the working would help. </p> <p>Thanks in advance </p>
0
Using PyWinAuto to control a currently running application
<p>Using the following code I can find that the currently running window I want to connect is named "Trade Monitor" how do i successfull connect to it? Using the app.start_ method does not work.</p> <pre><code>from pywinauto import application app=application.Application app.findwindows #prints all windows running on machine app.window("Trade Monitor") #error </code></pre>
0
pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts
<p>I'm trying to dump my pg db but got these errors please suggest</p> <pre><code>pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts pg_dump: [archiver (db)] query was: LOCK TABLE public.abouts IN ACCESS SHARE MODE </code></pre>
0
PyQt5 not finding installed Qt5 library
<p>On <code>Ubuntu 16.0.4</code>, I am trying to run <a href="https://stackoverflow.com/a/30144171/943773">this PyQt5 script</a>, and I have the distributed packages for <code>Qt5</code> (via <code>apt</code>) and <code>PyQt5</code> (via <code>pip3</code>) installed.</p> <p><strong>Error:</strong></p> <p><code>sudo ./video_qt.py </code></p> <blockquote> <p>Traceback (most recent call last): File "./video_qt.py", line 8, in from PyQt5 import QtWidgets, QtCore ImportError: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5' not >found (required by /usr/local/lib/python3.5/dist-packages/PyQt5/QtWidgets.so)</p> </blockquote> <p><strong>But it is there:</strong></p> <p><code>ls /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5</code></p> <blockquote> <p>/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5</p> </blockquote> <p>What could be going on here?</p>
0
Angular 2 - ngFor display last 3 items in array
<p>got an array with many projects and i want to display the last 3 projects.</p> <p>got in my html</p> <pre><code> &lt;li *ngFor="let project of projects;"&gt; &lt;h2&gt;{{ project.name }}&lt;/h2&gt; &lt;p&gt;{{ project.meta_desciption }}&lt;/p&gt; &lt;/li&gt; </code></pre> <p>it s displaying all the project now (over 20). how can i display only the last 3? I think i need to use "last" somewere in my code, but can't figure it out <a href="https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html" rel="nofollow">https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html</a></p>
0
Angular2 RC5 how to properly configure test module
<p>I'm updating my unit tests for Angular2 RC5. The <a href="https://github.com/angular/angular/blob/master/CHANGELOG.md#breaking-changes" rel="noreferrer">changelog</a> notes the following breaking change: </p> <blockquote> <p><code>addProviders</code> [is deprecated], use <code>TestBed.configureTestingModule</code> instead</p> </blockquote> <p>But this seems to take error only when attempting to include a service in a test. Where my unit test used to do the following: </p> <pre><code>beforeEach(() =&gt; addProviders([ MyService, MockBackend, ... ])); </code></pre> <p>it should now configure the test module:</p> <pre><code>TestBed.configureTestingModule({ providers: [ StoryService, MockBackend, ... ] }); </code></pre> <p>But that now throws an error </p> <blockquote> <p>Service: MyService encountered a declaration exception FAILED</p> <p>Error: Cannot configure the test module when the test module has already been instantiated. Make sure you are not using <code>inject</code> before <code>TestBed.configureTestingModule</code>.</p> </blockquote> <p>I have checked that <code>inject</code> isn't been called before the <code>configureTestingModule</code>. This doesn't affect any other component/directive tests, they seem to pass just fine. How can I resolve this error for unit testing a service with RC5? I realize that I may have to wait until the the testing documentation are updated for RC5 but any insight into possible solutions would be much appreciated. </p>
0
What is assertThat() method?
<p>What is <code>assertThat()</code> method? How can it be useful? </p> <p>I had seen this method in mapreduce program in hadoop. Can anyone explain brief about it?</p>
0