Tutorial by Examples: def

context.globalCompositeOperation = "source-over" "source-over" compositing [default], places all new drawings over any existing drawings. context.globalCompositeOperation='source-over'; // the default context.drawImage(background,0,0); context.drawImage(parachuter,0,0); ...
Considering that most debuggers are not aware of #define macros, but can check enum constants, it may be desirable to do something like this: #if __STDC_VERSION__ < 199900L typedef enum { false, true } bool; /* Modern C code might expect these to be macros. */ # ifndef bool # define bool bo...
It took me a while to get this right, so I decided to share a solution because it might save someone else several days of trial and error. The problem: I want to be able to enable/disable WCF tracing in my C# .NET application and choose the trace output filename. I don't want users editing the .con...
You can overload a def if the signature is different: def printValue(x: Int) { println(s"My value is an integer equal to $x") } def printValue(x: String) { println(s"My value is a string equal to '$x'") } printValue(1) // prints "My value is an integer equal ...
<svg width="400px" height="400px"> <defs> <rect id="defrect" fill="blue" fill-opacity=".5" x="50" y="50" width="100" height="100"/> </defs> <rect fill="red" x="...
CREATE TABLE menagerie.bird ( bird_id INT NOT NULL AUTO_INCREMENT, species VARCHAR(300) DEFAULT NULL COMMENT 'You can include genus, but never subspecies.', INDEX idx_species (species) COMMENT 'We must search on species often.', PRIMARY KEY (bird_id) ) ENGINE=InnoDB COMMENT 'Thi...
In features/step_definitions/documentation.rb: When /^I go to the "([^"]+)" documentation$/ do |section| path_part = case section when "Documentation" "documentation" else raise "Unknown documentation section: #{section...
In features/step_definitions/documentation.rb: When /^I go to the "([^"]+)" documentation$/ do |section| path_part = case section when "Documentation" "documentation" else raise "Unknown documentation section: #{section...
get_defined_vars() returns an array with all the names and values of the variables defined in the scope in which the function is called. If you want to print data you can use standard functions for outputting human-readable data, like print_r or var_dump. var_dump(get_defined_vars()); Note: This...
Consider the following partial example: import com.example.somelib.*; import com.acme.otherlib.*; public class Test { private Context x = new Context(); // from com.example.somelib ... } Suppose that when when you first developed the code against version 1.0 of somelib and versi...
In Julia, as in many other languages, it is possible to interpolate by inserting values defined by variables into strings. For a simple example: n = 2 julia> MyString = "there are $n ducks" "there are 2 ducks" We can use other types than numeric, e.g. Result = false j...
trait Speak { fn speak(&self) -> String { String::from("Hi.") } } The method will be called by default except if it's overwritten in the impl block. struct Human; struct Cat; impl Speak for Human {} impl Speak for Cat { fn speak(&self) -> S...
To use default values with **kwargs def fun(**kwargs): print kwargs.get('value', 0) fun() # print 0 fun(value=1) # print 1
Phalcon uses db service by default to obtain connection to databases. Assuming you have an conguration file with database field set up, you can include or autoload following code to obtain connection with database for your project: $di->set('db', function () use ($config) { $dbconf = $conf...
Use the annotation -- @FixMethodOrder(MethodSorters.DEFAULT). This runs all tests within the class in a deterministic and somewhat predictable order. The implementation hashes the method names and compares them. In the scenario of a tie, it sorts by lexicographical order. Code Segment Below Taken f...
In most cases, the range_lookup is used as FALSE (an exact match). The default for this parameter is TRUE - it is less commonly used in this form, but this example shows one usecase. A supermarket gives a bonus based on the customers monthly spend. If the customer spends 250 EUR or more in a mon...
In the example project.json below, an assembly Microsoft.AspNet.Identity.EntityFramework was added which is mscorlib based. { "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "2.2.1", ...
Everybody loves twitter bootstrap, but some of us don't like it's default design. So here's a simple guide on how to start customizing boostrap's design. Twitter boostrap when cloned provides a set of default css files which we can override. The mail css file that we need to override is the boostra...
An internally defined exception doesn't have a name, but it has its own code. When to use it? If you know that your database operation might raise specific exceptions those which don't have names, then you can give them names so that you can write exception handlers specifically for them. Otherwis...
Predefined exceptions are internally defined exceptions but they have names. Oracle database raise this type of exceptions automatically. Example create or replace procedure insert_emp is begin insert into emp (emp_id, ename) values ('1','Jon'); exception when dup_val_on_index then ...

Page 17 of 27