Cross-domain requests stopped working due to no `Access-Control-Allow-Origin` header present in the response

When making calls to a contentservice script I always have sent a callback for JSONP. Since GAS does not support CORS this is the only reliable way to ensure your app doesn’t break when x-domain issues arrive. Making a call in jQuery just add “&callback=?”. It will figure everything else out. var url = “https://script.google.com/macros/s/{YourProjectId}/exec?offset=”+offset+”&baseDate=”+baseDate+”&callback=?”; … Read more

Can somebody give a snippet of “append if not exists” method in swift array?

You can extend RangeReplaceableCollection, constrain its elements to Equatable and declare your method as mutating. If you want to return Bool in case the appends succeeds you can also make the result discardable. Your extension should look like this: extension RangeReplaceableCollection where Element: Equatable { @discardableResult mutating func appendIfNotContains(_ element: Element) -> (appended: Bool, memberAfterAppend: … Read more

is there a elegant way to parse a word and add spaces before capital letters

You can use lookarounds, e.g: string[] tests = { “AutomaticTrackingSystem”, “XMLEditor”, }; Regex r = new Regex(@”(?!^)(?=[A-Z])”); foreach (string test in tests) { Console.WriteLine(r.Replace(test, ” “)); } This prints (as seen on ideone.com): Automatic Tracking System X M L Editor The regex (?!^)(?=[A-Z]) consists of two assertions: (?!^) – i.e. we’re not at the beginning … Read more

Fastest way to test internet connection

Try using P/Invoke to call InternetGetConnectedState. That should tell you whether or not you have a connection configured. You can then try checking the specific connection to your service using InternetCheckConnection. This is (sometimes) quicker than hooking up the connection directly, but I’d test it to see if it’s any better than just doing a … Read more