Posts

Showing posts from September 14, 2018

Regex to get method parameter name

Image
Clash Royale CLAN TAG #URR8PPP Regex to get method parameter name Need regular expression to replace only parameter name. By program i am able to fetch the parameter name but while replacing it using regular exression , its failing when we have both parameter class and parameter name as same. like below method: getCustomerCyclesListInfo( CustomerCyclesListInfo CustomerCyclesListInfo, CustomerCyclesListInfo CustomerCyclesListInfo) getCustomerCyclesListInfo( CustomerCyclesListInfo CustomerCyclesListInfo, CustomerCyclesListInfo CustomerCyclesListInfo) i tried with below regex but its matching all four in above : (?<!()b(CustomerCyclesListInfo)b (?<!()b(CustomerCyclesListInfo)b i want that word starting with ( (opening parenthesis) space or ,(coma) space should not be considered while capturing. 1 Answer 1 Try this: bCustomerCyclesListInfo(?= *[,)]) See live demo. can u please also update the above regex if i have space after the parameter name also , as its not matchin...

Stuck wth issue: nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

Image
Clash Royale CLAN TAG #URR8PPP Stuck wth issue: nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V Trying to integrate JPA hibernate and SpringBoot Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 10:49:55,001 ERROR [org.springframework.boot.SpringApplication] (ServerService Thread Pool -- 2178) Application startup failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1634) [spring-beans-4.3.18.RELE...

Azure B2C AD: Is the email address mandatory for Local Accounts identity providers based on Username?

Image
Clash Royale CLAN TAG #URR8PPP Azure B2C AD: Is the email address mandatory for Local Accounts identity providers based on Username? Am I missing something? It does not seem to be possible to set it up so that the email address is not required (or not even prompted for at all) during sign-up? You can only disable the email verification. We may not allow the users to enter an email address at all. They must register with a username only. Surely this must be supported? I have redone the entire process over from scratch twice now following all the documentation I could find on the topic. But the outcome remains the same. I start by creating a new B2C tenant and I ensure that under Identity Providers, only "Username" is selected as the "Local Accounts". Then I go to "Sign-up or sign-in policies" and create a custom template, then click on edit. Then I ensure that the Identity Providers is set to only the "User ID signup" (and Local Account), and ...

How to add Pass statement in Protractor-Jasmine-typescript html report log

Image
Clash Royale CLAN TAG #URR8PPP How to add Pass statement in Protractor-Jasmine-typescript html report log I am using Protractor, typescript and jasmine html reporter for logging. Right now my log is displayed as below.But i want to add log for which steps are passed. Currently it is just showing passed for Passed steps. browser.getCurrentUrl().then(function(value) if(/report/.test(value)===true) fail("Result: URL doesnt works-FAIL"); else pass("Result: URL works-PASS"); ); I also read somewhere like , we can use because as step explanation but i am not able to add because as below - expect(userlist.getUsers().length).toEqual(1).because('when a user object is removed, the list should equal 1'); I also tried this - var since= require('jasmine2-custom-message') since(function() return 'Actual Message' + ' =/= ' + 'Expected Message'; ).expect(page.getTitle()).toBe('xyyz'); Also tried this - expect(page.getTi...

How do I target a specifc folder in a url path using regex and window.location.href.indexOf()?

Image
Clash Royale CLAN TAG #URR8PPP How do I target a specifc folder in a url path using regex and window.location.href.indexOf()? I am doing an a/b test that targets an element which has the same class name throughout different levels of a website: e.g url: www.sitename.com/service-provided/state/region/city. When I get to the city level page I dont want my code to run for the specific element. There are 100's of different cities so a list of url's to exclude is not the desired approach. Is there a way using window.location.href.indexOf() and regex to only target the first three folders of the path? Below is an example of what I am trying to achieve, If the url has any values in the first 3 folders of the path,only then run the code and not if the path goes into the 4th (city) folder. $(document).ready(function () if (window.location.href.indexOf("?/(.*)/(.*)/(.*)") > -1) $(".className").css("padding-right":"5%"); ); I'm open...

How can I convert this row form into JSON while pushing into kafka topic

