What is an optional value in Swift?

What is an optional value in Swift?

From Apple's documentation: You can use if and let together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that the value is missi

jQuery selector regular expressions

jQuery selector regular expressions

I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector.I have looked for this myself but have been unable to find information on the syntax and how to use it. Does anyone

How do I match any character across multiple lines in a regular expression?

How do I match any character across multiple lines in a regular expression?

For example, this regex(.*)will match:abcdeBut how do I get it to match across multiple lines?abcdefghij 1:It depends on the language, but there should be a modifier that you can add to the regex pattern. In PHP i

What is the Windows version of cron?

What is the Windows version of cron?

A Google search turned up software that performs the same functions as cron, but nothing built into Windows.I'm running Windows XP Professional, but advice for any version of Windows would be potentially helpful to someone.Is there also a w

Replace preg_replace() e modifier with preg_replace_callback

Replace preg_replace() e modifier with preg_replace_callback

I'm terrible with regular expressions. I'm trying to replace this:public static function camelize($word) { return preg_replace('/(^|_)([a-z])/e', 'strtoupper("\\2")', $word);}with preg_replace_callback with an anonymous function. I don't

Is there any difference between 'valid xml' and 'well formed xml'?

Is there any difference between 'valid xml' and 'well formed xml'?

I wasn't aware of a difference, but a coworker says there is, although he can't back it up. What's the difference if any? 1:There is a difference, yes. Xml that adheres to the xml standard is considered well formed, while xml that adhere

Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the re

Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the re

I am trying to do authorization using JavaScript by connecting to the RESTful API built in Flask. However, when I make the request, I get the following error: XMLHttpRequest cannot load http://myApiUrl/login. No 'Access-Control-Allow-Origi

Reference - What does this regex mean?

Reference - What does this regex mean?

What is this?This is a collection of common Q&A. This is also a Community Wiki, so everyone is invited to participate in maintaining it.Why is this?regex is suffering from give me ze code type of questions and poor answers with no explanati

Anonymous variables in Erlang

Anonymous variables in Erlang

What are the exact differences between underscore variables and a named variable that starts with underscore from the Erlang compiler point of view (apart from adding readability to the code)?For example are _ and _Var different? 1:The d

Calculate timespan in JavaScript

Calculate timespan in JavaScript

I have a .net 2.0 ascx control with a start time and end time textboxes. The data is as follows: txtStart.Text = 09/19/2008 07:00:00txtEnd.Text = 09/19/2008 05:00:00I would like to calculate the total time (hours and minutes) in JavaScript

Will ASP.Net MVC's AntiForgeryToken Method work with Load Balancers?

Will ASP.Net MVC's AntiForgeryToken Method work with Load Balancers?

Using ASP.Net MVC v2.0, I am starting to research the use of the Html.AntiForgeryToken() method when submitting forms that process data. I can see it sets a hidden value in the form HTML and it sets the same value in a session cookie. The q

Which file is Perl's diamond operator (null file handle) currently reading from?

Which file is Perl's diamond operator (null file handle) currently reading from?

I'm using Perl's diamond operator to read from files specified on the command line.I'd like to be able to report messages like "Trouble on line $. of file $FILENAME", but how can I tell which file is currently used by the diamond? 1:Se

Facebook Uncaught SecurityError

Facebook Uncaught SecurityError

I'm currently looking to make a Facebook JavaScript App. As such I'm literally just copy pasting out of the docs into my page and I keep getting the following errors in the console:Uncaught SecurityError: Blocked a frame with origin "http:/

Among Find, Single, First, which one is the fastest?

Among Find, Single, First, which one is the fastest?

I want to minimize the time needed to retrieve a single unique element from a list.Which one is the fastest method among Find, Single and First?Note that the searching key is a unique id. 1:The fastest (for a large set) would be to have

How to combine filter and map in scala?

How to combine filter and map in scala?

I have List[Int] in Scala. The List is List(1,2,3,4,5,6,7,8,9,10). I want to filter the list so that it only has even numbers. And I want to muliply the numbers with 2. Is it possible?I hope I have explained the question clearly. If u have

resize with averaging or rebin a numpy 2d array

resize with averaging or rebin a numpy 2d array

I am trying to reimplement in python an IDL function:http://star.pst.qub.ac.uk/idl/REBIN.htmlwhich downsizes by an integer factor a 2d array by averaging.For example:>>> a=np.arange(24).reshape((4,6))>>> aarray([[ 0, 1, 2, 3, 4, 5],

jquery select first child with class of a parent with class

jquery select first child with class of a parent with class

How can i select only the first child of a particular class of a parent with a particular class for the purposes of clone()? SELECT THIS DIV NOT THIS DIV I am trying like this:var form1 = $(this) .parents('.sector_or

Better way to filter a data frame with dplyr using OR?

Better way to filter a data frame with dplyr using OR?

I have a data frame in R with columns subject1 and subject2 (which contain Library of Congress subject headings). I'd like to filter the data frame by testing whether the subjects match an approved list. Say, for example, that I have this d

ack-grep: chars escaping

ack-grep: chars escaping

My goal is to find all "" occurrences with ack. How can I do that?ack "Doesn't work. Please tell me how can I fix escaping here? 1:Since ack uses Perl regular expressions, your problem stems from the fact that in Perl RegEx language, ? i

How can I get MIME type of an InputStream of a file that is being uploaded?

How can I get MIME type of an InputStream of a file that is being uploaded?

Simple question: how can I get MIME type (or content type) of an InputStream, without saving file, for a file that a user is uploading to my servlet? 1:It depends on where you are getting the input stream from. If you are getting it from

add class via jquery but only when not exists

add class via jquery but only when not exists

I would like to add a class (class="bbox") to a ul-list but only if no class exists.This is what i have so far. How do I check with jquery if a class exists in the ul-tag?$("ul").addClass("bbox"); 1:If you want to check if a specific cla

How do I query for fields containing a given text in MySQL?

How do I query for fields containing a given text in MySQL?

SELECT stuff REGEXP 'itunes' as is_itunes;In this MySQL query, if "stuff" has the word "itunes" in it, it will mark it as itunes.However, I want to say "begin with". How can I check for "begin with" instead of anywhere in the text? 1:SEL

MongoDb near/geonear query with variable distance

MongoDb near/geonear query with variable distance

I would like to execute a query where the distance is a dynamic field from the collection.Example of entries in the collection:{ name:'myName', location: {lat:10, lng:20}, maximumDistance: 10}{ name:'myName2', location: {lat:20, lng:20

PHP: RegEx for string with 3-9 letters and 5-50 numbers

PHP: RegEx for string with 3-9 letters and 5-50 numbers

How can I make a RegEx in PHP that only accepts 3-9 letters (uppercase) and 5-50 numbers?I'm not that good at regular expressions. But this one doesn't work:/[A-Z]{3,9}[0-9]{5,50}/For instance, it matches ABC12345 but not A12345BCAny ideas?

Regular Expression for Password Strength Validation

Regular Expression for Password Strength Validation

I have written a regular expression which could potentially be used for password strength validation:^(?:([A-Z])*([a-z])*(\d)*(\W)*){8,12}$The expression consists of four groups:Zero or more uppercase charactersZero or more lowercase charac