formatting

How to tell printf() to get the value from the untyped (or byte-sequence) buffer

I have a buffer of raw values, say, void* buffer or better, char* buffer - a raw byte stream, for example, read from a file. I'd like the bytes in the buffer to be represented and displayed in several ways, for example, as a float, or as a long long in runtime. I'd ask a user for desired format string, for example, %10d, and pass the for...

Where do I put formatting logic?

I have several classes with raw data, for example: public interface Transaction { public double getAmount(); public Date getDate(); } I need to output formatted versions of this data in several places. For example, I might display the amount as $1,000 on a web page, or 1000.00 on an Excel download. I also want to be able to reus...

UITextView: Change formatting of URLs?

I currently have a UITextView which has this property setup to detect URL's: txtTemp.dataDetectorTypes = UIDataDetectorTypeLink; The URL displays correctly, formatting in blue with an underline. I want to change the formatting of this hyperlink to a bold font style with no underline. The rest of the regular text in the UITextView nee...

How to avoid wasting screen space writing sparse C# code?

The commonly accepted way to format C# code seems to be as follows: namespace SomeNamespace { namespace SomeSubNamespace { class SomeClass { void SomeFunction() { using (var someFile = new StreamWriter(somePath)) { try ...

Excel: How can I speed up a Find & Replace process? Changing 32,000 links per workbook.

I'm comparing a lot of data for over 30 categories. Each category workbook is saved into 'MyFolder' with it's own distinctive name (the category). The data in the workbook is found on a sheet with the same name as the category: [Category.xls]CategoryYear_Final! It seemed best to create a standard template that references the data and wh...

What's the easiest way to get the binary representation of an integer?

Actually, I'm not asking how to implement this functionality myself. I know it wouldn't be very complicated. I just don't want to reinvent the wheel, so I was wondering if this functionality exists somewhere in the BCL. It seems like surely it's there somewhere... Example input/desired output: Input Output 1 1 2 ...

Print a leading '+' for positive numbers in printf

I've a temperature conversion program as an assignment, which I've completed. The program has many printf statements in it which print the temperature. Now the negative temperatures are printed the way I want them but the positive temperatures are printed without a leading + sign. Now what is the best way to get printf print a leading ...

Percentage display issue

i have a value that i calculate between 0 -100 , its usually a float number like 5.87876 , so i use number_format like : $format_number = number_format($number, 2, '.', ''); the problem is , even the calculate number is integer like : 100 its show 100.00 but i want to display it like : 100 what is the elegant way to achive this ? ...

Controlling appearance of new lines in IBM mainframe

All, So I'm uploading a text file from C# to an IBM MVS mainframe. The file is converted to ebcdic using C# libraries and it works well as I can read the data on the mainframe. The problem is the new lines. The text file has 10 rows of data and while viewing it in the mainframe environment, all data is present. But there are no new l...

WPF - Bind DisplayMemberPath to a Function?

Hey all, Is there a way I can bind the DisplayMemberPath of combobox to a function? The object with which I am currently working has three properties I wish to use for presentation; FirstName, LastName, and MiddleName. I wrote a static method in a Formatting class to handle it. This method is called FullName and accepts three string ...

Dealing With Different Coding Conventions/Styles In Visual Studio...

I'm working on two different projects - both in VB.NET/Visual Studio 2008 (as much as I'd like to move to 2010). I find I'm confusing the different coding standards that I'm supposed to follow. IE - Project1 wants variables named in a Hungarian-style notation like 'iSomeValue'; the does not want a prefix. One project requires an _ pre...

Excel macro: how do I change all row heights, BUT if cell.value = bold make the cell height bigger?

I'm working on a long list of data (Column B) that has been formatted using bold and indents. The bold cells contain the titles/category names and the indented cell values are the subcategories. The row heights are all over the place. It should have been 10.5 for everything, and the bold cells/rows 15. I can change everything to 10.5, b...

Can I add custom colors to mercurial command templates?

I want to use customized template for hg log which looks like this: hg log --template '{node|short} {desc} [{date|age} by {author}]\'n --color=always This in default terminal color is not very readable, so for instance I would like to make node red and desc green. How can I do this? In git I can define this kind of formatting like thi...

Registering a DateFormatProvider in Java

Is there a way to have my DateFormatProvider take precedence over the existing locales in Java? I have to do some custom formatting for the locale da_DK, and I would like to get these DateFormats by simply using DateFormat.getDateInstance(int, Locale). But it seems that if a Locale already exists in Java, it doesn't care that i register...

Extract text from a PDF and save it to a database - preserving spacing

I have a PDF document containing only text that needs to be saved into a varchar column in MSSQL. The first catch is that the spacing of the text in the PDF needs to be preserved as well, which can't be done simply by copy-pasting from the PDF into SSMS. Okay, so I need an application to read the PDF as text, while preserving spacing. B...

Help with string formatting in SQL Server Query

Hello, I have the following SQL query: SELECT DISTINCT ProductNumber, PageNumber FROM table I am trying to modify the query so that PageNumber will be formatted. You see, PageNumber is in any of the following formats, where 'x' is a digit: xxx, xxx xxx xxx-xxx xx, xxx-xxx xx-xx, xxx xx-xx, xxx-xxx I want to format PageNumber so th...

Convert varchar 114 on datetime equals what?

I have trouble in setting the equal condition on a datetime field after converting it to hh:mm:ss.mmm: select top 1 convert(varchar, timestamp, 114) from TEST_TABLE /* returns a single entry of 11:33:35:000 */ Then I want to find all entries with that timestamp: select * from TEST_TABLE where convert(varchar, timestamp, 114) = '11:3...

How do I format the date and time That is received from database

Iam getting the date and time from Database as follows Date : 20100101(YYYY/MM/DD) Time : 120912 (HH:MM:SS) I have to format the Date as follows 20100101 --> (2010-10-11) (look to have ) "-" in between year and month and Day I have to format the time as follows 120912 --> 12:02:12 suppose I may have the time as 62367 from the d...

Meaning of lone curly-braced code blocks in C.

I've come across a bit of code that contains a couple code blocks, delineated with curly braces {}. There is no line before the code blocks marking them as part of if statements, function definitions, or anything else. Just a code block floating in the middle of a function. Is there any meaning to this? gcc seems perfectly happy going...

How to format the selected text in a QTextEdit by pressing a button.

I want to format a selected text in a QTextEdit by clicking a button. For axample I want to make it bold if it is not-bold, or not-bold if it is bold. Please help me with an example. EDIT: Actually I have found already a code - qt demo for text editor which does what I need: void MyTextEdit::boldText(bool isBold) //this is the SLOT fo...