How do you use a TextPainter to draw text?

I found the answer as I was typing up this question but I’ve been wrestling with it for a while now, so posting in case it helps anyone else. What solved it was changing the TextSpan line to: TextSpan span = new TextSpan(style: new TextStyle(color: Colors.grey[600]), text: ‘Yrfc’); Apparently it was either drawing the text … Read more

Does Java support default parameter values?

No, the structure you found is how Java handles it (that is, with overloading instead of default parameters). For constructors, See Effective Java: Programming Language Guide’s Item 1 tip (Consider static factory methods instead of constructors) if the overloading is getting complicated. For other methods, renaming some cases or using a parameter object can help. This is … Read more

In C++, what is wx.h?

What is wx.h It is the header file of a library. The GitHub project should have some instructions on how to fetch the dependencies and how to install them. How do I install it in my compiler so that I can use it? Normally you have to download the dependency, build it (following some instructions), … Read more

Remove a git commit which has not been pushed

I did a git commit but I have not pushed it to the repository yet. So when I do git status, I get ‘# Your branch is ahead of ‘master’ by 1 commit. So if I want to roll back my top commit, can I just do: given that when I do git log I get: commit eb27bf26dd18c5a34e0e82b929e0d74cfcaab316 Date: Tue … Read more

Parsing a JSON string in Ruby

This looks like JavaScript Object Notation (JSON). You can parse JSON that resides in some variable, e.g. json_string, like so: If you’re using an older Ruby, you may need to install the json gem. There are also other implementations of JSON for Ruby that may fit some use-cases better: YAJL C Bindings for Ruby JSON::Stream

Import error: No module name urllib2

As stated in the urllib2 documentation: The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3. So you should instead be saying Your current, now-edited code sample is incorrect because you are saying urllib.urlopen(“http://www.google.com/”) instead of just urlopen(“http://www.google.com/”).

Pinging servers in Python

This function works in any OS (Unix, Linux, macOS, and Windows)Python 2 and Python 3 EDITS:By @radato os.system was replaced by subprocess.call. This avoids shell injection vulnerability in cases where your hostname string might not be validated. Note that, according to @ikrase on Windows this function will still return True if you get a Destination Host Unreachable error. Explanation The command is ping in both Windows and … Read more

git pull on a different branch

I found an incantation that worked for me: then (if you want to merge right away): I was really surprised how hard it was to find an answer to this since it seems like it would be a common use case.

en_US or en-US, which one should you use?

I’m pretty sure “-” is the standard. If you see “_” somewhere it’s probably something some people came up with to make it a valid identifier. Personally I’d go with “-“, just to be correct. http://en.wikipedia.org/wiki/IETF_language_tag