Tutorial by Examples

C-style bit-manipulation template <typename T> T rightmostSetBitRemoved(T n) { // static_assert(std::is_integral<T>::value && !std::is_signed<T>::value, "type should be unsigned"); // For c++11 and later return n & (n - 1); } Explanation if...
const CACHE_TAG_NAMESPACE_MODULE = "YOUR_MODULES_CACHE_TAGS"; $cacheGroup = 'namespace_module'; $useCache = Mage::app()->useCache($cacheGroup); if (true === $useCache) { $cacheId = 'unique_name'; if ($cacheContent = Mage::app()->loadCache($cacheId)) { $html ...
Mage::app()->removeCache($cacheId); Flush all Magento cache entries Mage::app()->cleanCache() or: Mage::app()->getCacheInstance()->flush();
Redis configuration: Install redis (2.4+ required) Install phpredis Install the Magento extension Cm_Cache_Backend_Redis (only for Magento 1.7 and below) Edit your app/etc/local.xml: <global> ... <cache> <backend>Cm_Cache_Backend_Redis</backend> <b...
NSArray *a = @[@1]; a = [a arrayByAddingObject:@2]; a = [a arrayByAddingObjectsFromArray:@[@3, @4, @5]]; These methods are optimized to recreate the new array very efficiently, usually without having to destroy the original array or even allocate more memory.
Detailed instructions on getting gis set up or installed.
You can set a ColdFusion variable using the <cfset> tag. To output the variable, you need to surround the variable name with hash # symbols and enclose it within <cfoutput> tags. <cfset variablename="World!"> <cfoutput> Hello #variablename# </cfoutput>...
The <cfparam> tag creates a variable if it does not already exist. You can assign a default value using the default attribute. This can be used if you want to create a variable, but don't want to overwrite it if it has been previously created elsewhere. Here the variable hasn't been set previ...
You can check if a variable has been defined in a scope by using ColdFusion's built in StructKeyExists() function. This can be used inside a <cfif> tag to prevent error messages in the event you attempt to refer to a variable that does not exist. You can also use this function to determine whe...
public class Producer { private static Random random = new Random((int)DateTime.UtcNow.Ticks); //produce the value that will be posted to buffer block public double Produce ( ) { var value = random.NextDouble(); Console.WriteLine($"Producing value: {value}...
We can draw a connection between the Haskell types and the natural numbers. This connection can be made assigning to every type the number of inhabitants it has. Finite union types For finite types, it suffices to see that we can assign a natural type to every number, based in the number of constr...
The addition and multiplication have equivalents in this type algebra. They correspond to the tagged unions and product types. data Sum a b = A a | B b data Prod a b = Prod a b We can see how the number of inhabitants of every type corresponds to the operations of the algebra. Equivalently, we...
Lists Lists can be defined as: data List a = Nil | Cons a (List a) If we translate this into our type algebra, we get List(a) = 1 + a * List(a) But we can now substitute List(a) again in this expression multiple times, in order to get: List(a) = 1 + a + a*a + a*a*a + a*a*a*a + ... ...
The derivative of a type is the type of its type of one-hole contexts. This is the type that we would get if we make a type variable disappear in every possible point and sum the results. As an example, we can take the triple type (a,a,a), and derive it, obtaining data OneHoleContextsOfTriple = (a...
Functions can be seen as exponentials in our algebra. As we can see, if we take a type a with n instances and a type b with m instances, the type a -> b will have m to the power of n instances. As an example, Bool -> Bool is isomorphic to (Bool,Bool), as 2*2 = 2². iso1 :: (Bool -> Bool) -...
You can, of course, return lists from subs: sub foo { my @list1 = ( 1, 2, 3 ); my @list2 = ( 4, 5 ); return ( @list1, @list2 ); } my @list = foo(); print @list; # 12345 But it is not the recommended way to do that unless you know what you are doing. While th...
The auto keyword by itself represents a value type, similar to int or char. It can be modified with the const keyword and the & symbol to represent a const type or a reference type, respectively. These modifiers can be combined. In this example, s is a value type (its type will be inferred as s...
Usage Sometimes, you could have to debug code in another PhpStorm project, you have to update the configuration. PHP configuration In php.ini, edit file and put xdebug.remote_autostart = 1 PhpStorm configuration You also have to configure your IDE: In the phpStorm configuration, Max. sim...
The most important consequence of the One Definition Rule is that non-inline functions with external linkage should only be defined once in a program, although they can be declared multiple times. Therefore, such functions should not be defined in headers, since a header can be included multiple tim...
Lets use the same code as above for this example. #include <iostream> void fail() { int *p1; int *p2(NULL); int *p3 = p1; if (p3) { std::cout << *p2 << std::endl; } } int main() { fail(); } First lets compile it g++ -g -o main m...

Page 671 of 1336