Tarik
Unmarshal an ISO-8859-1 XML input in Go
Updated answer for 2015 & beyond: import ( “encoding/xml” “golang.org/x/net/html/charset” ) reader := bytes.NewReader(theXml) decoder := xml.NewDecoder(reader) decoder.CharsetReader = charset.NewReaderLabel err = decoder.Decode(&parsed)
First occurrence in a binary search
An addition to Jon Skeets post: The potential faster implementation is actually not hard to implement and adds only 2 lines of code, here is how I’d do it: if (midVal < key) low = mid + 1; else if (midVal > key) high = mid – 1; else if (low != mid) //Equal but … Read more
Writing a Log file in C/C++
The standard method of logging (in my experience) is to use either the stdout or stderr streams. In C++ to use these you would need to include iostream, and use as below: #include <iostream> int main(int argc, char* argv[]) { using std::cout; using std::cerr; using std::endl; cout << “Output message” << endl; cerr << “Error … Read more
Troubles uninstalling oh-my-zsh?
Have you tried just running the commands from uninstall script by hand? It’s really straight forward: https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/uninstall.sh. For the most part it just removes OMZ and attempts to restore a back up file: rm -rf ~/.oh-my-zsh rm ~/.zshrc cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc source ~/.zshrc
Convert byte[] or object to GUID
How about using the Guid constructor which takes a byte array? Guid guid = new Guid(binaryData); (You can then use Guid.ToString() to get it in text form if you need to.)
How do I know if my server has NUMA?
I’m no expert here, but here’s something: Box 1, no NUMA: ~$ dmesg | grep -i numa [ 0.000000] No NUMA configuration found Box 2, some NUMA: ~$ dmesg | grep -i numa [ 0.000000] NUMA: Initialized distance table, cnt=8 [ 0.000000] NUMA: Node 4 [0,80000000) + [100000000,280000000) -> [0,280000000)
Make all variables in a Python function global
Warning: Don’t try this at home, you might burn it down. There is no legitimate reason to do the following in the course of normal day-to-day programming. Please review the other answers to this question for more realistic alternatives. I can barely imagine why you would want to do this, but here is a way … Read more
Composer & Cygwin
Just tripped over the same problem and found a solution. Posting it here, just in case I’ll ever have to look it up again. Set up a bin directory right under /home/my-username: cd ~ mkdir bin Move the composer.phar (or any other of those nifty new PHP imps that are on the rise) into the … Read more