formatting

Combine custom numeric format string with hex format string

I have a situation where I need to format an integer differently depending on whether or not it's zero. Using custom numeric format strings, this can be achieved with the semicolon as a separator. Consider the following: // this works fine but the output is decimal string format = "{0:0000;-0000;''}"; Console.WriteLine(format, 10); // ...

How can I break up this long line in Python?

How would you go about formatting a long line such as this? I'd like to get it to no more than 80 characters wide: logger.info("Skipping {0} because its thumbnail was already in our system as {1}.".format(line[indexes['url']], video.title)) Is this my best option? url = "Skipping {0} because its thumbnail was already in our system as...

NHibernate number format problem - where do I set the culture?!

LATER EDIT : It was me :( It was a non-nullable column left unfilled. Sorry to everyone I confused.. I am having issues with an INSERT statement generated by NHibernate because it formats the decimal numbers using the regional settings. The generated statement goes something like : exec sp_executesql N'INSERT INTO [TableName] ( Co...

How do I call an instance method from another classes' static method (i.e. have only one object)?

Hi all, my form1 class contains a bunch of data that I need to save, so there should only be one instance of it running at a time. public partial class Form1 : Form { public string form1string = "I really need to save this data"; public Form1() { InitializeComponent(); // Even if I pass my form1 object he...

Controlling Display of Methods In Template

I have the following in a view (foreign key relationships via _set): srvr = Server.objects.get(name=q) return render_to_response('search_results.html', {'drv': srvr.drive_set.all(), 'memry': srvr.memory_set.all(), 'query': q}) The results template includes: {% if drv %} <table> <tr> <td>{{ drv }}</td> </tr> </tabl...

How to align two form submits

Hi Everyone, I have a page with two submit buttons at the bottom of the page. One for the submit of the page that posts to an action and another to cancel that posts to a different action. For whatever reason IE has a problem with placing these two buttons side by side. Firefox has no issue. Here is my script: <div class="button_row...

Objective-c code formatter site to create html that can be embedded into a blog

I'm looking for site similar to http://www.manoli.net/csharpformat/ that allows one to put in c# code snippet and it formats the html to post into your blog with a CSS file. I need one that actually does this for Objective-C. ...

Inserting spaces between digits in C

How would I go about taking a number like 123456 and having it print as 1 2 3 4 5 6? ...

Getting text to display under an image in a navigation

I want my navigation to look like this: <icon> <icon> <icon> Title Longer Title Title Ideally, I want my code to look like: <li> <img src="images/icon.png" /> <a class="link_title">Title 1</a> </li> <li> <img src="images/icon.png"/> <a class="link_title">Title 2</a> </li> <li> <img src="images/i...

Parse number with positive/negative prefix from string in java

It's quite straight forward in java to parse number from String, i.e. with Integer.parseInt(s) if string in the format 'n' or '-n', but unfortunately it fails to parse string in the format of '+n'. So what is the most effective/elegant way to parse number from string in java if it contains positive or negative prefix: '+n' or '-n' ? ...

J2ME - number format

Hi! I need to format decimal numbers with patterns in J2ME just like java DecimalFormat. I see an option to port Format/NumberFormat/DecimalFormat. Can you suggest ready to use implementation or library? Thanks! ...

How to configure Eclipse formatter to not insert blank line between field declarations?

I am using Eclipse 3.5.1 (Galileo) and am having trouble with one of the auto-formatting settings. At the moment when I auto-format a blank line is inserted between each and every field declaration. The behaviour I'm looking for is to organise field declarations without a blank line between. Except in the case where there is already on...

How to change the formatting of the "Use Object Initializer" refactoring in Resharper?

When I refactor the following line: Employee e = new Employee(); e.First = "Frank"; e.Last = "Rizzo"; using Resharper's "Use Object Initializer", I get the following: Employee e = new Employee { First = "Frank", Last = "Rizzo" }; I really hate this type of formatting becau...

Use different fonts in same Excel cell?

Is there any way to change the color and/or font of specific text within an excel cell? That is, I'd like one part of the cell's displayed value to be red and another part of the same cell's displayed value to be blue (as an example). Since the displayed values are being calculated as formulas, I'd need some sort of formatting formula ...

How in C# to reformat string, representing a decimal, to have space group separator?

I have found on SO some posts, regarding formatting strings, representing numbers, to have digit group separators, during converting decimals (or other number data types) to string: http://stackoverflow.com/questions/2100472/how-to-format-1700-to-1700-and-1000000-to-1000000-in-c http://stackoverflow.com/questions/1142994/c-formating-pr...

PHP date formatting

I want to transform a date from this format: 01/07/09 to this jan 07,09. How can I do that in PHP? ...

Custom date format cannot be parsed. (Java)

I have to parse a custom date format in Java. It contains microseconds although Java doesn't provide support for microseconds. Because of that I filled the format with zeroes, but now I cannot parse date-strings with that format. Is there a simple workaround or must I handle microseconds on my own (with String functions)? @Test public ...

Jsp default date format

Is it possible to change default formatting of Date object in JPS pages? Now I have some kind of formatting and I would like to change formatting without using fmt-tags, because that would mean I would have to type that formatting to all pages and there are many! ...

Formatting sentences in a string using C#

Hi All, I have a string with multiple sentences. How do I Capitalize the first letter of first word in every sentence. Something like paragraph formatting in word. eg ."this is some code. the code is in C#. " The ouput must be "This is some code. The code is in C#". one way would be to split the string based on '.' and then capital...

How do I format a PLOT3D file for ParaView?

I'm trying to describe the shape of a rabbit heart in order for simulations to be visualised with ParaView. The problem I'm having is that ParaView would like the geometry to be described in PLOT3D format, a clear description of which I'm struggling to find online. The geometry I have consists of a regular 3D mesh, from which only some...