dump

Pretty print JSON dumps

妖精的绣舞 提交于 2019-11-27 15:47:36
问题 I use this code to pretty print a dict into JSON: import json d = {'a': 'blah', 'b': 'foo', 'c': [1,2,3]} print json.dumps(d, indent = 2, separators=(',', ': ')) Output: { "a": "blah", "c": [ 1, 2, 3 ], "b": "foo" } This is a little bit too much (newline for each list element!). Which syntax should I use to have this: { "a": "blah", "c": [1, 2, 3], "b": "foo" } instead? 回答1: Write your own JSON serializer: import numpy INDENT = 3 SPACE = " " NEWLINE = "\n" def to_json(o, level=0): ret = "" if

Restore dump on the remote machine

ε祈祈猫儿з 提交于 2019-11-27 14:56:56
问题 I've got my own machine with postgres dmp file, which I want to restore on the remote virtual machine (e.g. ip is 192.168.0.190 and postgres port is 5432) in my network. Is it possible to restore this dump using pg_restore without copying dump to remote machine? Because the size of dump about 12GB and the disk space on the virtual machine is 20GB. Thanks 回答1: You can run a restore over the network without copying the dump to the remote host. Just invoke pg_restore with -h <hostname> and -p

How in H2DB get sql dump like in MySql?

坚强是说给别人听的谎言 提交于 2019-11-27 11:25:37
I have some questions about H2DB. I have H2DB database which stores data in files, I have 3 files test.18.log.db, test.data.db, test.index.db. I want get sql dump file like when I use mysqldump. Is it possible? Yes, there are multiple solutions. One is to run the SCRIPT SQL statement : SCRIPT TO 'fileName' Another is to use the Script tool : java org.h2.tools.Script -url <url> -user <user> -password <password> Then, there are also the RUNSCRIPT statement and RunScript tool. By the way, you should consider upgrading to a more recent version of H2. With newer versions, the two files .data.db and

Save “screen” (program) output to a file

那年仲夏 提交于 2019-11-27 10:28:43
I need to save the whole output of screen to a file to check later all the content. The reason is that I'm dumping a flash memory trough serial port, using screen to interface with it. I would like to save it to a file to check memory structure. I've tried : $: screen /dev/ttyUSB0 115200 >> foo.txt $: screen /dev/ttyUSB0 115200 | tee foo.txt and I've also tried to use bufferfile from screen, but I don't understand how to use it. Is there an easy way? There is a command line option for logging. The output is saved to screenlog.n file, where n is a number of the screen. From man pages of screen:

How to dump YUV from OMXCodec decoding output

余生颓废 提交于 2019-11-27 07:32:47
问题 I'd like to dump YUV data from OMXCodec decoding output. It's MediaBuffer type. It's impossible to access data() pointer. If I try to access data, crash happens due to the check code below. frameworks/av/media/libstagefright/MediaBuffer.cpp:119 CHECK(mGraphicBuffer == NULL) failed. Please let me know the solution to extract YUV data from this MediaBuffer . 回答1: From the MediaBuffer , I feel that the following should be functional. I haven't tried the same yet and have worked with rg2's

How to capture a process memory dump of a .NET process when .NET is not in the middle of a garbage collection (GC)

a 夏天 提交于 2019-11-27 06:14:01
问题 When capturing a dump file and analyzing it (e.g. in WinDbg), I often get the warning that the data may not be accurate, or commands may not be accessible, because the process was in the middle of GC when the dump file was collected. When doing memory analysis, we often do it because the memory on the process is high and memory pressure is high which I guess forces .NET to GC frequently. How do I avoid taking dumps during a GC? Is there a way to know when its safe to capture the dump file?

What is the JavaScript equivalent of var_dump or print_r in PHP? [duplicate]

假如想象 提交于 2019-11-27 05:50:28
This question already has an answer here: Is there an equivalent for var_dump (PHP) in Javascript? 17 answers I would like to see the structure of object in JavaScript (for debugging). Is there anything similar to var_dump in PHP? Paolo Bergantino Most modern browsers have a console in their developer tools, useful for this sort of debugging. console.log(myvar); Then you will get a nicely mapped out interface of the object/whatever in the console. Check out the console documentation for more details. Most common way: console.log(object); However I must mention JSON.stringify which is useful to

How to dump data stored in objective-c object (NSArray or NSDictionary)

大兔子大兔子 提交于 2019-11-27 05:21:20
问题 Forgive me for a potentially silly question here, but in other programming languages (scripting ones like PHP or Perl) it is often easy to dump everything contained within a variable. For instance, in PHP there are the var_dump() or print_r() functions. Perl has the Data::Dumper CPAN class, etc etc. Is there something like this for Objective-C? It would be very convenient in a few cases to be able to dump everything like that, instead of using gdb to inspect each variable. 回答1: In Cocoa,

Connect to URL and dump webpage in Groovy

独自空忆成欢 提交于 2019-11-27 01:45:36
问题 I would like to open a webpage from groovy, dump the specified webpage and eventually dump the webpage behind an anchor tag. Does anybody has some sample code for this? 回答1: This is a good example http://docs.codehaus.org/display/GROOVY/Simple+file+download+from+URL Basically you want to do something like def data = new URL(feedUrl).getText() 回答2: here is a variation println 'http://www.google.com'.toURL().text 来源: https://stackoverflow.com/questions/943873/connect-to-url-and-dump-webpage-in

Is there a way to have an Android process produce a heap dump on an OutOfMemoryError?

独自空忆成欢 提交于 2019-11-27 00:37:52
问题 The sun JVM supports a -XX:+HeapDumpOnOutOfMemoryError option to dump heap whenever a java process runs out of heap. Is there a similar option on Android that will make an android app dump heap on an OutOfMemoryException? It can be difficult to try to time it properly when using DDMS manually. 回答1: To expand upon CommonsWare's answer: I have no idea if this works, but you might try adding a top-level exception handler, and in there asking for a heap dump if it is an OutOfMemoryError . I