How to sort a python list of arbitrary strings like Excel Column Names?

E.g. I have: x = ["Column a is…", "Column ab uses…", "Column b has…"] then I need to get: x = ["Column a is…", "Column b has…", "Column ab uses…"] >Solution : If the column identifier is guaranteed to be the second whitespace delimited token in each string then: x = ["Column a is…", "Column… Read More How to sort a python list of arbitrary strings like Excel Column Names?

How to search json for a string and output a parent value using jq?

Trying to pull a value out with jq, but didn’t seem as easy as i originally thought. I have a variable of CAR="baga6e~tlwdcmli__QmbHKa~G65fMXzh.car". How can i use this variable to return the parent "piece_cid" ? Example: Using a bash varible of $CAR with a value of baga6e~tlwdcmli__QmbHKa~G65fMXzh.car, id be able to get the results saved… Read More How to search json for a string and output a parent value using jq?

Creating a new file and add some text to it using bash

I’m making a basic installation script (my first to be precise) for LAMP, and I experienced some difficulties: I trying to put some configuration in a new file, in this case for ssl-params My humble code: cat > /etc/apache2/conf-available/ssl-params.conf << ENDOFFILE SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLHonorCipherOrder On Header always set X-Frame-Options… Read More Creating a new file and add some text to it using bash

keep apostrophes when passing string value in Innerhtml

The text value holds string text with double quotes and apostrophes as you see in the example. when I print the result it changes to different characters. The text that is coming from API is : "mismatched input ‘STARTt’ expecting ‘START’ "; but when I print it, it goes : "mismatched" input="" ‘startt’="" expecting="" ‘start’=""… Read More keep apostrophes when passing string value in Innerhtml

Regex to find two strings within a pipe delimited string

I need to find a match within the delimited string if the following two words appear between the pipes: apple and red Example string 1 (should give a match): |big blueberries blue|awesome lemon yellow|apple nice delicious red| Example string 2 (should not give match): |big blueberries apple|awesome lemon yellow|nice delicious red| RegEx tried: ^.*?apple.*?red.*? Which… Read More Regex to find two strings within a pipe delimited string

Most Pythonic way to eliminate duplicate entries in a delimited string (not a list) and returning the sorted result

I have a need to do some processing on many thousands of strings (each string being an element in a list, imported from records in a SQL table). Each string comprises a number of phrases delimited by a consistent delimiter. I need to 1) eliminate duplicate phrases in the string; 2) sort the remaining phrases… Read More Most Pythonic way to eliminate duplicate entries in a delimited string (not a list) and returning the sorted result