Image
Clash Royale CLAN TAG #URR8PPP How can I convert this row form into JSON while pushing into kafka topic I am using a Spark application for processing textfiles that dropped at /home/user1/files/ folder in my system and which map the comma separated data that present in those text files into a particular JSON format. I have written following python code using spark for doing the same. But the output that comes in Kafka will look like as follows Row(Name=Priyesh,Age=26,MailId=priyeshkaratha@gmail.com,Address=AddressTest,Phone=112) Python Code : import findspark findspark.init('/home/user1/spark') from pyspark import SparkConf, SparkContext from operator import add import sys from pyspark.streaming import StreamingContext from pyspark.sql import Column, DataFrame, Row, SparkSession from pyspark.streaming.kafka import KafkaUtils import json from kafka import SimpleProducer, KafkaClient from kafka import KafkaProducer producer = KafkaProducer(bootstrap_servers='server.kafka:9...

put an attribute on an html tag using an * ngFor

Image
Clash Royale CLAN TAG #URR8PPP put an attribute on an html tag using an * ngFor I'm doing an app using IONIC, but it's based on angular. I simply want that if one element is the last one: (item==myArray.length?'navPop':'') add the navPop attribute, otherwise do not add it. (in IONIC, navPop attribute is, when you click, it returns to a preview that is what I need). I'm doing this, but I get errors: this.myArray=[1,2,3,4]; <ion-slide *ngFor="let item of myArray" text-center item==myArray.length?'navPop':''> I hope this result (if is my last element): <ion-slide text-center></ion-slide> <ion-slide text-center></ion-slide> <ion-slide text-center></ion-slide> //last element with navPop <ion-slide text-center navPop></ion-slide> how can I fix it, thanks? 3 Answers 3 You can use the attr binding, like so: attr <ion-slide *ngFor="let item of myArray" text-cente...

MessageBox, more than one when executing code

Image
Clash Royale CLAN TAG #URR8PPP MessageBox, more than one when executing code I am creating a code in Visual Studio C# and when I execute my code I get to a section where I have a Messagebox pop up to confirm if you want to change a value. At this point a 2nd MessageBox will proceed the first. Does anyone have any ideas on how I can eliminate that 2nd box? For note: I had this error in a past code I made but it would continuously increase the number of boxes every time I reset the code because the control was called in one of my Initialize methods that got called on start, the error I am having is always two MessageBoxes consistently EDIT: It's the same messagebox that's showing up directly after itself. Example of code where I use the MessageBox and get the problem: private void comboBoxReprint_SelectedIndexChanged(object sender, EventArgs e) DialogResult result = MessageBox.Show( "Change Reason to: rn" comboBoxReprint.Text + "rnrn" + "Confirm?...

Gsub a every element after a keyword in R

Image
Clash Royale CLAN TAG #URR8PPP Gsub a every element after a keyword in R I'd like to remove all elements of a string after a certain keyword. Example : this.is.an.example.string.that.I.have Desired Output : This.is.an.example I've tried using gsub('string', '', list) but that only removes the word string. I've also tried using the gsub('^string', '', list) but that also doesn't seem to work. gsub('string', '', list) gsub('^string', '', list) Thank you. 3 Answers 3 Following simple sub may help you here. sub sub("\.string.*","",variable) Explanation: Method of using sub sub sub(regex_to_replace_text_in_variable,new_value,variable) Difference between sub and gsub : sub gsub sub : is being used for performing substitution on variables. sub gsub : gsub is being used for same substitution tasks only but only thing it will be perform substitution on ALL matches found though...

Understanding decorators in Django

Image
Clash Royale CLAN TAG #URR8PPP Understanding decorators in Django I'm currently trying to build my own decorator for function based views. I understood the basic concept behind decorators but I'm still struggling to fully understand whats happening "behind the scenes". I've this example decorator. Could someone explain me what happens here or how it works? And why do we need so many functions here? def active_user_required(): def decorator(function): def wrapper(request, *args, **kw): if request.user.is_active: return function(request, *args, **kw) else: raise PermissionDenied() return wrapper return decorator This is unnecessarily complicated. The main reason to have three levels of function is if the decorator itself takes parameters, but that's not the case here. The middle layer could be dropped. – Daniel Roseman Aug 8 at 18:13 Note though that decorators are a general Python thing; there is nothing specific to Django. – Daniel Rosem...

