How to read records terminated by custom separator from file in python?

There is nothing in the Python 2.x file object, or the Python 3.3 io classes, that lets you specify a custom delimiter for readline. (The for line in file is ultimately using the same code as readline.) But it’s pretty easy to build it yourself. For example: def delimited(file, delimiter=”\n”, bufsize=4096): buf=”” while True: newbuf … Read more

NSNumberFormatter with comma decimal separator

I would recommend not hardcoding the separator to ensure the right separator behavior based on the iPhone locale setting. The easiest way to to this is: using objective-c NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc]init]; numberFormatter.locale = [NSLocale currentLocale];// this ensures the right separator behavior numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; numberFormatter.usesGroupingSeparator = YES; // example for writing the number … Read more

Set decimal separator when using f:convertNumber

The default decimal separator depends on the locale used. You can set it in 2 ways: On a per-view basis by the locale attribute of the <f:view> tag: <f:view locale=”#{bean.locale}”> On a per-converter basis by the locale attribute of the <f:convertNumber> tag: <f:convertNumber locale=”#{bean.locale}” /> It’s unclear what locale you’re targeting, but the use of … Read more

Adding Thousand Separator to Int in Swift

You can use NSNumberFormatter to specify a different grouping separator as follow: update: Xcode 11.5 • Swift 5.2 extension Formatter { static let withSeparator: NumberFormatter = { let formatter = NumberFormatter() formatter.numberStyle = .decimal formatter.groupingSeparator = ” ” return formatter }() } extension Numeric { var formattedWithSeparator: String { Formatter.withSeparator.string(for: self) ?? “” } } … Read more

Android: custom separator (or even item) in ListView depening on content of item

Here is one implementation that does exactly what you describe. That one is GPLv3, because it is derived from this implementation, which was GPLv3. You can also use my MergeAdapter for this, which has the advantage of being Apache License 2.0. Just hand it an alternating set of header TextViews and Adapters containing each section’s … Read more

HTML + CSS: Ordered List without the Period?

This is perfectly possible to do with just CSS (2.1): ol.custom { list-style-type: none; margin-left: 0; } ol.custom > li { counter-increment: customlistcounter; } ol.custom > li:before { content: counter(customlistcounter) ” “; font-weight: bold; float: left; width: 3em; } ol.custom:first-child { counter-reset: customlistcounter; } Keep in mind that this solution relies on the :before pseudo-selector, … Read more