formatting

SwiftUI Row Height of List - how to control?

£可爱£侵袭症+ 提交于 2020-02-20 07:53:46
问题 I have a simple List in SwiftUI. Code and Screenshot included below. I would like to reduce the height of each row in the list (so less space between lines and text lines closer together). I already tried to add a ".frame(height: 20)" to the HStack but it only allows the line spacing to be increased! Is there a way to do that? Thanks! Gerard import SwiftUI struct PressureData: Identifiable { let id: Int let timeStamp: String let pressureVal: Int } struct ContentView : View { @State var

Format floats with standard json module

前提是你 提交于 2020-02-08 19:23:05
问题 I am using the standard json module in python 2.6 to serialize a list of floats. However, I'm getting results like this: >>> import json >>> json.dumps([23.67, 23.97, 23.87]) '[23.670000000000002, 23.969999999999999, 23.870000000000001]' I want the floats to be formated with only two decimal digits. The output should look like this: >>> json.dumps([23.67, 23.97, 23.87]) '[23.67, 23.97, 23.87]' I have tried defining my own JSON Encoder class: class MyEncoder(json.JSONEncoder): def encode(self,

Formatting and Bullets in a TextBox in iOS5

独自空忆成欢 提交于 2020-02-05 04:37:28
问题 Does anyone know how to insert bullets and do some formatting in a textbox, maybe in a webview (as shown in the print screen below) in iOS 5, XCode 4.3? 回答1: For the UITextView manually add dots and newlines, for example: NSArray *items = [NSArray arrayWithObjects:@"Stack",@"Overflow",nil]; NSMutableString *formattedString = [[NSMutableString alloc] init ]; for (NSString *item in items) [formattedString appendFormat:@"\u2022 %@\n", item]; theTextViewName.text = formattedString; For the

Google docs formatting, converting texts into sheets

こ雲淡風輕ζ 提交于 2020-02-04 01:28:14
问题 I've had success in sending a google docs file into a google sheets and the spreadsheet managed to fill itself in correctly (it formats the text into a table, very neat) Below is an example of how I'm formatting my text: ID, NAME, MOBILE, CITY, COUNTRY, BIRTHDAY, 3, NameGoesHere1, 21 98658 5548, abcity, countryNameHere, 1998-05-02, 6, SomeoneElse Joined Here, 21 98535 1218, whereland, Far far away, 1989-11-15, 5, AnotherCustomer, 21 85482 5245, somecity, Somewhereland, 1999-08-04, ID, PRICE,

How to turn a list/tuple into a space separated string in python using a single line?

寵の児 提交于 2020-02-03 04:46:25
问题 I tried doing: str = "" "".join(map(str, items)) but it says str object is not callable. Is this doable using a single line? 回答1: Use string join() method. List: >>> l = ["a", "b", "c"] >>> " ".join(l) 'a b c' >>> Tuple: >>> t = ("a", "b", "c") >>> " ".join(t) 'a b c' >>> Non-string objects: >>> l = [1,2,3] >>> " ".join([str(i) for i in l]) '1 2 3' >>> " ".join(map(str, l)) '1 2 3' >>> 回答2: The problem is map need function as first argument. Your code str = "" "".join(map(str, items)) Make

Need small help in converting date format in ruby

荒凉一梦 提交于 2020-02-02 06:24:04
问题 Here are some outputs: Date.today => Mon, 25 Jun 2012 Date.today.to_formatted_s(:long_ordinal) => "June 25th, 2012" Date.today.strftime('%A %d, %B') => "Monday 25, June" Now I need output in the format ie: Monday 25th, June or Thrusday, 1st, October Problem is to_formatted_s and strftime apply only on date and both or them return string. How can I get the output in the way I need. 回答1: You can use Date::DATE_FORMATS to add a new customized format, and Integer.ordinalize to get the day ordinal

Need small help in converting date format in ruby

橙三吉。 提交于 2020-02-02 06:22:31
问题 Here are some outputs: Date.today => Mon, 25 Jun 2012 Date.today.to_formatted_s(:long_ordinal) => "June 25th, 2012" Date.today.strftime('%A %d, %B') => "Monday 25, June" Now I need output in the format ie: Monday 25th, June or Thrusday, 1st, October Problem is to_formatted_s and strftime apply only on date and both or them return string. How can I get the output in the way I need. 回答1: You can use Date::DATE_FORMATS to add a new customized format, and Integer.ordinalize to get the day ordinal

How to write readable Javascript

与世无争的帅哥 提交于 2020-02-02 03:42:08
问题 In JavaScript, the standard rules for code formatting don't seem to cut it. You still end up with messes of });}); all over the place and I don't believe I even know of established rules for the correct indention of anonymous functions declared as arguments to other functions. In short, I have trouble reading my own JavaScript, and I bet I'm not alone. I think the idea that I am coming around to is to just not define functions within other functions. Write every function with a name and as a

Parsing timestamp as LocalDateTime

孤者浪人 提交于 2020-01-30 13:09:11
问题 I want to parse a timestamp in the form of yyyy-MM-dd'T'HH:mm:ss as LocalDateTime . When doing so, it strips the seconds if they are 00 . As described here, I need to use a custom formatter LocalDateTime date = LocalDateTime.parse("2008-10-02T12:30:00"); DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); String dateString = date.toString(); String dateFormatted = date.format(f); System.out.println(dateString); // 2008-10-02T12:30 This one works, but it returns a

XSLT unable to group/sort nodes based on value

浪尽此生 提交于 2020-01-30 08:24:05
问题 I'm trying to transform this xml. However I'm having formatting issues. Could someone please guide me to solve this problem. Thanks in advance <?xml version="1.0" encoding="windows-1252"?> <XML> <Attributes> <Attribute> <id>5</id> <Name>Buyer ID</Name> <Type>common</Type> <Value>Lee</Value> </Attribute> <Attribute> <id>331</id> <Name>Enviornment</Name> <Type>common</Type> <Value>Development</Value> </Attribute> <Attribute> <id>79</id> <Name>Retail</Name> <Type>common</Type> <Value></Value> <