pretty-print

Customizing the printing of maps by :type in Clojure

让人想犯罪 __ 提交于 2019-12-11 01:06:10
问题 Pretty-printing this map comes out pretty ugly: {:type :move, :name :boost, :from {:nodeid :plus, :name :left-operand, :value {:args [:result :right-operand], :f #object[fargish.workspace_test$fn__159675$fn__159678 0xb3f518f "fargish.workspace_test$fn__159675$fn__159678@b3f518f"]}, :dockclass :input, :ref [:plus :left-operand]}, :to {:nodeid :source11, :name :output, :value 11, :dockclass :output, :ref [:source11 :output]}, :do #object[fargish.workspace$do_boost 0x179d226e "fargish.workspace

Get C#-style type reference from CLR-style type full name

落花浮王杯 提交于 2019-12-10 13:13:57
问题 Given a .NET type object found through reflection, is it possible to pretty print or decompile this type as a C# declaration, taking into account C# type aliases, etc.? For example, Int32 -> int String -> string Nullable<Int32> -> int? List<au.net.ExampleObject> -> List<ExampleObject> I want to be able to print out methods close to what was originally written in the source. If there isn't anything in the .NET framework, is there a third-party library? I might possibly have a look at ILSpy.

Disabling sorting mechanism in pprint output

不羁岁月 提交于 2019-12-10 12:55:22
问题 I have big dictionary which I`m printing for viewing with prettyprint, but how I can keep formatting but kill sorting mechanism in pprint? 回答1: You can monkey patch the pprint module. import pprint pprint.pprint({"def":2,"ghi":3,"abc":1,}) pprint._sorted = lambda x:x # Or, for Python 3.7: # pprint.sorted = lambda x, key=None: x pprint.pprint({"def":2,"ghi":3, "abc":1}) Since the 2nd output is essentiallly randomly sorted, your output may be different from mine: {'abc': 1, 'def': 2, 'ghi': 3}

How to format numbers according to locale in Haskell?

荒凉一梦 提交于 2019-12-10 10:06:28
问题 In Python I can use locale.format to pretty-print numbers according to locale setting: >>> import locale >>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8") 'en_US.UTF-8' >>> locale.format("%.2f",1234567.89,grouping=True) '1,234,567.89' How can I do the same in Haskell? I see that there are localeconv and setlocale bindings, but is there a generic pretty printer which respects Lconv ? 回答1: I would say that if the library in question is missing then you could either write yourself one (obvious

Use PHP to format an input SQL query as HTML?

南笙酒味 提交于 2019-12-10 03:20:57
问题 What I am looking for is a php function that takes an unformatted query like this: $sql = "select name, size from things where color = 'green' order by price asc"; so that it would appear in an HTML page something like this: SELECT name, size FROM things WHERE color = 'green' ORDER BY price ASC'; There's some code inside phpMyAdmin that does this already, I could look in there I guess! 回答1: I had the same problem and made a light-weight PHP class to do formatting/syntax highlighting. https:/

Haskell — easier to read show function? (for debugging)

青春壹個敷衍的年華 提交于 2019-12-09 15:28:42
问题 I'm looking for a function like show that produces more readable output. It certainly doesn't have to work on all classes. I searched "haskell pretty print" on Google, but that seems to produce compiler source code printers. Debugging stuff like the following (newlines inserted manually for stackoverflow formatting) is difficult! (fromList [(Ref {name = "phi", lenRef = 4},fromList [CompNode {val = 1, ident = CNId {uid = 4, zone = 0}, deps = []},CompNode {val = 2, ident = CNId {uid = 5, zone =

format xml, pretty print

穿精又带淫゛_ 提交于 2019-12-09 11:55:00
问题 I know of two ways to "pretty print", or format, xml: shell tools Hack 38 Pretty-Print XML Using a Generic Identity Stylesheet and Xalan what other free (as in beer) formatters are there? (aside from using javascript) 回答1: Well, the identity transform you linked to is portable to any XSLT processor (Saxon, msxml, etc). Additionally, you could look at xmllint which is part of the LibXML2 toolkit. The --format option allows you to pretty print the input. Similar functionality exists in

user-defined printer in OCaml

大城市里の小女人 提交于 2019-12-08 17:12:11
问题 printf , fprintf , etc. : all accept the %a conversion. The manual says for %a : "user-defined printer. Takes two arguments and apply the first one to outchan (the current output channel) and to the second argument. The first argument must therefore have type out_channel -> 'b -> unit and the second 'b. The output produced by the function is therefore inserted in the output of fprintf at the current point." I can't understand what a user-defined printer is for, and how you would implement and

Hibernate: OutOfMemoryError persisting Blob when printing log message

蓝咒 提交于 2019-12-08 11:21:19
问题 I have a Hibernate Entity: @Entity class Foo { //... @Lob public byte[] getBytes() { return bytes; } //.... } My VM is configured with a maximum heap size of 512 MB. When I try to persist an object which has a 75 MB large object, I get an OutOfMemoryError. The names of the methods in the stack trace (StringBuilder, ByteArrayBlobType.toLoggableString, pretty.Printer.toString) suggest that hibernate is trying to write a very large log message that contains my object. Am I correct about why

pretty printing nested vectors

喜你入骨 提交于 2019-12-07 17:10:01
问题 I have the following code to pretty-print generic vectors -: // print a vector template<typename T1> std::ostream& operator <<( std::ostream& out, const std::vector<T1>& object ) { out << "["; if ( !object.empty() ) { std::copy( object.begin(), --object.end(), std::ostream_iterator<T1>( out, ", " ) ); out << *--object.end(); // print the last element separately to avoid the extra characters following it. } out << "]"; return out; } I am getting a compiler error if I try to print a nested