human-readable

Actual numbers to the human readable values

时间秒杀一切 提交于 2020-01-22 14:31:19
问题 I have data in bytes. I need to draw this values as human readable labels on a chart (like 2.5KB, 14MB etc.) and need to help with function (input data - actual value, output - human readable string). I did funcion like this, but I want more elegant realization function tickFormatter(value, type) { var suffix = (type == "bytes") ? ['B', 'KB', 'MB', 'GB'] : ['', 'K', 'M', 'G'] if(value > (1024 * 1024 * 1024 * 1024)) { return (value / (1024 * 1024 * 1024 * 1024)).toFixed(2) + suffix[3] } else

Actual numbers to the human readable values

陌路散爱 提交于 2020-01-22 14:28:06
问题 I have data in bytes. I need to draw this values as human readable labels on a chart (like 2.5KB, 14MB etc.) and need to help with function (input data - actual value, output - human readable string). I did funcion like this, but I want more elegant realization function tickFormatter(value, type) { var suffix = (type == "bytes") ? ['B', 'KB', 'MB', 'GB'] : ['', 'K', 'M', 'G'] if(value > (1024 * 1024 * 1024 * 1024)) { return (value / (1024 * 1024 * 1024 * 1024)).toFixed(2) + suffix[3] } else

How to serialize a python dict to text, in a human-readable way?

独自空忆成欢 提交于 2020-01-04 14:00:45
问题 I have an python dict whose keys and values are strings, integers and other dicts and tuples (json does not support those). I want to save it to a text file and then read it from the file. Basically, I want a read counterpart to the built-in print (like in Lisp). Constraints: the file must be human readable (thus pickle is out) no need to detect circularities. Is there anything better than json? 回答1: You could use repr() on the dict , then read it back in and parse it with ast.literal_eval()

Finding human-readable files on unix

本小妞迷上赌 提交于 2019-12-31 16:30:04
问题 I'd like to find human-readable files on my linux machine without a file extension constraint. Those files should be of human sensing files like text, configuration, html, source-code etc. files. Could you suggest a way to filter and locate. 回答1: find and file are your friends here: find /dir/to/search -type f -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print this will find any files ( NOTE: it will not find symlinks directories sockets etc only regular files ) in /dir/to/search and

Finding human-readable files on unix

微笑、不失礼 提交于 2019-12-31 16:29:07
问题 I'd like to find human-readable files on my linux machine without a file extension constraint. Those files should be of human sensing files like text, configuration, html, source-code etc. files. Could you suggest a way to filter and locate. 回答1: find and file are your friends here: find /dir/to/search -type f -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print this will find any files ( NOTE: it will not find symlinks directories sockets etc only regular files ) in /dir/to/search and

Is there a standard file naming convention for key-value pairs in filename?

懵懂的女人 提交于 2019-12-25 11:57:20
问题 I have multiple data files that are named after what they contain. For example machine-testM_pid-1234_key1-value1.log There are keys and values separated by - and _. Is there a better syntax for this? Are there parsers that automatically read these kinds of files/filenames? The idea here is that the filenames are human and machine readable. 回答1: There seems to be no standard file naming convention for key-values. 来源: https://stackoverflow.com/questions/10087079/is-there-a-standard-file-naming

Is there a standard file naming convention for key-value pairs in filename?

▼魔方 西西 提交于 2019-12-25 11:57:06
问题 I have multiple data files that are named after what they contain. For example machine-testM_pid-1234_key1-value1.log There are keys and values separated by - and _. Is there a better syntax for this? Are there parsers that automatically read these kinds of files/filenames? The idea here is that the filenames are human and machine readable. 回答1: There seems to be no standard file naming convention for key-values. 来源: https://stackoverflow.com/questions/10087079/is-there-a-standard-file-naming

How to make Python Yaml library save in a human-friendly way?

℡╲_俬逩灬. 提交于 2019-12-24 04:58:21
问题 Here is the Python code I've got: d = {'ToGoFirst': 'aaa', 'Second': 'bbb', 'Pagargaph': '''Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.''', 'Integer': 25} with open('d.yaml', 'w') as f: yaml.safe_dump(d, f, default_flow_style=False) What I keep getting: Integer: 25 Pagargaph: "Lorem ipsum dolor sit amet, \nconsectetur adipiscing elit, \nsed do eiusmod\ \ tempor incididunt \nut labore et dolore magna aliqua."

A minimalistic human-readable serialisation format parser for an embedded system

坚强是说给别人听的谎言 提交于 2019-12-20 12:35:39
问题 By "human-readable serialisation format" I mean YAML , JSON , INI or like. Please note, XML is too verbose and too inconvenient for my purposes, so let's leave it alone as the last resort. The format should store the data as "named key -- value" pairs and allow for nesting and arrays. Absence of arrays is not critical, though. Also, type-awareness (ability to return data not only as plain strings) is highly appreciated. What I need exactly is a pure C library, which provides an API for

A minimalistic human-readable serialisation format parser for an embedded system

天涯浪子 提交于 2019-12-20 12:35:09
问题 By "human-readable serialisation format" I mean YAML , JSON , INI or like. Please note, XML is too verbose and too inconvenient for my purposes, so let's leave it alone as the last resort. The format should store the data as "named key -- value" pairs and allow for nesting and arrays. Absence of arrays is not critical, though. Also, type-awareness (ability to return data not only as plain strings) is highly appreciated. What I need exactly is a pure C library, which provides an API for