Is there a PowerShell code formatter / pretty printer? [closed]

UPDATE: it’s now on GitHub: https://github.com/DTW-DanWard/PowerShell-Beautifier I wrote a PowerShell pretty printer / code cleaner in PowerShell. It cleans white space, indents code groups, replaces aliases with commands, fixes casing on commands, parameters, types, etc. You can use it to reformat a file in place or read a source file and output the result in … Read more

Formatting Ruby’s prettyprint

#!/usr/bin/ruby1.8 require ‘pp’ mooth = [ “booth”, “month”, “mooch”, “morth”, “mouth”, “mowth”, “sooth”, “tooth” ] PP.pp(mooth, $>, 40) # => [“booth”, # => “month”, # => “mooch”, # => “morth”, # => “mouth”, # => “mowth”, # => “sooth”, # => “tooth”] PP.pp(mooth, $>, 79) # => [“booth”, “month”, “mooch”, “morth”, “mouth”, “mowth”, “sooth”, “tooth”] … Read more

When using Spring MVC for REST, how do you enable Jackson to pretty-print rendered JSON?

If you are using Spring Boot 1.2 or later the simple solution is to add spring.jackson.serialization.INDENT_OUTPUT=true to the application.properties file. This assumes that you are using Jackson for serialization. If you are using an earlier version of Spring Boot then you can add http.mappers.json-pretty-print=true This solution still works with Spring Boot 1.2 but it is … Read more

How do I print out a tree structure?

The trick is to pass a string as the indent and to treat the last child specially: class Node { public void PrintPretty(string indent, bool last) { Console.Write(indent); if (last) { Console.Write(“\\-“); indent += ” “; } else { Console.Write(“|-“); indent += “| “; } Console.WriteLine(Name); for (int i = 0; i < Children.Count; i++) … Read more