Wrapping C++ class API for C consumption

Foreach public method you need a C function. You also need an opaque pointer to represent your class in the C code. It is simpler to just use a void* though you could build a struct that contains a void* and other information (For example if you wanted to support arrays?). Fred.h ——————————– #ifdef __cplusplus … Read more

How do I wrap text in a span?

Wrapping can be done in various ways. I’ll mention 2 of them: 1.) text wrapping – using white-space property http://www.w3schools.com/cssref/pr_text_white-space.asp 2.) word wrapping – using word-wrap property http://webdesignerwall.com/tutorials/word-wrap-force-text-to-wrap By the way, in order to work using these 2 approaches, I believe you need to set the “display” property to block of the corresponding span element. … Read more

Remove characters before and including _ in python 2.7

To get all text on a line after a underscore character, split on the first _ character and take the last element of the result: line.split(‘_’, 1)[-1] This will also work for lines that do not have an underscore character on the line. Demo: >>> ‘Grp25_QTY47 5’.split(‘_’, 1)[-1] ‘QTY47 5’ >>> ‘No underscore’.split(‘_’, 1)[-1] ‘No … Read more

Printing with indentation in python

I think what you’re looking for here is the textwrap module: user = “Username” prefix = user + “: ” preferredWidth = 70 wrapper = textwrap.TextWrapper(initial_indent=prefix, width=preferredWidth, subsequent_indent=” “*len(prefix)) message = “LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT ” * 3 print wrapper.fill(message) This prints: Username: LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT LEFTLEFTLEFTLEFTLEFTLEFTLEFT RIGHTRIGHTRIGHT If you actually want to use tabs in … Read more

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