formatting

Formatting alphanumeric string

Hello. I have a string with 16 alphanumeric characters, e.g. F4194E7CC775F003. I'd like to format it as F419-4E7C-C775-F003. I tried using string.Format("{0:####-####-####-####}","F4194E7CC775F003"); but this doesn't work since it's not a numeric value. So I came up with the following: public class DashFormatter : IFormatProvider, ...

Objective-C - How To Remove Characters From a String?

I have a UILable that has a formatted String (formatted for currency), so there is a dollar sign, $21.34. In the core data entity the attribute is of a type double, I am using an NSDecimalNumber to save to the database. self.purchase.name = self.nameTextField.text; NSString *string = self.amountLabel.text NSDecimalNumber *...

What is the Oracle date formatting mask for time zones?

I need to insert a date format from an outside source which includes the three letter code for time zone, but the TZD formatting mask does not seem to work... insert into blah values (to_date('Thu, 18 Feb 2010 08:37:00 EST','Dy, DD Mon YYYY HH24:MI:SS TZD')); ORA-01821: date format not recognized If I remove the "TZD"... insert ...

Excel: macro to auto-format time (without date)

I'm looking for a simple macro to specify cells as being of type "time" and typing only numbers (for example "955") will format that (and recognise as) "hh:mm" time. In other words, by typing "955", the cell would interpret to "09:55", whereas all I can have it do right now is interpret to "1902-08-12 00:00:00" (most likely 955 is the d...

XQuery formatting tool

I need a tool for reformatting (indenting, long line split) of xquery scripts. My script started very small but now is almost 4000 lines long and quite messy and needs refactoring. Can someone help? ...

Visual Studio Object Browser disregards XML comment formatting

In my .NET XML comments on methods and classes, I try to provide usage examples in <example><code></code></example> blocks. When I use Sandcastle to generate a .chm documentation file using my XML documentation, it's always formatted nicely and respects the newlines in my <code> blocks. However, when I browse the classes and methods in...

Change list formatting in PyYAML output

This is how PyYAML behaves on my machine: >>> plan = {'Business Plan': ['Collect Underpants', '?', 'Profit']} >>> print(yaml.dump(plan)) Business Plan: [Collect Underpants, '?', Profit] What I want instead is this output (both is valid YAML): Business Plan: - Collect Underpants - '?' - Profit Is there some kind of option that would...

convert money/decimal to string

I'm using .net. Is there some code somewhere that can change $11,456.50 -> eleven thousand four hundred fifty six and 50/100 Dollars I can do it myself, but don't want to rewrite something that's already there. ...

How do I center a crosstab in Crystal Reports XI?

I have a crosstab that I would like to have automatically centered (left to right) on the page. I would have thought this a simple thing. For example, on a web page I could do something like "align=center". In a java GUI I would use a layout manager. In GWT I would use a panel. In Word I would use Ctrl-E. In Latex, \centering. ...

How to format date in SQLite according to current locale format settings?

I need to match on a date using the LIKE operator. The date should be in current user's local format, not in the general format. So I use the strftime function like this: WHERE strftime('%d.%m.%Y %H:%M', createdDate, 'localtime') LIKE '%{searchTerm}%' Unfortunately this works only for fixed format '%d.%m.%Y %H:%M'. But I want to use ...

What is the most common, industry preferred formatting method?

I couldn't seem to find a good question on SO, or a good Google search that seemed to answer my question. What is the industry or popular preference when it comes to formating code "chunks" and their brackets. Here are some examples for what I am trying to explain... if($foo) { return $bar; } else { return $stackOverflow; } VS...

Unicode Locale Data Markup for (e.g.) "Tue, 23 Feb 2010 06:00:44 PST"

Hi. I was parsing a XML feed and trying to convert it to a NSObject when I noticed that (e.g.) [NSDate dateFromString:@"Tue, 23 Feb 2010 06:00:44 PST"] returned nil. Then I tried to convert my string to a NSDate by using the NSDateFormatter. NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"EEE, dd MMM YYYY HH:m...

PdfPTable as a header in iTextSharp

I need a table with about 12 cells to display as a header. The following code fails to do this. I am aware table2 does not have 12 cells. On the second page, only "testing" is displayed. What am I missing? Thanks in advance! Document document = new Document(); try { PdfWriter.GetInstance(document, new FileS...

What is the correct syntax for replacing two characters at once in ColdFusion?

Hello, I'm trying to replace two special characters using the replace function in ColdFusion: <cfset MyQuery = "/Attribute One\/Attribute Two\/Attribute Three\"> <cfset MyString = Replace(MyQuery, "/", "<li>", "ALL")> <ul> <cfoutput>#MyString#</cfoutput> </ul> This works well, but I need to correctly close my li tags. I tried adding ...

Vertical alignment of subfigures LATEX

Hi, I am working on my thesis and I am struggling with placing 2 images next to each other, so that the second image would be centered vertically along the first one. I was also trying to use subfigure instead of subfloat but neither of them works. This is how it looks and my code is: \begin{figure}[H] \centering \subfloat[H][spars...

php plain text email formats differently in outlook

I'm trying to align some text in a php generated plain text email. Thunderbird displays all characters as the same width. Newer versions of Outlook however do not. Is there some way I can force outlook to use a "fixed-width" font in the headers for instance? Here are the headers I'm currently using Content-Type: text/plain; charset=ut...

C# double formatting align on decimal sign

I align numbers with various number of decimals so that the decimal sign aligns on a straight row. This can be achevied by padding with spaces, but I'm having trouble. Lays say I want to align the following numbers: 0 0.0002 0.531 2.42 12.5 123.0 123172 This is the result I'm after: 0 0.0002 0.531 2.42 12.5 ...

Is there a better way to code this sqlQuery in R ?

I'm writing an R script to get some database data and then do stuff with it, using the RODBC package. Currently all my sqlQuery commands are one long string; stsample<-sqlQuery(odcon, paste"select * from bob.DESIGNSAMPLE T1, bob.DESIGNSUBJECTGROUP T2, bob.DESIGNEVENT T3, bob.CONFIGSAMPLETYPES T4 WHERE T1.SUBJECTGROUPID = T2.SUBJECTGROU...

(How) Can I use string substitution for working w/ Django’s i18n {% trans %} tag?

I'm looking for something like this: {% trans "There are %{flowers}n flowers in the vase" < flowers:3 %} Now obviously syntax is fake, but it should be sufficient to demonstrate what I'm looking for. Should I cook something of my own? It looks like a common usecase, so I was quite surprised that quick web search didn't return anythi...

Parsing dates to a Rails friendly format

I've got a batch of a 100k or so records that I'm importing to a Rails app. There's a date in each row formatted like the following: 03/17/81 However, when I try to just assign it to a date field, it gets converted as follows: ruby-1.8.7-p174 > "03/17/81".to_date => Sat, 17 Mar 0081 Ultimately I would like the format to result in ...