formatting

Why can't nlog read the current date

二次信任 提交于 2019-12-10 20:49:28
问题 I'm using Nlog to write some logging to a textfile. Partial nlog.config: <target name="file" xsi:type="File" fileName="${basedir}/MBWRunner_log.txt" layout="${date} (${level}): ${message} Exception: ${exception:format=Method, ToString}"/> Lines in the logfile look like this: 0001-01-01 00:00:00 (Trace): MBWRunner started As you can see the date and time are all 0. I have tested {longdate} and {date:format=yyyyMMddHHmmss} with the same result. The application is a console app, run from an

Conditional text formatting XAML WP8

混江龙づ霸主 提交于 2019-12-10 20:00:11
问题 Is it possible to setup some form of conditional formatting of textblock controls in XAML so that the color of the text can be changed depending on the text (eg. Text = "good" then set to green, Text = "bad" then set text to red.) I have tried some examples but they don't seem to work, presumably because WP8 works differently. 回答1: One simple way is in the view with DataTrigger s like: Namespaces: xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas

adding horizontal rule to html rmarkdown doc hides sections of text

戏子无情 提交于 2019-12-10 19:29:58
问题 I am making an Rmarkdown document that knits to an HTML page. Instead of separating some text sections with headers or bullets, I just want to draw horizontal lines between them. According to http://rmarkdown.rstudio.com/authoring_basics.html this would be called a "horizontal rule" and I can do that with three or more --- . However when I actually try to do this, various sections disappear from the html doc. Here is a very simple example of my code: --- title: "formatting issue" author: "rrr

Oracle To_Char function How to handle if it's already a string

我怕爱的太早我们不能终老 提交于 2019-12-10 19:26:02
问题 Scenario: I am calling a function that returns a field that the user enters in. The field usually returns a number like '120000' which I then use to_char to convert into '120,000'. Problem: Some users enter in values such as '120,000' which gives me an error when trying to use to_char. Also the function will return a space ' ' if no value is found. I tried something with to_number earlier and it has a problem with the ' ' I believe. Question: What would be the best way to handle this problem?

ASP.Net MVC switching Cultures after compile for initial load

廉价感情. 提交于 2019-12-10 19:04:05
问题 I have a hybrid ASP.Net web forms/MVC app. On one of the MVC "pages"/views, I have it render a bunch of dates using the ToShortDateString() and ToLongDateString(). These work correctly most of the time, but the first time I load the view after compiling the app, they are formatted incorrectly. I traced this down and checked the current thread's culture. For 99% of the time it's en-US, but on the first load of the MVC view after compiling it is set to en-GB. If I reload the page immediately

Clang format splits if statement body into multiple lines

青春壹個敷衍的年華 提交于 2019-12-10 19:03:35
问题 I have the following .cpp file: //////////////////////////////////////////////////////////////////////////////// void call_long_function_name(bool) {} void sf(bool) {} int main() { bool test = true; if (test) { call_function_name(test); } if (test) { sf(test); } return 0; } (the slashes delimit 80 characters). Using the following configuration file, clang-format suggests: //////////////////////////////////////////////////////////////////////////////// void call_long_function_name(bool) {}

How do I add thousand separators with reg ex?

跟風遠走 提交于 2019-12-10 18:43:56
问题 I'm using this free RegExp Designer which does find and replace. How do I search for all numbers and add thousand separators? Input: <node num='12345678'> Output: <node num='12,345,678'> 回答1: To reformat numbers only in "num" attribute values you can do this: (?<=num='\d+)(?=(?:\d{3})+(?!\d)) But note that this will only work in .NET regexes, which is what RegExp Designer uses. Most regex flavors only allow lookbehinds that match a fixed number of characters. Java regexes allow variable

Convert minutes into a human readable format

梦想的初衷 提交于 2019-12-10 18:39:48
问题 quick question. Is there a smarter/sleeker way to convert minutes into a more readable format, showing only the most significant digit? I'm using Android Studio's Java. public String MinutesToHumanReadable(Long minutes) { ... } ie 2 mins = "2 mins" 45 mins = "45 mins" 60 mins = ">1 hr" 85 mins = ">1 hr" 120 mins = ">2 hrs" 200 mins = ">3 hrs" 1500 mins = ">1 day" My code is very cumbersome, sloppy, and somewhat unreadable. public String MinutesToHumanReadable(long minutes) { String sReturn =

How to apply different formatting depending on whether number is positive or negative

心已入冬 提交于 2019-12-10 18:19:06
问题 I'm outputting a Double that can be either (+) or negative (-). If the number is a negative the symbol (-) is included automatically, is there a way to do this for positive numbers as well? The only (horrible) way I can do this is : If MyNumber <= 0 then string.Format("{0:0.00}", MyNumber) Else string.Format("+{0:0.00}", MyNumber) End If 回答1: You can use the section separator in your format: string.Format("{0:+0.00;-0.00}", num); The format before the semi-colon will be used for positive

Netbeans code format braces in PHP single line statements

寵の児 提交于 2019-12-10 18:17:15
问题 Intro Im developing PHP in NetBeans IDE 7.2 (Build 201207171143) and I love the formatting to clean up my code in my custom format. At the moment I work in a group with colleagues. Some of my colleagues are used to write single line statement without braces (I think this is bad practice). Examples What my colleagues do: <?php if($stackoverflow == 'Cool') echo 'Stack Overflow is Cool!'; ?> What I want when I format the code. <?php if($stackoverflow == 'Cool') { echo 'Stack Overflow is Cool!';