天道酬勤,学无止境

技术分享

Google Cloud SQL with SSL from Compute Engine and/or External Network

Question I'm trying to connect to an Google Cloud SQL (mysql) instance using SSL. I've enabled two IP addresses and a user with remote access permissions from those IP addresses. I have also generated the certificate files from Google's Developer Console. client-key.pem client-cert.pem server-ca.pem Using this command from each of the two enabled IP addresses I successfully make a connection. mysql --ssl-ca=server-ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem --host=xxx.xxx.xxx.xxx --user=username --password Since the mysql client works I know my firewall settings, users, certs

2021-09-21 19:15:09   java   mysql   google-app-engine   ssl

spark-submit no class found - htrace

Question I am trying to run the Spark example code HBaseTest from command line using spark-submit instead run-example, in that case, I can learn more how to run spark code in general. However, it told me CLASS_NOT_FOUND about htrace since I am using CDH5.4. I successfully located the htrace jar file but I am having a hard time adding it to path. This is the final spark-submit command I have but still have the class not found error. Can anyone help me with this? #!/bin/bash export SPARK_HOME=/opt/cloudera/parcels/CDH/lib/spark /bin/bash $SPARK_HOME/bin/spark-submit \ --master yarn-client \ -

2021-09-21 19:15:04   apache-spark   hbase

Where do I put the .tld file so that the resulting JAR file built with maven2 is properly packaged?

Question I currently have the following directory structure for my code: src |-- main | `-- java | `-- com | `-- upthescala | `-- tags | `-- ViewProtectTag.java |-- test |-- pom.xml |-- .project |-- .classpath `-- .hgignore I want to include a tld file for my JSP tag, and I'm not sure where to package it. My initial thought is to add a src/main/resources directory and put META-INF/viewprotect.tld in there. Answer1 My initial thought is to add a src/main/resources directory and put META-INF/viewprotect.tld in there And that's a good initial thought.

2021-09-21 19:14:58   java   jsp   maven-2   web-applications   jsp-tags

Testing with protractor using ui-select

Question I am trying to test an ui-select with protractor. In this ui-select I have a list of countries. My html looks like: <ui-select ng-model="datiAnagrafici.countryOfBirth" name="countryOfBirth" theme="bootstrap" reset-search-input="true" append-to-body="true" required blur> <ui-select-match placeholder="paese di nascita">{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="country.code as country in countries | filter: {name:$select.search}"> <span ng-bind-html="country.name"></span> </ui-select-choices> </ui-select> My page object looks like: this.country = element(by

2021-09-21 19:14:53   javascript   angularjs   testing   protractor   angular-ui-select

Postgresql & psycopg2: database does not exist

Question I am trying to establish a connection to a database like this: psycopg2.connect(database="movies", user="lfcj", host="127.0.0.1"); my pg_hba.conf file has a line: TYPE __ DATABASE___USER__ADDRESS___METHOD local all lfcj peer I am trying to use peer identification, and my SO user name is also lfcj. When I log in postgresql like this, grant all privileges to lfcj, and run \list : psql lfcj -h 127.0.0.1 -d movies Enter password: 'myPassword' psql (9.4.1) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. movies=#

2021-09-21 19:14:48   python   database   postgresql   postgresql-9.1   psycopg2

Table without lock won't query unless nolock hint included

Question Microsoft SQL Server 2008 R2 I have a table that currently can not be queried on but seems to not have a lock against it. Doesn't return: SELECT * FROM myTable Does return: SELECT * FROM myTable with (nolock) Inserts into the table also fail. When I run sp_lock, I don't find any instances of locks on myTable. When I run the "Resource Locking Statistics by Object" report, I don't see any locks for myTable. What other possibilities could there be that would keep a table from being acted upon? Thanks. Answer1 Run sp_who2 and look at all the spids. See if you still have a connection to

2021-09-21 19:14:42   sql-server   locking

dplyr on subset of columns while keeping the rest of the data.frame

Question I am trying to use dplyr to apply a function to a subset of columns. However, in contrast to the code per below, I am trying to implement this while keeping all columns in the data-frame. Currently, the resulting data-frame only keeps the selected columns. I can use a remove-and-cbind construction to merge these columns back into the original dataframe, but I was wondering if there is a way to do this directly in dplyr? I have tried to move the select function inside the mutate function, but was not able to make this work yet. require(dplyr) Replace15=function(x){ifelse(x<1.5,1,x)} dg

2021-09-21 19:14:36   r   dplyr

What is the difference between on_data and on_status in the tweepy library?

Question I just started using tweepy library to connect with streaming api of twitter. I encountered both on_status() and on_data() methods of the StreamListener class. What is the difference? Total noob here! Answer1 on_data() handles: replies to statuses deletes events direct messages friends limits, disconnects and warnings whereas, on_status() just handles statuses. source: https://github.com/tweepy/tweepy/blob/78d2883a922fa5232e8cdfab0c272c24b8ce37c4/tweepy/streaming.py Answer2 If you're only concerned with tweets, use on_status(). This will give you what you needed without the added

2021-09-21 19:14:32   python   twitter   tweepy

Determine data type of a column in SQLite

Question I'm working on an Android App where the user has different options for sorting the displayed data that comes from the database. Currently my orderBy string that I pass to Androids query() method looks like this: "LOWER("+columnName+") ASC" The problem with this is that if the data type in the column specified by columnName is integer, calling LOWER() on it will cause it to be sorted alphabetically, i.e. based only on the leftmost digit, which of course doesn't make any sense for numeric data. Hence I only want to apply LOWER() if the data type of the column is not integer. What I have

2021-09-21 19:14:27   android   sqlite   case   types

C# MouseKeyHook key suppression problems

Question I've been using the MouseKeyHook NuGet package for a project where a single key press needs to be monitored to provide explicit functionality. The prototype application I have written, checks the required key is pressed and then sets the Handled property to true. The key I'm testing with is LaunchApplication2, now the problem I'm having is the key press isn't always surpressed, at the moment if Microsoft Word or Excel is in focus then the calculator launches! The code is as follows: /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow

2021-09-21 19:14:22   c#   mousekeyhook