Search Results

Search found 2255 results on 91 pages for 'formatting'.

Page 24/91 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Getting a nicely formatted timestamp without lots of overhead?

    - by Brad Hein
    In my app I have a textView which contains real-time messages from my app, as things happen, messages get printed to this text box. Each message is time-stamped with HH:MM:SS. Up to now, I had also been chasing what seemed to be a memory leak, but as it turns out, it's just my time-stamp formatting method (see below), It apparently produces thousands of objects that later get gc'd. For 1-10 messages per second, I was seeing 500k-2MB of garbage collected every second by the GC while this method was in place. After removing it, no more garbage problem (its back to a nice interval of about 30 seconds, and only a few k of junk typically) So I'm looking for a new, more lightweight method for producing a HH:MM:SS timestamp string :) Old code: /** * Returns a string containing the current time stamp. * @return - a string. */ public static String currentTimeStamp() { String ret = ""; Date d = new Date(); SimpleDateFormat timeStampFormatter = new SimpleDateFormat("hh:mm:ss"); ret = timeStampFormatter.format(d); return ret; }

    Read the article

  • Please take a stab at this VB.Net Oracle-related sample and help me with String.Format.

    - by Hamish Grubijan
    If the database is not Oracle, it is MS SQl 2008. My task: if Oracle, add two more parameters when calling a stored proc. Oracle and MSFT stored procs are generated; Oracle ones have 3 extra parameters: Vret_val out number, Vparam2 in out number, Vparam3 in out number, ... the rest (The are not actually named Vparam2 and Vparam3, but this should not matter). So, the code for a helper VB.Net class that calls a stored proc: Imports System.Data.Odbc Imports System.Configuration Dim objCon As OdbcConnection = Nothing Dim objAdapter As OdbcDataAdapter Dim cmdCommand As New OdbcCommand Dim objDataTable As DataTable Dim sconnection As String Try sconnection = mConnectionString objAdapter = New OdbcDataAdapter objCon = New OdbcConnection(sconnection) objCon.Open() objAdapter.SelectCommand = cmdCommand objAdapter.SelectCommand.Connection = objCon objAdapter.SelectCommand.CommandType = CommandType.StoredProcedure objAdapter.SelectCommand.CommandTimeout = Globals.mReportTimeOut If Not mIsOracle Then objAdapter.SelectCommand.CommandText = String.Format("{{call {0}}}", spName) Else Dim returnValue As New OdbcParameter returnValue.Direction = ParameterDirection.Output returnValue.ParameterName = "@Vret_val" returnValue.OdbcType = OdbcType.Numeric objAdapter.SelectCommand.Parameters.Add(returnValue) objAdapter.SelectCommand.CommandText = String.Format("{{call {0}(?)}}", spName) End If Try objDataTable = New DataTable(spName) objAdapter.Fill(objDataTable) Catch ex As Exception ... Question: I am puzzled as to what String.Format("{{call {0}(?)}}", spName) does, in particular the (?) part. My understanding of the String.Format is that it will simply replace {0} with spName. The {{, }}, and (?) do throw me off because { reminds me of formatting, (?) hints at some advanced regex use. Unfortunately I am getting little help from a key person who is on vacation without a leash [smart]phone. I am guessing that I simply add 5 more lines for each additional parameter, and change String.Format("{{call {0}(?)}}", spName) to String.Format("{{call {0}(?,?,?)}}", spName). I forgot to mention that I am coding this "blindly" - I have a compiler to help me, but no environment set up to test this. This will be over in a few days, but I need to do my best to try finishing it on time :) Thanks.

    Read the article

  • XSL transformation generating output from other nodes

    - by Abel Morelos
    I have the following XSL template: <xsl:template match="SOAP-ENV:Body/*[local-name()='Publisher']"> <html> <xsl:call-template name="body" /> </html> </xsl:template> The previous template generates the output I want, it's generating the tags containing the output generated by the "body" template. The issue I'm having is that before the opening tag I'm getting text output from a previous node. Not sure why this is happening since I'm not selecting these other nodes. For example: <SOAP-ENV:Header> <!-- Many child nodes here--> </SOAP-ENV:Header> <SOAP-ENV:Body> <publishParty:Publisher> <!-- Many child nodes here--> </publishParty:Publisher> </SOAP-ENV:Body> Given the previous sample XML fragment, my output would contain what I would expect of formatting the Publisher element, but I'm also getting the text nodes of the children of the SOAP-ENV:Header node. Any ideas? Thanks!

    Read the article

  • Mixing JSP/HTML any new features or suggestions

    - by Maglebolia
    Hi all, I have a Web-Application, which is mainly JSP (file extension) and is including some HTML. It seems to me that the "general" way is "old" and not always well red by some IDE like Eclipse: Is there no other way to include jsp expression with "<% ... %". There is no need for a framework to resolve this, since we only have like 60 pages. I run through examples and see that we can seperate the code with blockquotes "< script < /script ". I'm really wondering which is the better method for understanding and easier reading of the code. Any formatting, syntax coloring, plugin or new code style suggestions would help. Here an example <%} %> <%if(condition) { %> <tr> <td class="label"><%=method()%></td> <td class="text"><%=method()%></td> </tr> <%} %> <tr>

    Read the article

  • Should a Trim method generally in the Data Access Layer or with in the Domain Layer?

    - by jpierson
    I'm dealing with a database that contains data with inconsistencies such as white leading and trailing white space. In general I see a lot of developers practice defensive coding by trimming almost all strings that come from the database that may have been entered by a user at some point. In my oppinoin it is better to do such formating before data is persisted so that it is done only once and then the data can be in a consistent and reliable state. Unfortunatley this is not the case however which leads me to the next best solution, using a Trim method. If I trim all data as part of my data access layer then I don't have to concern myself with defensive trimming within the business objects of my domain layer. If I instead put the trimming responsibility in my business objects, such as with set accessors of my C# properties, I should get the same net results however the trim will be operating on all values assigned to my business objects properties not just the ones that come from the inconsistent database. I guess as a somewhat philisophical question that may determine the answer I could ask "Should the domain later be responsible for defensive/coercive formatting of data?" Would it make sense to have a set accessor for a PhoneNumber property on a business object accept a unformatted or formatted string and then attempt to format it as required or should this responsibility be pushed to the presentation and data access layers leaving the domain layer more strict in the type of data that it will accept? I think this may be the more fundamental question. Update: Below are a few links that I thought I should share about the topic of data cleansing. Information service patterns, Part 3: Data cleansing pattern LINQ to SQL - Format a string before saving? How to trim values using Linq to Sql?

    Read the article

  • XSLT 1 Plain Text Spacing

    - by justkt
    Using Perl's XML::LibXSLT necessitates that I use XSLT 1.0, which means that I am stuck without XSLT 2.0 features. Is there a way that I can still pad text cleanly in a plain-text output from my processing? What I want is: <values> <headers> <header>Header 1</header> <header>Header 2</header> </headers> <value> <one>First value 1</one> <two>First value 2</two> </value> <value> <one>Second value 1</one> <two>Second value 2</two> </value> .... <value> <one>Nth value 1</one> <two>Nth value 2</two> </value> </values> To become Header 1 Header 2 First value 1 First value 2 Second value 1 Second value 2 .... Nth value 1 Nth value 2 I realize that XSLT isn't necessarily ideally suited for this type of formatting, but the data will likely also be formatted in other ways.

    Read the article

  • Set the background color for a fixed range of cells

    - by Count Boxer
    I have VBA code in an Excel spreadsheet. It is used to set the font and background color of a cell based on the value in that cell. I am doing it in VBA instead of "Conditional Formatting" because I have more than 3 conditions. The code is: Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, d As Range, fc As Long, bc As Long, bf As Boolean Set d = Intersect(Range("A:K"), Target) If d Is Nothing Then Exit Sub For Each c In d If c >= Date And c <= Date + 5 Then fc = 2: fb = True: bc = 3 Else Select Case c Case "ABC" fc = 2: fb = True: bc = 5 Case 1, 3, 5, 7 fc = 2: fb = True: bc = 1 Case "D", "E", "F" fc = 2: fb = True: bc = 10 Case "1/1/2009" fc = 2: fb = True: bc = 45 Case "Long string" fc = 3: fb = True: bc = 1 Case Else fc = 1: fb = False: bc = xlNone End Select End If c.Font.ColorIndex = fc c.Font.Bold = fb c.Interior.ColorIndex = bc c.Range("A1:D1").Interior.ColorIndex = bc Next End Sub The problem is in the "c.Range" line. It always uses the current cell as "A" and then goes four cells to the right. I want it to start in the "real" cell "A" of the current row and go to the "real" cell "D" of the current row. Basically, I want a fixed range and not a dynamic one.

    Read the article

  • What GUI systems let you copy text with formatting preserved, via clipboard?

    - by culebrón
    If you select and copy a text from Internet Explorer and paste it in Miscrosoft Word, the formatting is preserved. If you do that in Opera or Firefox in Windows, it's lost, IIRC. I use Gnome desktop in Linux, and formatting is preserved nowhere, which is very inconvenient. Even if desktop lets me copy formatted text, I can't post it into any web form: WISYWIG Javascript forms will strip formatting and make me walk through the whole text and fix it manually. I don't know how things are in Macs. Is there a desktop + browser + editor set that allow passing formatted text consistently throughout?

    Read the article

  • TSQL formatting - a sure fire way to start a conversation.

    - by fatherjack
    There are probably as many opinions on ways to format code as there are people writing code and I am not here to say that any one is better than any other. Well, that isn't true. I am here to say that one way is better than another but this isn't a matter of preference or personal taste, this is an example of where sloppy formatting can cause TSQL to weird and whacky things but following some simple methods can make your code more reliable and more robust when . Take these two pieces of code, ready...(read more)

    Read the article

  • TSQL formatting - a sure fire way to start a conversation.

    - by fatherjack
    There are probably as many opinions on ways to format code as there are people writing code and I am not here to say that any one is better than any other. Well, that isn't true. I am here to say that one way is better than another but this isn't a matter of preference or personal taste, this is an example of where sloppy formatting can cause TSQL to weird and whacky things but following some simple methods can make your code more reliable and more robust when . Take these two pieces of code, ready...(read more)

    Read the article

  • JqGrid - AfterInsertRow, setCell. programmatically change the contet of the cell

    - by oirfc
    Hello there, I am new to JqGrid, so please bare with me. I am having some problems with styling the cells when I use a showlink formatter. In my configuration I set up the AfterInsertRow and it works fine if I just display simple text: afterInsertRow: function(rowid, aData) { if (aData.Security == `C`) { jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `red` }); } else { jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `green` }); } }, ... This code works just fine, but as soon as I add a formatter {'Doc_Number, ..., 'formatter: ’showlink’, formatoptions: {baseLinkUrl: ’url.aspx’} the above code doesn't work because a new element is added to the cell <a href='url.aspx'>cellValue</a> Is it possible to access programmatically the new child element using something like the code above and change the style? <a href='url.aspx' style='color: red;'>cellValue</a> etc. Thanks in advance, oirfc

    Read the article

  • Sharepoint xsl ddwrt FormatDateTime issue

    - by mahumba
    I use the ddwrt:FormatDateTime function to format the output like yyyyMMdd. inputs like 01/01/2010 work fine but when the day gets over the number 12 the output is an emtpy string. ddwrt:FormatDate(string(@myDate), 1033, 'yyyyMMdd') At first I thought it could be a language specific problem but even none of those combinations work: 13/01/2010 01/13/2010 13.01.2010

    Read the article

  • JqGrid - AfterInsertRow, setCell. programmatically change the content of the cell

    - by oirfc
    Hello there, I am new to JqGrid, so please bare with me. I am having some problems with styling the cells when I use a showlink formatter. In my configuration I set up the AfterInsertRow and it works fine if I just display simple text: afterInsertRow: function(rowid, aData) { if (aData.Security == `C`) { jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `red` }); } else { jQuery('#list').setCell(rowid, 'Doc_Number', '', { color: `green` }); } }, ... This code works just fine, but as soon as I add a formatter {'Doc_Number, ..., 'formatter: ’showlink’, formatoptions: {baseLinkUrl: ’url.aspx’} the above code doesn't work because a new element is added to the cell <a href='url.aspx'>cellValue</a> Is it possible to access programmatically the new child element using something like the code above and change the style? <a href='url.aspx' style='color: red;'>cellValue</a> etc. Thanks in advance, oirfc

    Read the article

  • Linq 2 Sql DateTime format to string yyyy-MM-dd

    - by Bogdan Maxim
    Basically, i need the equivalent of T-SQL CONVERT(NVARCHAR(10), datevalue, 126) I've tried: from t in ctx.table select t.Date.ToString("yyyy-MM-dd") but it throws not supported exception from t in ctx.table select "" + t.Date.Year + "-" + t.Date.Month + "-" + t.Date.Day but i don't think it's an usable solution, because i might need to be able to change the format. The only option I see is to use Convert.ToString(t.Date, FormatProvider), but i need a format provider, and I'm not sure it works either.

    Read the article

  • Android - phone number contact format

    - by Daniel Benedykt
    Hi In Android I can get phone numbers of all the contacts without any problem. Tha problem is that for most users some numbers are stored as 'local' numbers, meaning that they dont have the country code included. For example, if the user lives in US and he has 2 contacts: 1) John - 555-123-1234 (local) (starting 1 not showing) 2) Jane - 44-123456787 (england phone number) The question is: How do I get all the numbers in an international format, when some of the numbers doesnt include the country code? Any way to figure that out? Thanks

    Read the article

  • AnkhSVN client side pre-commit hook

    - by santa
    Basically I want to do the same thing as the fella over there. It seems that everybody was thinking about server-side hooks (with all their evil potential). I want a client side script be run before commit so astyle can format the code the way my boss likes to see it. Since my IDE (VS2010Pro) automatically checks when a file changed on the disk an opts me in for reloading it, there is no real evil with all that. Is there any (clean) way to accomplish that with AnkhSVN? Maybe there's also a way to extend VisualStudio to call my pre-commit-script...

    Read the article

  • Is there a way to mark up code to tell ReSharper not to format it?

    - by adrianbanks
    I quite often use the ReSharper "Clean Up Code" command to format my code to our coding style before checking it into source control. This works well in general, but some bits of code are better formatted manually (eg. because of the indenting rules in ReSharper, things like chained linq methods or multi-line ternary operators have a strange indent that pushes them way to the right). Is there any way to mark up parts of a file to tell ReSharper not to format that area? I'm hoping for some kind of markup similar to how ReSharper suppresses other warnings/features. If not, is there some way of changing a combination of settings to get ReSharper to format the indenting correctly? EDIT: I have found this post from the ReSharper forums that says that generated code sections (as defined in the ReSharper options page) are ignored in code cleanup. Having tried it though, it doesn't seem to get ignored.

    Read the article

  • Suggestions for displaying code on webpages, MUST use <br> for newline

    - by bguiz
    Hi, I want to post code snippets online (wordpress.com blog) - and have its whitespace formatted nicely. See the answers suggested by this other SO question: Those would be OK, except that I like to copy code to clip board or clip entire pages using Evernote - and they use either the <pre> tag or <table> (or both) to format the code. So I end up with text whose newlines and white spaces ignored, e.g. string url = "<a href=\"" + someObj.getUrl() + "\" target=\"_blank\">"; // single line comments // second single line override protected void OnLoad(EventArgs e) { if(Attributes["class"]&nbsp;!= null) { //_year.CssClass = _month.CssClass = _day.CssClass = Attributes["class"]; } base.OnLoad(e); } Which I find rather annoying myself. I find that if the code was formatted using <br> tags, they copy/ clip porperly, e.g. string url = "<a href=\"" + someObj.getUrl() + "\" target=\"_blank\">"; // single line comments // second single line override protected void OnLoad(EventArgs e) { if(Attributes["class"]&nbsp;!= null) { //_year.CssClass = _month.CssClass = _day.CssClass = Attributes["class"]; } base.OnLoad(e); } I find this annoying myself, so I don't want to inflict it upon others when I post my own code. Please suggest methods of posting code snippets online that are able to do this. I would like to emphasise that syntax highlighting capability is secondary to correct white space markup. Thank you

    Read the article

  • IText Lines Per Page?

    - by exit174
    I have used IText(Sharp) to make PDFs from raster images but have never used IText to build text based PDF's. In this new scenario, I have N words of ASCII text that I need to add as text pages to a new PDF. Each page should be 8.5 x 11, .5 margins, using some monospaced font. Is IText(Sharp) smart enough to automatically apply line and page breaks where necessary or do I need to do this manually? Are their any good IText tutorials for this scenario? thanks! scottm

    Read the article

  • Square Bullet in XSL-FO

    - by Igman
    I am attempting to create a list in XSL-FO using a square bracket. I have been able to get it working using the standard unicode bullet character (&#8226;) but I just can't seem to get it working for square brackets. I have tried using &#9632;, but that does not seem to work. It is important that i can get the square bullets working because I am matching an existing file format.Any help in getting this working would be greatly appreciated. <fo:list-item-label end-indent="label-end()"> <fo:block>&#x2022;</fo:block> </fo:list-item-label>

    Read the article

  • Python dictionary formating

    - by None
    I made a python function to convert dictionaries to formatted strings. My goal was to have a function take a dictionary for input and turn it into a string that looked good. For example, something like "{'text':'Hello', 'blah':{'hi':'hello','hello':'hi'}}" would be turned into this: text: Hello blah: hi: hello hello: hi This is the code I wrote: indent = 0 def format_dict(d): global indent res = "" for key in d: res += (" " * indent) + key + ":\n" if not type(d[key]) == type({}): res += (" " * (indent + 1)) + d[key] + "\n" else: indent += 1 res += format_dict(d[key]) indent -= 1 return res #test print format_dict({'key with text content':'some text', 'key with dict content': {'cheese': 'text', 'item':{'Blah': 'Hello'}}}) It works like a charm. It checks if the dictionary item is another dictionary, in which it process that, or something else, in which it would use that as the value. The problem is: I can't have a dictionary and a string together in a dictionary item. For example: if I wanted blah: hi hello: hello again there'd be no way to do it. Is there some way I could have something like a list item in a dictionary. Something like this "{'blah':{'hi', 'hello':'hello again'}}"? And if you provide a solution could you tell me how I would need to change my code (if it did require changes). Note: I am using python 2.5

    Read the article

  • Netbeans render unrecognized files as html

    - by nick
    Hey Everyone, I am using Netbeans and very happy with it. Unfortunately I am having a little problem with it that I cant seem to figure out. I am using Silverstripe CMS and it uses a templating system that syntactically is basically just a mix of php and html. These files however end in .ss and therefore netbeans doesnt format and highlight them at all. How do I make netbeans format and highlight all .ss files just as if they where normal html files? Kind Regards Nick

    Read the article

  • C#: File-size format provider

    - by Seb Nilsson
    Is there any easy way to create a class that uses IFormatProvider that writes out a user-friendly file-size? public static string GetFileSizeString(string filePath) { FileInfo info = new FileInfo(@"c:\windows\notepad.exe"); long size = info.Length; string sizeString = size.ToString(FileSizeFormatProvider); // This is where the class does its magic... } It should result in strings formatted something like "2,5 MB", "3,9 GB", "670 bytes" and so on.

    Read the article

  • making jQuery plug-in autoNumeric format fields by time page loads...

    - by Lille
    Hi, I've been messing around with autoNumeric, a plug-in for jQuery that formats currency fields. I'd like to wire the plug-in so that all currency fields are formatted by the time the user sees the page, e.g., on load. Currently, the default that I can't seem to get around is that fields are formatted upon blur, key-up or other action in the fields themselves. I've been experimenting with the plug-in code and it looks like it will take this relative newcomer some time to resolve this, if at all. Anybody on this? Lille

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >