format

C++ format macro / inline ostringstream

你离开我真会死。 提交于 2019-12-17 08:53:33
问题 I'm trying to write a macro that would allow me to do something like: FORMAT(a << "b" << c << d) , and the result would be a string -- the same as creating an ostringstream, inserting a...d , and returning .str() . Something like: string f(){ ostringstream o; o << a << "b" << c << d; return o.str() } Essentially, FORMAT(a << "b" << c << d) == f() . First, I tried: 1: #define FORMAT(items) \ ((std::ostringstream&)(std::ostringstream() << items)).str() If the very first item is a C string (

Audio format for iOS and Android

让人想犯罪 __ 提交于 2019-12-17 07:06:02
问题 Sorry if I am asking too generic question. We are in the process of developing an application which records and plays audio on mobile devices. This application is being developed for both Android and iOS. The application will record audio using device mic and store it in the server. User (on Android and iOS) can open the application and play the sound which is stored on the server. The sound format we are using is AAC. In iOS its working fine. We can record and play the AAC files. But on

Changing date format in R

不羁岁月 提交于 2019-12-17 06:35:55
问题 I have some very simple data in R that needs to have its date format changed: date midpoint 1 31/08/2011 0.8378 2 31/07/2011 0.8457 3 30/06/2011 0.8147 4 31/05/2011 0.7970 5 30/04/2011 0.7877 6 31/03/2011 0.7411 7 28/02/2011 0.7624 8 31/01/2011 0.7665 9 31/12/2010 0.7500 10 30/11/2010 0.7734 11 31/10/2010 0.7511 12 30/09/2010 0.7263 13 31/08/2010 0.7158 14 31/07/2010 0.7110 15 30/06/2010 0.6921 16 31/05/2010 0.7005 17 30/04/2010 0.7113 18 31/03/2010 0.7027 19 28/02/2010 0.6973 20 31/01/2010 0

What's the difference between ISO 8601 and RFC 3339 Date Formats?

蹲街弑〆低调 提交于 2019-12-17 06:21:00
问题 ISO 8601 and RFC 3339 seem to be two formats that are common the web. Should I use one over the other? Is one just an extension? Do I really need to care that bad? 回答1: Is one just an extension? Pretty much, yes - RFC 3339 is listed as a profile of ISO 8601. Most notably RFC 3339 specifies a complete representation of date and time (only fractional seconds are optional). The RFC also has some small, subtle differences. For example truncated representations of years with only two digits are

Changing the date format to yyyy-mm-dd

梦想的初衷 提交于 2019-12-17 06:14:50
问题 I've got a date column that contains dates in mixed format. For example: A 21.03.1990 03/21/1990 So, basically there are two different formats in one column: dd.mm.yyyy and mm/dd/yyyy . I'm trying to write a VBA script to change format of all dates in the column to be yyyy-mm-dd . That's what I've got so far: Sub changeFormat() Dim rLastCell As Range Dim cell As Range, i As Long Dim LValue As String i = 1 With ActiveWorkbook.Worksheets("Sheet1") Set rLastCell = .Range("A65536").End(xlUp) On

PHP “pretty print” HTML (not Tidy)

╄→尐↘猪︶ㄣ 提交于 2019-12-17 06:06:54
问题 I'm using the DOM extension in PHP to build some HTML documents, and I want the output to be formatted nicely (with new lines and indentation) so that it's readable, however, from the many tests I've done: "formatOutput = true" doesn't work at all with saveHTML(), only saveXML() Even if I used saveXML(), it still only works on elements created via the DOM, not elements that are included with loadHTML(), even with "preserveWhiteSpace = false" If anyone knows differently I'd really like to know

Why doesn't C have unsigned floats?

℡╲_俬逩灬. 提交于 2019-12-17 05:36:29
问题 I know, the question seems to be strange. Programmers sometimes think too much. Please read on... In C I use signed and unsigned integers a lot. I like the fact that the compiler warns me if I do things like assigning a signed integer to an unsigned variable. I get warnings if I compare signed with unsigned integers and much much more. I like these warnings. They help me to keep my code correct. Why don't we have the same luxury for floats? A square-root will definitely never return a

Why doesn't C have unsigned floats?

故事扮演 提交于 2019-12-17 05:35:01
问题 I know, the question seems to be strange. Programmers sometimes think too much. Please read on... In C I use signed and unsigned integers a lot. I like the fact that the compiler warns me if I do things like assigning a signed integer to an unsigned variable. I get warnings if I compare signed with unsigned integers and much much more. I like these warnings. They help me to keep my code correct. Why don't we have the same luxury for floats? A square-root will definitely never return a

Inserting the same value multiple times when formatting a string

て烟熏妆下的殇ゞ 提交于 2019-12-17 04:14:07
问题 I have a string of this form s='arbit' string='%s hello world %s hello world %s' %(s,s,s) All the %s in string have the same value (i.e. s). Is there a better way of writing this? (Rather than listing out s three times) 回答1: You can use advanced string formatting, available in Python 2.6 and Python 3.x: incoming = 'arbit' result = '{0} hello world {0} hello world {0}'.format(incoming) 回答2: incoming = 'arbit' result = '%(s)s hello world %(s)s hello world %(s)s' % {'s': incoming} You may like

Automatic image format detection in PHP

和自甴很熟 提交于 2019-12-17 04:09:23
问题 I am looking for a way to take a user uploaded image that is currently put in a temporary location ex: /tmp/jkhjkh78 and create a php image from it, autodetecting the format. Is there a more clever way to do this than a bunch of try/catching with imagefromjpeg, imagefrompng, etc? 回答1: This is one of the functions of getimagesize. They probably should have called it "getimageinfo", but that's PHP for you. 回答2: //Image Processing $cover = $_FILES['cover']['name']; $cover_tmp_name = $_FILES[