Posts

Showing posts from July 9, 2018

What is the configurations for enabling `ehcache replication`?

What is the configurations for enabling `ehcache replication`? I have a project that used JPA and Hibernate in DataAccessLayer with OraclDB and WebLogic application server. Also, I provided second-level-cache through ehcache as following configs: second-level-cache ehcache ehcache.xml <ehcache> <diskStore path="java.io.tmpdir"/> <defaultCache> maxEntriesLocalHeap="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" maxEntriesLocalDisk="10000000" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU"/> <persistence strategy="localTempSwap" </defaultCache> </ehcache> persistence.xml <persistence-unit name="datasource1" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>my_datasource

returning subscriber in RxJava after storing data fetch from webservice

returning subscriber in RxJava after storing data fetch from webservice I am trying to call the web service to fetch the data and storing it into database using following code. I have created a separate class to perform following operation. Now , the issue is i want to notify my activity when i successfully fetch and store data in database. if some error occurs then i want to show that on UI itself. somehow i am able to write a code to fetch the data using pagination but not sure how would i notify UI where i can subscribe catch the update related to progress and error if any. public Flowable<Response> getFitnessData() { Request request = new Request(); request.setAccess_token("d80fa6bd6f78cc704104d61146c599bc94b82ca225349ee68762fc6c70d2dcf0"); Flowable<Response> fitnessFlowable = new WebRequest() .getRemoteClient() .create(FitnessApi.class)

Hyperledger Composer Rest Server connection with Cloudant

Hyperledger Composer Rest Server connection with Cloudant I'm trying to use Cloudant NoSQL DB as a persistent data source for my blockchain identities in my composer rest server. I have the composer-rest server setup in multiuser mode and is using google OAuth for authentication. I have looked at this question (Hyperledger Composer Rest Server connection with Cloudant NoSQL DB) but I'm still experiencing problems. If I do a composer card list in my terminal I can see the cards in my cloudant database. However, if I do a http get method from my rest server it returns an empty array. I have the COMPOSER_DATSOURCES variable set to {"db": { "name": "db", "connector": "cloudant", "username": "83bcdcfc-327b-xxxxxxxxxxxxx4e0ba4a9-bluemix", "password": "01e6d7xxxxxxxxxxxxxxxxb29adcc85ab35ce9ba", "database": "wallet" } } In cloudant, I have one database called wallet

Isalpha() function with while loop c++

Image
Isalpha() function with while loop c++ I want to create a while loop that will allow me to input a mix of string numbers until I input string that contains all characters. while Also, I have a problem with output int main() { string name; string temp; cout << "Enter your name:"; cin >> name; cout << endl; for(auto a:name) { if(isalpha(a)) { temp=name; } else { while(!isalpha(a)) { cout << "Enter your name without digit:"; cin >> name; cout << endl; } } } cout << temp << endl; } 1 Answer 1 for(auto a:name) { This is a loop over the characters in name , as entered after the prompt "Enter your name:" . The current character is assigned to a . name "Enter your name:" a if(is

XPATH syntax validator in Python

XPATH syntax validator in Python I develop a crawler with many actions. Many xpaths are involving and for this reason I use a json file for storing. Then crawler start running I would like to make a basic syntax check (before xpath usage) on xpaths and raise error for invalid xpaths. for example: xpath1 = '//*[@id="react-root"]/section' xpath2 = '//*[[@id="react-root"]/section' xpath3 = '//*[@id="react-root"]section' from these xpaths only xpath1 is valid is there any module or regex which does this kind of validation? 1 Answer 1 You can compile the xpath strings with lxml.etree.XPath which will raise an exception if the syntax is incorrect: lxml.etree.XPath >>> import lxml.etree >>> lxml.etree.XPath('//*[@id="react-root"]/section') //*[@id="react-root"]/section >>> lxml.etree.XPath('//*

Exception member class OOP

Exception member class OOP I have met the following concept in the production code: class A { public: class Exception : public std::exception {/* ... */}; //... }; Nobody can give me a clear answer why it is like this. My question is whether this approach is in line with SOLID rules? I think that would be better if this exception class is located outside the class A and is injected while creating the instance of A. Design principles are important, but they aren't followed "because they are design principles". They are followed because they accomplish something. What would injecting the exception object upon construction accomplish? Now the class should manage this objects lifetime. What if an error state is never encountered, and it's never thrown? – StoryTeller Jul 2 at 6:16

JMeter fails on beanshell imports

Image
JMeter fails on beanshell imports I had been using Beanshell pre-processor to add custom cookies created through javascript. While it used to work perfectly earlier, with the same line of codes I started to recieve errors in my pre-processor. ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.CookieManager; import org.apache. . . . '' : TargetError WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.CookieManager; import org.apache. . . . '' : TargetError The lines of code is as per suggestion provided in https://javaworks.wordpress.com/2011/08/05/setting-cookie-in-jmeter/ import org.apache.jmeter.protocol.http.control.CookieManager; import org.apache.jmeter.protocol.http.control.

Creating React component vs using CSS styling

Creating React component vs using CSS styling I have created a tab menu using CSS styling that I use in several different spots in my ReactJS app. .tab { overflow: hidden; border: 1px solid #ccc; background-color: #f1f1f1; margin: 0; padding: 0; } .tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; } .tab button:hover { background-color: #ddd; } .tab button:disabled { background-color: #ccc; cursor: default; } .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top:none; } This is in a index.css file that sits with all my .js files. Within my React code I use it like this, as an example: index.css .js <table><tbody> <tr className="tab"><td> <button onClick={() => this.openTab(0)}>Tab 1</button> <button onClick={() => this.op

Getting repeated results in SVM in R

Getting repeated results in SVM in R I'm trying to predict using SVM from R package "e1071". But I'm getting repeated values as predicted outcomes. I have run this several times but getting same results. Please help me to find what wrong is going here. library(e1071) tuneResult <- tune(svm,y~.,data=calibration.data,ranges = list(epsilon = seq(0,1,0.1), cost = 2^(2:9))) tunedModel <- tuneResult$best.model predict.data<-predict(tunedModel,prediction.data) predict.data 2006-03-01 2006-04-01 2006-05-01 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01 2006-12-01 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 0.05798676 2007-06-01 2007-07-01 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01 2008-02-01 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01 0.05798

Get the field that is going to be edited in kendo beforeedit event

Get the field that is going to be edited in kendo beforeedit event I have a dependent column that needs to be editable based on value of the first cell. How can do this using the beforeedit event of kendo grid. I wish to avoid closing the cell in edit event of kendo grid. Below is a sample https://dojo.telerik.com/enodEwub 1 Answer 1 In order to achieve this when "Inline" edit mode is used you can use the Grid's cancelRow() method. $("#grid").kendoGrid({ //.... edit: onEdit }); function onEdit(e) { //your custom logic $('#grid').data("kendoGrid").cancelRow(); } Hope that helps! grid seems to break. dojo.telerik.com/enodEwub – Jose Tuttu Jul 2 at 11:40 Also, cancelRow is sup

ECharts: Disable default click action on legends

ECharts: Disable default click action on legends I'm trying to use ECharts to render a simple doughnut chart which I've been able to do. I've noticed by default that the legend will hide the data item on the chart if it is clicked. I want the user to be able to select the legend to do something (fire an event) which I can do using the events available (https://ecomfe.github.io/echarts-doc/public/en/api.html#events.legendselected) however I want to prevent the default behaviour of hiding/showing the data item on the chart. In the documentation there is mention of a property on the legend called selectedMode (https://ecomfe.github.io/echarts-doc/public/en/option.html#legend.selectedMode), which prevents the toggling of the series, but it also stops the legend from being selectable entirely. I've also tried returning false on the events fired for legendselected and legendunselected but to no success. Has anyone found a way of stopping this behaviour? I'd appreciate any

does not have valid android:name [duplicate]

<activity> does not have valid android:name [duplicate] This question already has an answer here: I have trouble with the INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error where I looked into logcat where the following was my error: W/PackageParser: /data/app/vmdl-1226238136.tmp (at Binary XML file line #27): does not have valid android:name I looked into my manifest code and after searching through a lot of forums (adding . before my activity name, adding big letters and etcetera) it does not work. What is wrong with my activity name? Down below is my manifest code; <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="R.ekryt"> <uses-feature android:name="android.hardware.bluetooth" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <

R Extract values from data frame with vectors

Image
R Extract values from data frame with vectors I hope my question is not a duplicate, but I really couldn't find what I need. I dived in dplyr and even did the data.table course from DataCamp, but I can't fix it. Maybe overlooking something? I have this df: set.seed(1964) df<-data.frame(id = c( "XEY", "NZH", "DYE", "JNF", "LHH", "WNB"), q_1 = sample(5,6, replace = TRUE), q_2 = sample(5,6, replace = TRUE), q_3 = sample(5,6, replace = TRUE), q_4 = sample(5,6, replace = TRUE), q_5 = sample(5,6, replace = TRUE)) So my df looks like this: Next I have two vectors with id's (row-indicators) and q's (question numbers) like these: id <- c("XEY", "DYE", "JNF", "DYE", "XEY", "LHH", "WNB", "JNF" ) question <- c("val_1", "val_1","val_3","val_3"

AWS SNS HTTP subscription is not calling endpoint

AWS SNS HTTP subscription is not calling endpoint I have deployed AWS SNS using Localstack in my dev machine and now I'm trying to consume messages I'm emitting from awslocal CLI (basically it's a aws against my local Localstack infra) awslocal aws First, I have created a topic: $ awslocal sns create-topic --name my-topic Then, I've created a HTTP subcription against http://localhost:8080/sns/publish : http://localhost:8080/sns/publish $ awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:123456789012:my-topic" --protocol http --notification-endpoint http://localhost:8080/sns/publish I have a server running at localhost in port 8080 with a POST /sns/publish endpoint. It is supposed to be called in order to confirm the subscription. But it's never called. localhost 8080 /sns/publish I have some clues. I have deployed Localstack using Docker. After checking the container logs, I have seen this error: 2018-07-02T10:20:03:INFO:werkzeug: 127.0.0.1 -

Firebase “User is missing a constructor with no arguments”

Firebase “User is missing a constructor with no arguments” I am trying to retrieve my user details from the /User/ tree i have in Firebase. I have the following User object : public class User { private String name; private String email; private FirebaseUser firebaseUser; private String lastOnline; private LatLng latLng; private ArrayList<SwapLocation> locations; public User(){ } public String getName(){ if(firebaseUser.getDisplayName() != null && !firebaseUser.getDisplayName().equals("")) return firebaseUser.getDisplayName(); if(name != null && !name.equals("")) return name; return ""; } public void setName(String name){ this.name = name; } public String getEmail(){ if(firebaseUser.getEmail() != null && firebaseUser.getEmail().equals("")) return firebaseUser.getEmail(); if(email != nul

How do I display a double in an af:inputText rounded down to an integer?

How do I display a double in an af:inputText rounded down to an integer? I have an af:inputText which displays a double value. For example: 17555.8 af:inputText <af:inputText value="#{bindings.regnum.inputValue}" disabled="true" simple="true" id="it4"/> I want to view this data as an integer: 17555. How can I achieve that? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

The activity is not responding

Image
The activity is not responding I have been working on developing an application which needed login and signup screen. My register activity is not working properly. The application is unable to take user from the start screen to the register activity, first the error arose of absence of intent filter then I included the intent filter in the manifest file but it seems like my app is ignoring the register activity. I am attaching both manifest file and the activity code please have a look. Don't use images to share code, use code snippet. – tahsinRupam Jul 2 at 10:39 2 Answers 2 As images are suggesting there are two LAUNCHER Activities in your AndroidMenifest.xml file, so you will have to make one of them as DEFAULT category . LAUNCHER AndroidMenife

Shell script: while variable concatenation

Shell script: while variable concatenation This is my straightforward function: generate_post_data() { cat <<-EOF {"stringData": {}} EOF } This is my other function: generate_curl_body() { template=$(generate_post_data $secret_id) echo "$template" echo "$KVS_VARIABLES" | while read -r key value do template=$(echo "$template" | jq ".stringData += { "$key" : "$value" }") echo $template done } The output is: #Before while -> {"stringData": {}} #1 iteration -> { "stringData": { "VAR1": "VAL1" } } #2 iteration -> { "stringData": { "VAR1": "VAL1", "VAR2": "VAL2" } } #3 iteration -> { "stringData": { "VAR1": "VAL1", "VAR2": "VAL2", "VAR3": "VAL3" } } #After while -> {"stringData": {}} Why template variable is not