swift: animation with buttons

Image
Clash Royale CLAN TAG #URR8PPP swift: animation with buttons I use this code to create animation with button: func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) switch indexPath.section case 0: self.button1.constant = self.button2.constant case 6: self.button3.constant = self.button4.constant default: self.button1.constant = 0 self.button3.constant = 0 UIView.animate(withDuration: 1.0, delay: 0.0, options: , animations: self.view.layoutIfNeeded() ) I have collectionView . But with my buttons my collectionView animated too. How to do that I have animation only with button? collectionView collectionView This code doesn't work: UIView.animate(withDuration: 1.0, delay: 0.0, options: , animations: self.myButton.layoutIfNeeded() self.myButton1.layoutIfNeeded() ) call layoutIfNeeded on your cell instead of self.view – Shahzaib Qureshi Aug 8 at 18:25 cell.layoutIfNeeded() ...

Nested classes are not serializable in python when trying JSON dump

Image
Clash Royale CLAN TAG #URR8PPP Nested classes are not serializable in python when trying JSON dump I currently have two classes in Python like these ones class person: age="" name="" ranking = def addRanking(): #Do Whatever treatment and add to the ranking dict class ranking: semester = "" position = "" gpa = "" I have my list of person as a dictionary called dictP json.dumps() this dictionary but it seems that it doesn't work. Here is my function to dump to JSON dictP json.dumps() def toJson(): jsonfile = open('dict.json', 'w') print(json.dump(listP, jsonfile)) I get the famous: is not JSON serializable. Would you know what I can do to help this problem. I thought that having two dictionaries (which are serializable) would avoid this kind of issue, but apparently not. Thanks in advance Edit: Here is an example (typed on my phone sorry for typos, I'm not sure it does run but it's so you ge...

Ant pattern matcher starting with and having decimal values

Image
Clash Royale CLAN TAG #URR8PPP Ant pattern matcher starting with and having decimal values I want to do an ant match for initializing a variable as below."version" is input. if version is 1.2.X.X then value should be true (X means anything[1-9]) else value should be false Example : version = 1.3.0.5, value = false version = 1.2.0.5, value = true version = 1.2.5.3, value = true version = 2.1.0.5, value = false <if> <matches string="@VERSION" pattern="^1.2"/> <then> <property name="version.value" value="true"/> </then> <else> <property name="version.value" value="false"/> </else> </if> What should be the pattern to check first 2 digit including '.' [1.2.x.x] 2 Answers 2 I would highly recommend avoiding ant-contrib tasks whenever possible, as they tend to encourage the use of Ant as a programming language, which will often cause problems dow...

Tornado: how to make it to catch changes done to JavaScript?

Image
Clash Royale CLAN TAG #URR8PPP Tornado: how to make it to catch changes done to JavaScript? I'm trying to use Tornado and found that every time when I changed JavaScript or HTML files don't look changed. I have an experience with Node.js and it worked well - if changes were not related with the server side everything updated itself. How to solve this problem? Of course, I can stop the server every time but it's time-consuming and tedious. Thanks. 2 Answers 2 In your project folder where you tornado application is, you can listen for changes using the autoreload module. e.g from os import walk from socket import gethostname from tornado import autoreload from tornado.ioloop import IOLoop from tornado.web import Application from tornado.httpserver import HTTPServer from tornado.web import RequestHandler from tornado.options import define, options, parse_command_line class TestHandler(RequestHandler): def get(self): self.render("index.html") class TestApp...

Time difference between two times

Image
Clash Royale CLAN TAG #URR8PPP Time difference between two times I want to display the difference between two times in hh:mm format. The first time is from a database and the second time is the system time. Time difference is updated every second. How can I do that? Currently I'm using two manual time if this works perfectly then I implement it into my apps. public class MainActivity extends Activity TextView mytext; @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Timer updateTimer = new Timer(); updateTimer.schedule(new TimerTask() public void run() try TextView txtCurrentTime= (TextView)findViewById(R.id.mytext); SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss aa"); Date date1 = format.parse("08:00:12 pm"); Date date2 = format.parse("05:30:12 pm"); long mills = date1.getTime() - date2.getTime(); Log.v("Data1", "...