Tutorial by Examples: c

In some cases we want to run an alternative code if the condition is false, for this we use the optional else part: a = 20; if a < 10 disp('a smaller than 10') else disp('a bigger than 10') end Here we see that because a is not smaller than 10 the second part of the code, after t...
/** * @param num Numerator * @param denom Denominator * @throws ArithmeticException in case `denom` is `0` */ class Division @throws[ArithmeticException](/*no annotation parameters*/) protected (num: Int, denom: Int) { private[this] val wrongValue = num / denom /** Integer n...
This simple macro annotation outputs the annotated item as-is. import scala.annotation.{compileTimeOnly, StaticAnnotation} import scala.reflect.macros.whitebox.Context @compileTimeOnly("enable macro paradise to expand macro annotations") class noop extends StaticAnnotation { def m...
Dim Value As Variant Value = CDec(1.234) 'Set Value to the smallest possible Decimal value Value = CDec("0.0000000000000000000000000001") The Decimal data-type is only available as a sub-type of Variant, so you must declare any variable that needs to contain a Decimal as a Variant ...
A const Enum is the same as a normal Enum. Except that no Object is generated at compile time. Instead, the literal values are substituted where the const Enum is used. // Typescript: A const Enum can be defined like a normal Enum (with start value, specifig values, etc.) const enum NinjaActivity ...
sample on price increases: UPDATE ItemPrice SET Price = Price * CASE ItemId WHEN 1 THEN 1.05 WHEN 2 THEN 1.10 WHEN 3 THEN 1.15 ELSE 1.00 END
You may have noticed that many applications have double-back-click functionality to exit the app. In this example, we are overriding the default back button action using the onBackPressed() method override. This method will Toast a message for the single back-click action, and will close the app if...
Paramorphisms model primitive recursion. At each iteration of the fold, the folding function receives the subtree for further processing. para :: Functor f => (f (Fix f, a) -> a) -> Fix f -> a para f = f . fmap (\x -> (x, para f x)) . unFix The Prelude's tails can be modelled as ...
Apomorphisms model primitive corecursion. At each iteration of the unfold, the unfolding function may return either a new seed or a whole subtree. apo :: Functor f => (a -> f (Either (Fix f) a)) -> a -> Fix f apo f = Fix . fmap (either id (apo f)) . f Note that apo and para are dual...
import Test.Tasty import Test.Tasty.SmallCheck as SC import Test.Tasty.QuickCheck as QC import Test.Tasty.HUnit main :: IO () main = defaultMain tests tests :: TestTree tests = testGroup "Tests" [smallCheckTests, quickCheckTests, unitTests] smallCheckTests :: TestTree smal...
First, Install Java SE Development Kit This can be as simple as downloading, double-clicking on the downloaded file, and following the installation instructions. For install Java SE Development Kit download it from official web site. Java SE Development Kit. Downloads After JDK install is complete...
Only the homepage works, all other pages return 404 Make sure mod_rewrite module has been installed in Apache and been enabled to load. See step 2 for info on how to do this here: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04 Make sure the y...
$this->getSkinUrl('images/imagename.gif', array('_secure'=>true));
$this->getSkinUrl('images/imagename.jpg');
Mage::helper('core/url')->getCurrentUrl();
<?php class MyClass { ... } class OtherClass { ... } ?> Any class that has the same name as it's file name will be auto loaded by Silverstripe. OtherClass will be loaded too because it is in a file which is being read. MyPage.php <?php class MyPage_Controller e...
Profiling repetition of elements in an array >>> import timeit >>> timeit.timeit('list(itertools.repeat("a", 100))', 'import itertools', number = 10000000) 10.997665435877963 >>> timeit.timeit('["a"]*100', number = 10000000) 7.118789926862576
Profiling concatanation of numbers python -m timeit "'-'.join(str(n) for n in range(100))" 10000 loops, best of 3: 29.2 usec per loop python -m timeit "'-'.join(map(str,range(100)))" 100000 loops, best of 3: 19.4 usec per loop
The source code with @profile directive before the function we want to profile: import requests @profile def slow_func(): s = requests.session() html=s.get("https://en.wikipedia.org/").text sum([pow(ord(x),3.1) for x in list(html)]) for i in range(50): s...
Description An image maps is an image with clickable areas that usually act as hyperlinks. The image is defined by the <img> tag, and the map is defined by a <map> tag with <area> tags to denote each clickable area. Use the usemap and name attributes to bind the image and the map...

Page 316 of 826