OCaml: Match expression inside another one?

Quick Solution You just need to add parentheses, or begin/end, around the inner match: Simplifications In your particular case there is no need for a nested match. You can just use bigger patterns. You can also eliminate the duplication in the nested rules using “|” (“or”) patterns: You can make it even more readable by replacing … Read more

Flushing buffers in C

Flushing the output buffers: or Can be a very helpful technique. Why would you want to flush an output buffer? Usually when I do it, it’s because the code is crashing and I’m trying to debug something. The standard buffer will not print everytime you call printf() it waits until it’s full then dumps a bunch at … Read more

What is a good Hash Function?

For doing “normal” hash table lookups on basically any kind of data – this one by Paul Hsieh is the best I’ve ever used. http://www.azillionmonkeys.com/qed/hash.html If you care about cryptographically secure or anything else more advanced, then YMMV. If you just want a kick ass general purpose hash function for a hash table lookup, then … Read more

How to read a file into a variable in shell?

In cross-platform, lowest-common-denominator sh you use: In bash or zsh, to read a whole file into a variable without invoking cat: Invoking cat in bash or zsh to slurp a file would be considered a Useless Use of Cat. Note that it is not necessary to quote the command substitution to preserve newlines. See: Bash Hacker’s Wiki – Command substitution – Specialities.

jQuery removing ‘-‘ character from string

Since text() gets the value, and text( “someValue” ) sets the value, you just place one inside the other. Would be the equivalent of doing: EDIT: I hope I understood the question correctly. I’m assuming $mylabel is referencing a DOM element in a jQuery object, and the string is in the content of the element. If the string is in some … Read more

super(type, obj): obj must be an instance or subtype of type

You should call super using the UrlManager class as first argument not the URL model. super cannot called be with an unrelated class/type: From the docs, super(type[, object-or-type]): Return a proxy object that delegates method calls to a parent or sibling class of type. So you cannot do: You should do: Or in Python 3:

Orphaned Case Error in Java

You ran into multiple problems here. Problem 1 : Look carefully your ; ends your switch there right away. Apparently all your case statements became orphans 🙂 Problem 2 : Your Switch should be switch(lower case s) Problem 3 : One more ; cause you compile time error at the line Note: I strongly suggest you to use an IDE, to save lot of time here. It … Read more