Should I buffer the InputStream or the InputStreamReader?

r1 is more efficient. The InputStreamReader itself doesn’t have a large buffer. The BufferedReader can be set to have a larger buffer than InputStreamReader. The InputStreamReader in r2 would act as a bottleneck. In a nut: you should read the data through a funnel, not through a bottle. Update: here’s a little benchmark program, just … Read more

Git add lines to index by grep/regex

patchutils has a command grepdiff that can be use to achieve this. # check that the regex search correctly matches the changes you want. git diff -U0 | grepdiff ‘regex search’ –output-matching=hunk # then apply the changes to the index git diff -U0 | grepdiff ‘regex search’ –output-matching=hunk | git apply –cached –unidiff-zero I use … Read more

Hide external modules when importing a module (e.g. regarding code-completion)

I had the same problem, and solved it by adding a leading underscore to all my imports. It doesn’t look brilliant, but it achieves what you’re after. from __future__ import division as _division import numpy as _np import pandas as _pd Only the stuff that starts without an underscore is imported when you import the … Read more

How can I cancel Task.WhenAll?

Use TaskCompletionSource<T> to create a task for some asynchronous condition that does not already have an asynchronous API. Use CancellationToken.Register to hook the modern CancellationToken-based cancellation system into another cancellation system. Your solution just needs to combine these two. I have a CancellationToken.AsTask() extension method in my AsyncEx library, but you can write your own … Read more

href=”mailto:” is not working on any of the browsers

Provided you have registered a default email client, this usually works, if you’re using an <a> tag as follows: <a href=”https://stackoverflow.com/questions/34129707/mailto:[email protected]”>Mail me</a> To change or check the email client settings, do the following (cited from MSDN) – I have modified it slightly because it differs depending on the Windows version you’re using: Depending on the … Read more

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