Posts

Showing posts with the label generator

Auto convert keywords into links

Image
Clash Royale CLAN TAG #URR8PPP Auto convert keywords into links Is there a simple way to auto-convert keywords on article pages into internal hyperlinks? Maybe using a text file with a list of all keywords i want to auto convert, so that any occurance of those keywords in an article page are automatically converted into links? First occurance of any keyword only. This is for a simple static html site. Thanks for any help. <script type="text/javascript"> var searchFor = 'revolution'; // replace with search phrase var linkTo = 'revolution.html'; // replace with URL var caseSensitive = false; // set to true or false (without quotes) // do not change script below this line var content = document.getElementsByTagName('body')[0]; var flag = caseSensitive ? '' : 'i'; var pattern = new RegExp("\s(?!</a>)(" + searchFor + "\b)", "g" + flag); content.innerHTML = content.in...

Equivalent C++ to Python generator pattern

Image
Clash Royale CLAN TAG #URR8PPP Equivalent C++ to Python generator pattern I've got some example Python code that I need to mimic in C++. I do not require any specific solution (such as co-routine based yield solutions, although they would be acceptable answers as well), I simply need to reproduce the semantics in some manner. This is a basic sequence generator, clearly too large to store a materialized version. def pair_sequence(): for i in range(2**32): for j in range(2**32): yield (i, j) The goal is to maintain two instances of the sequence above, and iterate over them in semi-lockstep, but in chunks. In the example below the first_pass uses the sequence of pairs to initialize the buffer, and the second_pass regenerates the same exact sequence and processes the buffer again. first_pass second_pass def run(): seq1 = pair_sequence() seq2 = pair_sequence() buffer = [0] * 1000 first_pass(seq1, buffer) second_pass(seq2, buffer) ... re...

How to convert a HttpServletRequest to a cURL command line?

How to convert a HttpServletRequest to a cURL command line? I want to convert a HttpServletRequest to a cURL command line for debugging. How to do this? 1 Answer 1 The most common information are: getRequestURL getHeaders getMethods You will find all information in documentation: https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html https://curl.haxx.se/docs/manpage.html 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.