pretty-print

Ubuntu 14.04, gcc 4.8.4: gdb pretty printing doesn't work because of Python issue

人走茶凉 提交于 2019-12-17 18:28:47
问题 I'm getting this error when launching a program in gdb: Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Traceback (most recent call last): File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module> from libstdcxx.v6.printers import register_libstdcxx_printers ImportError: No module named 'libstdcxx' Google turned up this bug report: http://osdir.com/ml/debian-gcc/2014-02/msg00061.html This bug report list using the

Pretty print a tree

空扰寡人 提交于 2019-12-17 15:25:46
问题 Let's say I have a binary tree data structure defined as follows type 'a tree = | Node of 'a tree * 'a * 'a tree | Nil I have an instance of a tree as follows: let x = Node (Node (Node (Nil,35,Node (Nil,40,Nil)),48,Node (Nil,52,Node (Nil,53,Nil))), 80,Node (Node (Nil,82,Node (Nil,83,Nil)),92,Node (Nil,98,Nil))) I'm trying to pretty-print the tree into something easy to interpret. Preferably, I'd like to print the tree in a console window like this: _______ 80 _______ / \ _ 48 _ _ 92 _ / \ / \

Print a list of space-separated elements in Python 3

落花浮王杯 提交于 2019-12-17 10:24:30
问题 I have a list L of elements, say natural numbers. I want to print them in one line with a single space as a separator. But I don't want a space after the last element of the list (or before the first). In Python 2, this can easily be done with the following code. The implementation of the print statement (mysteriously, I must confess) avoids to print an extra space before the newline. L = [1, 2, 3, 4, 5] for x in L: print x, print However, in Python 3 it seems that the (supposedly) equivalent

How can I get Express to output nicely formatted HTML?

戏子无情 提交于 2019-12-17 05:25:05
问题 When using Express for Node.js, I noticed that it outputs the HTML code without any newline characters or tabs. Though it may be more efficient to download, it's not very readable during development. How can I get Express to output nicely formatted HTML? 回答1: In your main app.js or what is in it's place: Express 4.x if (app.get('env') === 'development') { app.locals.pretty = true; } Express 3.x app.configure('development', function(){ app.use(express.errorHandler()); app.locals.pretty = true;

How can I get Express to output nicely formatted HTML?

£可爱£侵袭症+ 提交于 2019-12-17 05:25:03
问题 When using Express for Node.js, I noticed that it outputs the HTML code without any newline characters or tabs. Though it may be more efficient to download, it's not very readable during development. How can I get Express to output nicely formatted HTML? 回答1: In your main app.js or what is in it's place: Express 4.x if (app.get('env') === 'development') { app.locals.pretty = true; } Express 3.x app.configure('development', function(){ app.use(express.errorHandler()); app.locals.pretty = true;

How can I beautify JavaScript code using Command Line?

我与影子孤独终老i 提交于 2019-12-17 03:23:36
问题 I am writing a batch script in order to beautify JavaScript code. It needs to work on both Windows and Linux . How can I beautify JavaScript code using the command line tools? 回答1: First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at http://jsbeautifier.org/, because it's what I found first. Downloads its file https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js Second, download and install The Mozilla group's Java based Javascript

Printing Java Collections Nicely (toString Doesn't Return Pretty Output)

人盡茶涼 提交于 2019-12-17 02:44:05
问题 I wish to print a Stack<Integer> object as nicely as the Eclipse debugger does (i.e. [1,2,3...] ) but printing it with out = "output:" + stack doesn't return this nice result. Just to clarify, I'm talking about Java's built-in collection so I can't override its toString() . How can I get a nice printable version of the stack? 回答1: You could convert it to an array and then print that out with Arrays.toString(Object[]) : System.out.println(Arrays.toString(stack.toArray())); 回答2: String.join(","

Pretty-Print JSON in Java

[亡魂溺海] 提交于 2019-12-16 22:14:23
问题 I'm using json-simple and I need to pretty-print JSON data (make it more human readable). I haven't been able to find this functionality within that library. How is this commonly achieved? 回答1: GSON can do this in a nice way: Gson gson = new GsonBuilder().setPrettyPrinting().create(); JsonParser jp = new JsonParser(); JsonElement je = jp.parse(uglyJSONString); String prettyJsonString = gson.toJson(je); 回答2: I used org.json built-in methods to pretty-print the data. JSONObject json = new

Properly formatting JavaScript in JavaScript

冷暖自知 提交于 2019-12-14 02:31:54
问题 How can I automatically format JavaScript properly? As an example, this: (function(){(function(){alert('whatever')})()})() Should become: (function(){ (function(){ alert('whatever') })() })() 回答1: There is the jsbeautifier, you can find the source code at github. 回答2: Try http://jsbeautifier.org/ - it's the same one used by jsfiddle.net on their "Tidy Up" button where you can try it out. 来源: https://stackoverflow.com/questions/10366985/properly-formatting-javascript-in-javascript

antlr4/java: pretty print parse tree to stdout

喜夏-厌秋 提交于 2019-12-14 00:17:04
问题 Beginners question: how do I print a readable version of the parse tree to stdout? CharStream input = CharStreams.fromFileName("testdata/test.txt"); MyLexer lexer = new MyLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); MyParser parser = new MyParser(tokens); parser.setBuildParseTree(true); RuleContext tree = parser.record(); System.out.println(tree.toStringTree(parser)); this prints the whole tree on a single line delimited by brackets '()'. (record (husband <4601>