How to insert a counter into a Stream .forEach()?

You can use an AtomicInteger as a mutable final counter. public void test() throws IOException { // Make sure the writer closes. try (FileWriter writer = new FileWriter(“OutFile.txt”) ) { // Use AtomicInteger as a mutable line count. final AtomicInteger count = new AtomicInteger(); // Make sure the stream closes. try (Stream<String> lines = Files.lines(Paths.get(“InFile.txt”))) … Read more

How can I use #pragma message() so that the message points to the file(lineno)?

Here is one that allows you to click on the output pane: (There are also some other nice tips there) http://www.highprogrammer.com/alan/windev/visualstudio.html // Statements like: // #pragma message(Reminder “Fix this problem!”) // Which will cause messages like: // C:\Source\Project\main.cpp(47): Reminder: Fix this problem! // to show up during compiles. Note that you can NOT use the … Read more

Command for toggling line numbers in vi

You can use (on VIM at least): :set invnumber More Info: :set number Turn line numbers on :set nonumber Turn line numbers off :set invnumber Toggle line numbers :set number! Toggle line numbers :set number& Set option to default value :set number? Show value of option source: http://vim.wikia.com/wiki/Managing_set_options#Boolean_options

Debugging: Get filename and line number from which a function is called?

The function inspect.stack() returns a list of frame records, starting with the caller and moving out, which you can use to get the information you want: from inspect import getframeinfo, stack def debuginfo(message): caller = getframeinfo(stack()[1][0]) print(“%s:%d – %s” % (caller.filename, caller.lineno, message)) # python3 syntax print def grr(arg): debuginfo(arg) # <– stack()[1][0] for this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)