package my.com;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class Paths {
public static void main(String[] args) {
String str = "A1, A1\\BB1\\CCC1, A2\\BB1, A2\\BB1\\CCC1";
ArrayList<String> paths = new ArrayList<String>(Arrays.asList(str.split(",")));
System.out.println("====== Беган =======");
System.out.println("Было");
for(String i:paths){
System.out.println(i);
}
Set<String> out = new TreeSet<String>(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o2.compareTo(o1);
}
});
for(String i : paths) {
ArrayList<String> path = new ArrayList<String>(Arrays.asList(i.trim().split("\\\\")));
for(int j = 1; j <= path.size(); j++) {
List<String> s = path.subList(0, j);
out.add(String.join("\\",s));
}
}
System.out.println("=================");
System.out.println("Сортировка туда");
for(String i:out) {
System.out.println(i);
}
System.out.println("=================");
System.out.println("Сортировка обратно");
Set<String> out1 = new TreeSet<String>();
out1.addAll(out);
for(String i:out1) {
System.out.println(i);
}
System.out.println("======= Доне ======");
}
}
====== Беган =======
Было
A1
A1\BB1\CCC1
A2\BB1
A2\BB1\CCC1
=================
Сортировка туда
A2\BB1\CCC1
A2\BB1
A2
A1\BB1\CCC1
A1\BB1
A1
=================
Сортировка обратно
A1
A1\BB1
A1\BB1\CCC1
A2
A2\BB1
A2\BB1\CCC1
======= Доне ======
ssh -2 -v cooluser@superhost.my
from flask import jsonify
# Begin AJAX requests
@cart.route("/api/total")
def total():
count = 0
if "cart" in session:
cart = session.get("cart")
l = [int(i) for i in redis.hvals(getCartKey(cart))]
count = sum(l)
logger.debug('cart %s : %d', cart, count)
data = calculateItems()
data.pop("products")
return jsonify(dict(count=count, **data))
"""Creates a :class:`~flask.Response` with the JSON representation of
the given arguments with an `application/json` mimetype. The arguments
to this function are the same as to the :class:`dict` constructor.
Example usage::
from flask import jsonify
@app.route('/_get_current_user')
def get_current_user():
return jsonify(username=g.user.username,
email=g.user.email,
id=g.user.id)
This will send a JSON response like this to the browser::
{
"username": "admin",
"email": "admin@localhost",
"id": 42
}
For security reasons only objects are supported toplevel. For more
information about this, have a look at :ref:`json-security`.
This function's response will be pretty printed if it was not requested
with ``X-Requested-With: XMLHttpRequest`` to simplify debugging unless
the ``JSONIFY_PRETTYPRINT_REGULAR`` config parameter is set to false.
.. versionadded:: 0.2
"""
version 5
interface any world
policy DROP
protection strong
server "ssh http https icmp ping" accept
client "icmp dns ping" accept