Tutorial by Examples

Add 'exception' as a suffix Custom exception names should be suffixed with "-Exception". Below are correctly named exceptions: public class MyCustomException : Exception public class FooException : Exception
$ jekyll build # The current site folder will be built into the ./_site directory $ jekyll build --destination /var/www/ # The current site folder will be generated into /var/www/ $ jekyll build --watch # The current site folder will be built into the ./_site directory and will be kept up t...
map Overview A key sequence can be re-mapped to another key sequence using one of the map variants. As an example, the following typical map will exit Insert mode when you press jk in quick sequence: :inoremap jk <Esc> map Operator There are multiple variants of :map for different modes...
This will trigger the native email client for sharing text. Parameters : Email To address, Subject, Body. Code Sample : you can call the function wherever you need, (mostly inside click listeners) like below Calling function shareEmail("[email protected]", "Email sharing example&q...
The easiest way to use Processing is by downloading the Processing editor from the Processing download page. That comes as a zip file. Unzip that file anywhere, and you'll have a directory that contains an executable (on Windows, that's processing.exe). Running that executable opens up the Process...
Use a HashMap to store the parameters that should be sent to the server through POST parameters: HashMap<String, String> params; Once the params HashMap is populated, create the StringBuilder that will be used to send them to the server: StringBuilder sbParams = new StringBuilder(); ...
VBA is compiled in run-time, which has a huge negative impact on it's performance, everything built-in will be faster, try to use them. As an example I'm comparing SUM and COUNTIF functions, but you can use if for anything you can solve with WorkSheetFunctions. A first attempt for those would be t...
This example shows how to mock out a function call that is irrelevant to our unit test, and then use the defer statement to re-assign the mocked function call back to its original function. var validate = validateDTD // ParseXML parses b for XML elements and values, and returns them as a map of ...
Although available, defining a class from scratch is not recommended in modern Perl. Use one of helper OO systems which provide more features and convenience. Among these systems are: Moose - inspired by Perl 6 OO design Class::Accessor - a lightweight alternative to Moose Class::Tiny...
In this example we create a goroutine (a function running in a separate thread) that accepts a chan parameter, and simply loops, sending information into the channel each time. In the main we have a for loop and a select. The select will block processing until one of the case statements becomes tru...
So here, I have removed the for loops, and made a timeout by adding a second case to the select that returns after 3 seconds. Because the select just waits until ANY case is true, the second case fires, and then our script ends, and chatter() never even gets a chance to finish. // Use of the select...
Subroutine arguments in Perl are passed by reference, unless they are in the signature. This means that the members of the @_ array inside the sub are just aliases to the actual arguments. In the following example, $text in the main program is left modified after the subroutine call because $_[0] in...
1.7+ Timing out an HTTP request with a context can be accomplished with only the standard library (not the subrepos) in 1.7+: import ( "context" "net/http" "time" ) req, err := http.NewRequest("GET", `https://example.net`, nil) ctx, _ := ...
Use Dojo from CDN Load Dojo through <script> tags in your HTML page pointing to Google CDN. Example: <script src="//ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script> Install Dojo with Bower Type the following command in your project directory: bowe...
Mage::app()->getStores(); Returns an array of Mage_Core_Model_Store models.
To get started quickly with Express, you can use the Express generator which will create an application skeleton for you. First, install it globally with npm: npm install express-generator -g You may need to put sudo before this command if you get a "permission denied" error. Once th...
CPAN.pm is a Perl module which allows to query and install modules from CPAN sites. It supports interactive mode invoked with cpan or perl -MCPAN -e shell Querying modules By name: cpan> m MooseX::YAML By a regex against module name: cpan> m /^XML::/ Note: to enable a pager o...
Command line You can use cpan to install modules directly from the command line: cpan install DBI This would be followed by possibly many pages of output describing exactly what it is doing to install the module. Depending on the modules being installed, it may pause and ask you questions. Int...
NHibernate uses classes to map into tables or views. Creating a Plain Old CLR Object (POCOs, sometimes called Plain Ordinary CLR Objects) is a good practice for persistent classes. A POCO has its data accessible through the standard .NET property mechanisms, shielding the internal representation fro...
The xml mapping uses a hbm.xml file which is a hibernate mapping file. It is a syntax xml file which contains the metadata required for the object/relational mapping. The metadata includes declaration of persistent classes and the mapping of properties (to columns and foreign key relationships to ot...

Page 470 of 1336