formatting

Date Formatting in VBScript - Prefix Month with 0 (zero) e.g. 07 instead of 7

Hi, If i use DatePart("m",Now()) ' out put will be 7 but my requirment is to display "07" rather than "7" Is there any direct method to achieve this, or should should I write custom code to prefix "0" zero? ...

git post-receive-email hooks.showrev pretty formatting?

I'm trying to do this: git show --format=format:"parents:%p%ncommit:%h%nauthor:%an%n%N%n%s%n%b" -C; echo in my hooks.showrev in my post-receive-email script for git: custom_showrev=$(git config hooks.showrev || git show --format=oneline --abbrev-commit -C %s; echo) using the "standard" post-receive-email script. It just gives me th...

vmstat and column

I want to use column utility to format output of iostat in aligned columns. I want to run something like: vmstat 1 10 | column -t But the output appers only after 10 sec (vmstat completes its work) and not each second. Any ideas? ...

Format a date in C++

Hi, I have a series of date strings in the format: "30-05-2001" string date1 = "30-05-2001"; I would like to parse the date into Day, Month, Year. Now an easy way of doing this would be just to call the function sscanf. But I'd like to explore other possiblilties and from searching the web the following function from time.h was r...

How to change default Xaml TextBox fontsize

In my file.xaml, how can I set the TextBlock default size, so that I don't have to include that attribute in the TextBlock element? <UserControl.Resources> <!-- how?/can i set the default font size for textblock element here? --> </UserControl.Resources> <Grid> <StackPanel> <TextBlock Text="{Binding HelloWorld}" /> </S...

ostream showbase non-present for zero value, and internal doesn't work for HANDLE? Must I fudge it?

PSPS: (a Pre-scripted Post-script) It has just come to mind that a more prescient question would have included the notion of: Is this non-display of "0x"(showbase) for zero-value integers a standard behaviour, or is it just a quirk of my MinGW implementation? It all began on a pleasant Sunday morning... I want to dump some Handles i...

Simple C number formatting question

Hi guys, This a very simple c question. Is there a way to format a float for printf so that it has xx SIGNIFICANT decimals? So I'm not take about, say, %5.3 float, but if I had float x=0.00001899383 how would i output 0.0000189 if i wanted UP TO the first three non-zero decimals? thanks! I'm not stating at home this weekend so I do...

Date conversion

How to convert the date displayed 7/19/2010 12:00:00 AM to July/Sunday/2010??? ...

How to stop ReSharper removing spaces in object initializer

I like my object initializers to look like this: new Point { Label = g.Key.Name, Claims = g }; When hit the semicolon key, they get reformatted like this: new Point {Label = g.Key.Name, Claims = g}; Where is the option to stop my padding from being removed? ...

Format date based on locale in python

I have a date output like >>> import time >>> print time.strftime("%d %B") 19 July Is there a way to format the date based on the locale, but still have control of what is shown (in some cases I don't want the year). For example, on a en_US machine, I want it to output: July 19'th ...

Set color of TextView span in Android

Is it possible to set the color of just span of text in a TextView? I would like to do something similar to the Twitter app, in which a part of the text is blue. See image below: Thanks! ...

How to auto format a table in Excel?

I have a table in Excel. In each row, I want to highlight the columns that correspond to the maximum value in that row. For example, if I have this table: 0 1 2 3 4 5 3 5 8 9 3 4 I want to highlight 3 in row 1, 5 in row 2 and 9 in row 3. How can I do that automatically? THANKS! ...

Formatting rules of JSP in Eclipse

Eclipse has a huge number of formatting rules for Java and Javascripting, which can be reached via "code-style" option under java and javascript. I couldn't find any JSP settings for formatting rules. Is there any? I could find a few basic setting in Web->JSP Files->Editor which redirects to Web->Html->Editor and Web->XML->Editor. This o...

Omit HTML but keep <br> tags in rails

I need to display user comments, omitting HTML to prevent attacks (when custom styled elements can be posted as comments) The only thing, i would like to keep by displaying - is tag I displaying the comment in this way: <p class="content"><%=h comment.content.gsub(/\n/,"<br/>") %></p> Comment is suppossed to be saved in database wit...

How to always display a BigDecimal object in full decimal format instead of scientific notation?

I have a BigDecimal object, myNumber, with unknown length. For example: 12345678. I always want to divide this number by 1 million, so I do: myNumber.divide(BigDecimal.valueOf(1000000)) I get 12.345678. I want to display this as a string "12.345678", without cutting off ANY decimal places. So I do myNumber.divide(BigDecimal.val...

What is the most efficient way to format UTF-8 strings in java?

I am doing the following: String url = String.format(WEBSERVICE_WITH_CITYSTATE, cityName, stateName); String urlUtf8 = new String(url.getBytes(), "UTF8"); Log.d(TAG, "URL: [" + urlUtf8 + "]"); Reader reader = WebService.queryApi(url); The output that I am looking for is essentially to get the city name with blanks (e.g., "Overland Par...

Having a Pretty-Printed XML file from the WriteXml of a Dataset in VB.NET

Hello all, I'm trying to use Dataset.WriteXml() function in VB.Net to generate an XML file with Pretty-Print Layout (I think this is how it's named) like the example below (Listing 1): <MainRoot> <Table1> <Col1>Value1</Col1> <Col2>Value2</Col2> <Col3></Col3> <Col4>Value4</Col4> </Table1> <Table2> ...

how to create a flat file in ruby

how can I create a flat file in ruby? Flat file is there each letter is placed at a specific column number in the file. So for example if I am reading some values from the DB: Name Class ------------------- one A two English three Math four Science and I want to make a flat file out of it wh...

Scale() of Divide method in BigDecimal

new BigDecimal("37146555.53880000").divide(new BigDecimal("1000000")).scale() This returns 10. But according to the API, the divide method: Returns a BigDecimal whose value is (this / divisor), and whose preferred scale is (this.scale() - divisor.scale()); So in this case, 37146555.53880000's scale is 8, and 1000000's scale...

MySQL/PHP - Would putting quotes around numbers break any queries?

I want to have a generic PHP function that builds a mysql query based on the parameters of the function. Since it is generic the query may sometimes ask for id=123 or name='Bob'. I test out some queries with quotes around numbers, even stuff like WHERE id > '50' + 7 and it worked but I have my doubts that this won't cause trouble down t...