String comparison in awk

Sure it can: pax$ echo ‘hello goodbye’ | gawk ‘{if ($0 == “hello”) {print “HELLO”}}’ HELLO You can also do inequality (ordered) testing as well: pax> printf ‘aaa\naab\naac\naad\n’ | gawk ‘{if ($1 < “aac”){print}}’ aaa aab

Convert Data to String in Swift 3

This is an example using a completion handler: class func getFilm(filmID: Int, completion: @escaping (String) -> ()) { let url = URL(string: “https://api.kinopoisk.cf/getFilm?filmID=\(filmID)”)! URLSession.shared.dataTask(with:url) { (data, response, error) in if error != nil { print(error!) completion(“”) } else { if let returnData = String(data: data!, encoding: .utf8) { completion(returnData) } else { completion(“”) } } … Read more

Groovy: isn’t there a stringToMap out of the box?

You might want to try a few of your scenarios using evaluate, it might do what you are looking for. def stringMap = “[‘a’:2,’b’:4]” def map = evaluate(stringMap) assert map.a == 2 assert map.b == 4 def stringMapNested = “[‘foo’:’bar’, baz:[‘alpha’:’beta’]]” def map2 = evaluate(stringMapNested) assert map2.foo == “bar” assert map2.baz.alpha == “beta”

How to check if a string contains an int? -Swift

You can use Foundation methods with Swift strings, and that’s what you should do here. NSString has built in methods that use NSCharacterSet to check if certain types of characters are present. This translates nicely to Swift: var str = “Hello, playground1” let decimalCharacters = CharacterSet.decimalDigits let decimalRange = str.rangeOfCharacter(from: decimalCharacters) if decimalRange != nil … Read more

Split string with bash with symbol

Using Parameter Expansion: str=”test1@test2″ echo “${str#*@}” The # character says Remove the smallest prefix of the expansion matching the pattern. The % character means Remove the smallest suffix of the expansion matching the pattern. (So you can do “${str%@*}” to get the “test1” part.) The / character means Remove the smallest and first substring of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)