Tag Archives: replace

Is it possible to edit/replace the com.android.internal.policy.impl.PhoneWindowManager file without building a new version?

Questions: Is it possible to edit or replace com.android.internal.policy.impl.PhoneWindowManager? I have a pine64 a64 mini computer with sopine android 7.0.1 running on it and a hdmi display is its only output. My initial problem was the resolution and the screen rotation which I solved using this threat (connected via adb): https://android.stackexchange.com/questions/117003/allow-rotate-into-portrait-mode-but-do-not-rotate-external-display# The answer to this… Read More »

Replace list iteration logic with lambda expression

Questions: I have below piece of code to iterate through a list, checking for a particular value and then terminating loop. Can you please suggest a better approach using lambda expression if possible? for(InvoiceLine invoiceLine : inputInvoice.getInvoiceLines()) { Object flag = invoiceLine.getTransientField(“ApproveInvoiceLine”); if(flag != null && ((Boolean)flag)) { approveInv = true; break; } } Answers:

Data replacement using MongoReactiveRepository nad project reactor

Questions: I try to replace data from mongo if it’s different than already stored data, and i wrote this code public <T> Mono<Void> replaceObjectsIfNotAlreadyStored(List<T> products, ReactiveCrudRepository<T, String> objRepository) { return objRepository.findAll() .collectList() .filter(productsList -> !areAlreadyInDb(productsList, products)) .flatMap(products1 -> objRepository.deleteAll()). doOnSuccess(products1 -> objRepository.saveAll(products).collectList()); } But when i’am trying to test it @Test public void replaceObjectsIfNotAlreadyStoredNeg() {… Read More »

JQuery .replaceWith Angular2 content

Questions: I am working on a project using both JQuery and Angular2 in order to use a JQuery library. My problem is when it comes to replace DOM element with Angular2 code using JQuery. I am expecting the below code to add Angular code in the DOM element: let myContainer = <HTMLElement>document.querySelector(“.question-text”); myContainer.innerHTML = “<span>{{model?.text}}</span>”;… Read More »

Conditional replacement of a string using regex?

Questions: I need to replace all occurrences of @example/ in a file, unless the complete match is @exapmle/is. Currently I have this code: let updated = s.replace(/@example\//g, replacement); However this will update all occurrences, including the ones with @example/is. How do we exclude the @example/is occurrences in the file? Addendum I’m just pasting in the… Read More »

preg_replace_callback quirk? doesn't match a certain type of string

Questions: Is this some quirk with the preg_replace_callback function or something? The full code is really complex but I’ll post the specific problem here which I found after alot of debugging, a specific type of tag doesn’t get matched at all, any ideas why this could be? preg_replace_callback(‘/(?:<del>(.|\n)*?<\/del>)|(?:<ins>(.|\n)*?<\/ins>)|(?P<DOT>[\s\S])/’, function($match) { //does something and runs fully… Read More »

Is it possible to replace nested loops on different collections with Stream API

Questions: I was wondering if it’s possible to rewrite nested for loops using java.utils.stream in Java 8? Here is a sample data type I’m working with: class Folder { private final String name; private final Integer itemCound; Folder(String name, Integer itemCount) { this.name = name; this.itemCount = itemCount; } public String getName() { return this.name;… Read More »

Replace javascript href content with php link

Questions: I need to replace one link from javascript with php link. javascript line: ‘<a href=”‘ + res.attachment.guid + ‘” target=”_blank”> php : echo ‘<a href=”‘ . wp_get_attachment_url($value->ID) . ‘” target=”_blank”> javascript context: if (res.success) { $(‘.no_file_upload’).remove(); var template = ‘<li class=”attachment-‘ + res.attachment.ID + ‘”>’ + ‘<p>’ + res.attachment.post_title + ‘<span>’ + ‘<a href=”‘… Read More »

Java replaceAll not working

Questions: Map contents: key (#500 – #509); and there values for (Map.Entry<String, Double> entry : values.entrySet()) { if (line.contains(entry.getKey())) { line = line.replaceAll(entry.getKey(), String.valueOf(entry.getValue())); System.out.println(line); } } Original string #102=[#503+0.9775*#508-0.9775*#503] output string #102=[2.0+0.9775*#508-0.9775*2.0] “#508” is not replaced, what am i doing wrong? Answers: