Tutorial by Examples

To convert NSString to const char use -[NSString UTF8String]: NSString *myNSString = @"Some string"; const char *cString = [myNSString UTF8String]; You could also use -[NSString cStringUsingEncoding:] if your string is encoded with something other than UTF-8. For the reverse path use...
This command will display all the registered Valet links you have created and their corresponding file paths on your computer. Command: valet links Sample Output: ... site1 -> /path/to/site/one site2 -> /path/to/site/two ... Note 1: You can run this command from anywhere not just f...
Implicit classes make it possible to add new methods to previously defined classes. The String class has no method withoutVowels. This can be added like so: object StringUtil { implicit class StringEnhancer(str: String) { def withoutVowels: String = str.replaceAll("[aeiou]", &quo...
#include <iostream> #include <functional> std::function<void(int , const std::string&)> myFuncObj; void theFunc(int i, const std::string& s) { std::cout << s << ": " << i << std::endl; } int main(int argc, char *argv[]) { m...
Think about a situation where we need to callback a function with arguments. std::function used with std::bind gives a very powerful design construct as shown below. class A { public: std::function<void(int, const std::string&)> m_CbFunc = nullptr; void foo() { ...
The $_FILES["FILE_NAME"]['error'] (where "FILE_NAME" is the value of the name attribute of the file input, present in your form) might contain one of the following values: UPLOAD_ERR_OK - There is no error, the file uploaded with success. UPLOAD_ERR_INI_SIZE - The uploaded fi...
Assumptions for this example: You have a class, foo.bar.Baz. You'd like to create a run configuration that runs the main method. It's in a module called fooBar. In your gradle file: idea { workspace.iws.withXml { provider -> // I'm not actually sure why this is necessar...
Detailed instructions on getting model-view-controller set up or installed.
Redirect any naked domain to www.[your_domain].tld: # Start Apache Rewriting engine RewriteEngine On # Make sure you're not already using www subdomain # and that the host string is not empty RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. # We check for http/https connection ...
insert :: Ord a => a -> [a] -> [a] insert x [] = [x] insert x (y:ys) | x < y = x:y:ys | otherwise = y:(insert x ys) isort :: Ord a => [a] -> [a] isort [] = [] isort (x:xs) = insert x (isort xs) Example use: > isort [5,4,3,2,1] Result: [1,2,3,4...
Ordered merging of two ordered lists Preserving the duplicates: merge :: Ord a => [a] -> [a] -> [a] merge xs [] = xs merge [] ys = ys merge (x:xs) (y:ys) | x <= y = x:merge xs (y:ys) | otherwise = y:merge (x:xs) ys Top-down version: msort :: Ord a => [...
qsort :: (Ord a) => [a] -> [a] qsort [] = [] qsort (x:xs) = qsort [a | a <- xs, a < x] ++ [x] ++ qsort [b | b <- xs, b >= x]
XML pre-defines five general entities that can be used without declaring them: & " ' < > They are associated with the names amp, quot, apos, lt and gt. <?xml version="1.0"?> <entities> & is an ampersand. " is a quote. ' is...
It is possible to define one's own general entities. The declaration occurs in the DTD subset, with a name and the associated replacement text. It can then be used in the document using the entity reference syntax &...;, either in text, or in attribute values. <?xml version="1.0"?...
Show the changes between the tip of new and the tip of original: git diff original new # equivalent to original..new Show all changes on new since it branched from original: git diff original...new # equivalent to $(git merge-base original new)..new Using only one parameter such as ...
This is the most basic version of a trait in Scala. trait Identifiable { def getIdentifier: String def printIndentification(): Unit = println(getIdentifier) } case class Puppy(id: String, name: String) extends Identifiable { def getIdentifier: String = s"$name has id $id" } ...
The HasFlag() method can be used to check if a flag is set. Module Module1 <Flags> Enum Material Wood = 1 Plastic = 2 Metal = 4 Stone = 8 End Enum Sub Main() Dim houseMaterials As Material = Material.Wood Or Material.Stone ...
Bash indirection permits to get the value of a variable whose name is contained in another variable. Variables example: $ red="the color red" $ green="the color green" $ color=red $ echo "${!color}" the color red $ color=green $ echo "${!color}" the ...
${parameter:-word} If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted. $ unset var $ echo "${var:-XX}" # Parameter is unset -> expansion XX occurs XX $ var="" # Parameter is null ...
The semantics for this are similar to that of default value substitution, but instead of substituting a default value, it errors out with the provided error message. The forms are ${VARNAME?ERRMSG} and ${VARNAME:?ERRMSG}. The form with : will error our if the variable is unset or empty, whereas the ...

Page 284 of 1336