Tutorial by Examples: c

Macros are categorized into two main groups: object-like macros and function-like macros. Macros are treated as a token substitution early in the compilation process. This means that large (or repeating) sections of code can be abstracted into a preprocessor macro. // This is an object-like macro ...
In PowerShell, there are many ways to achieve the same result. This can be illustrated nicely with the simple & familiar Hello World example: Using Write-Host: Write-Host "Hello World" Using Write-Output: Write-Output 'Hello world' It's worth noting that although Write-Outp...
./mongo localhost:27017/mydb myjsfile.js Explanation: This operation executes the myjsfile.js script in a mongo shell that connects to the mydb database on the mongod instance accessible via the localhost interface on port 27017. localhost:27017 is not mandatory as this is the default port mongo...
To make all the characters in a String uppercase or lowercase: 2.2 let text = "AaBbCc" let uppercase = text.uppercaseString // "AABBCC" let lowercase = text.lowercaseString // "aabbcc" 3.0 let text = "AaBbCc" let uppercase = text.uppercased() // &qu...
It can also be installed by downloading the source code and placing it in a directory of your project. However there are many benefits to using composer. require '/path/to/lib/Twig/Autoloader.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('/path/to/templates'); $opti...
$sku = 'sku-goes-here'; $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$id = 1; $product = Mage::getModel('catalog/product')->load($id); if($product->getId()){ //product was found }
$collection = Mage::getModel('catalog/product')->getCollection(); $collection->addAttributeToFilter('sku', array('like' => 'UX%'));
$collection = Mage::getModel('catalog/product')->getCollection(); // Using operator $collection->addAttributeToFilter('status', array('eq' => 1)); // Without operator (automatically uses 'equal' operator $collection->addAttributeToFilter('status', 1);
If you are matching on an Option type: def f(x: Option[Int]) = x match { case Some(i) => doSomething(i) case None => doSomethingIfNone } This is functionally equivalent to using fold, or map/getOrElse: def g(x: Option[Int]) = x.fold(doSomethingIfNone)(doSomething) def h(x: ...
If you want to add custom.js script that is located in the js/ folder of your theme, you'll need to enqueue it. In functions.php add <?php add_action( 'after_setup_theme', 'yourtheme_theme_setup' ); if ( ! function_exists( 'yourtheme_theme_setup' ) ) { function yourtheme_theme_setup()...
Factors are one way to represent categorical variables in R. A factor is stored internally as a vector of integers. The unique elements of the supplied character vector are known as the levels of the factor. By default, if the levels are not supplied by the user, then R will generate the set of uniq...
When a column name matches a reserved keyword, standard SQL requires that you enclose it in double quotation marks: SELECT "ORDER", ID FROM ORDERS Note that it makes the column name case-sensitive. Some DBMSes have proprietary ways of quoting names. For example, SQL Serve...
Some convenience functions to manipulate data.frames are subset(), transform(), with() and within(). subset The subset() function allows you to subset a data.frame in a more convenient way (subset also works with other classes): subset(mtcars, subset = cyl == 6, select = c("mpg", "...
This will delete all rows that match the WHERE criteria. DELETE FROM Employees WHERE FName = 'John'
Functions can be written using several types of syntax function name() integer name name = 42 end function integer function name() name = 42 end function function name() result(res) integer res res = 42 end function Functions return values through a function result....
In the VBA Editor window, from the Tools menu select "Options": Then in the "Editor" tab, make sure that "Require Variable Declaration" is checked: Selecting this option will automatically put Option Explicit at the top of every VBA module. Small note: This is ...
When pattern matching an object whose type is a sealed trait, Scala will check at compile-time that all cases are 'exhaustively matched': sealed trait Shape case class Square(height: Int, width: Int) extends Shape case class Circle(radius: Int) extends Shape case object Point extends Shape ...
A popular form of data analysis is split-apply-combine, in which you split your data into groups, apply some sort of processing on each group, and then combine the results. Let's consider a data analysis where we want to obtain the two cars with the best miles per gallon (mpg) for each cylinder cou...
In many cases, the Razor parser is smart enough to figure out when the @ sign is meant to be used as part of code, as opposed to being part of something like an email address. In the example below, escaping the @ sign is not necessary: <p>Reach out to us at [email protected]</p> Howev...

Page 82 of 826