Tutorial by Examples

Here we consider sums of the form a + b + a + b + ... a vs. a + b + a + b + ... b To visualize these sums, imagine a section of fence alternating between posts and rails. Three scenarios are possible. Imagine a section of fence with posts at each end, connected by rails. n rails require...
Normally Android-SQLiteOpenHelper does not allow fully qualified path names where the database should be stored. So public database files are not possible. You can use the SQLiteOpenHelper with a custom path if you provide a custom ContextClass and if you have write access in the target directory. ...
Mockito provides a Matcher<T> interface along with an abstract ArgumentMatcher<T> class to verify arguments. It uses a different approach to the same use-case than the ArgumentCaptor. Additionally the ArgumentMatcher can be used in mocking too. Both use-cases make use of the Mockito.argT...
Here this will calculate the UTC time offset from current data in desired timezone. +(NSTimeInterval)getUTCOffSetIntervalWithCurrentTimeZone:(NSTimeZone *)current forDate:(NSDate *)date { NSTimeZone *utcTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; NSInteger currentG...
Checking whether the current date contains the symbol for AM or PM Objective-C NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[NSLocale currentLocale]]; [formatter setDateStyle:NSDateFormatterNoStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; NSStr...
Declare JNDI resource in tomcat's server.xml, using the Tomcat JDBC connection pool: <GlobalNamingResources> <Resource name="jdbc/DatabaseName" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" auth="Container" ...
There are many ways to return a Date from a DateTime object SELECT CONVERT(Date, GETDATE()) SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) returns 2016-07-21 00:00:00.000 SELECT CAST(GETDATE() AS DATE) SELECT CONVERT(CHAR(10),GETDATE(),111) SELECT FORMAT(GETDATE(), 'yyyy-MM-dd') Note th...
ByVal keyword before method parameter (or no keyword as ByVal is assumed by default) says that parameter will be sent in a way not allowing the method to change (assign a new value) the variable underlying the parameter. It doesn't prevent the content (or state) of the argument to be changed if it'...
ByRef keyword before method parameter says that parameter will be sent in a way allowing the method to change (assign a new value) the variable underlying the parameter. Class SomeClass Public Property Member As Integer End Class Module Program Sub Main() Dim someInstance As ...
Structs // Structs use UpperCamelCase. pub struct Snafucator { } mod snafucators { // Try to avoid 'stuttering' by repeating // the module name in the struct name. // Bad: pub struct OrderedSnafucator { } // Good: pub struct Ordered { ...
Pooling provides a higher level abstraction of the Worker functionality, including the management of references in the way required by pthreads. From: http://php.net/manual/en/class.pool.php Pools and workers provide an higher level of control and ease of creating multi-threaded <?php // T...
If you wish to make a complete backup of a large MySql installation and do not have sufficient local storage, you can dump and compress it directly to an Amazon S3 bucket. It's also a good practice to do this without having the DB password as part of the command: mysqldump -u root -p --host=localho...
The UMD (Universal Module Definition) pattern is used when our module needs to be imported by a number of different module loaders (e.g. AMD, CommonJS). The pattern itself consists of two parts: An IIFE (Immediately-Invoked Function Expression) that checks for the module loader that is being i...
Immediately invoked function expressions can be used to create a private scope while producing a public API. var Module = (function() { var privateData = 1; return { getPrivateData: function() { return privateData; } }; })(); Module.getPrivateData(); // 1 Module.priva...
AMD is a module definition system that attempts to address some of the common issues with other systems like CommonJS and anonymous closures. AMD addresses these issues by: Registering the factory function by calling define(), instead of immediately executing it Passing dependencies as an array...
CommonJS is a popular modularization pattern that's used in Node.js. The CommonJS system is centered around a require() function that loads other modules and an exports property that lets modules export publicly accessible methods. Here's an example of CommonJS, we'll load Lodash and Node.js' fs m...
Add the gradle dependency in app-level build.gradle compile 'com.android.volley:volley:1.0.0' Also, add the android.permission.INTERNET permission to your app's manifest. **Create Volley RequestQueue instance singleton in your Application ** public class InitApplication extends Application { ...
This example shows how to develop our first application step by step, assuming you already have Sails installed and a project created. Create an empty controller file by typing $ sails generate controller hello Find the new controller file at api/controllers/HelloControllers.js and add th...
Audio stream types There are different profiles of ringtone streams. Each one of them has it's different volume. Every example here is written for AudioManager.STREAM_RING stream type. However this is not the only one. The available stream types are: STREAM_ALARM STREAM_DTMF STREAM_MUSIC STR...
An example of "before" middleware would be as follows: <?php namespace App\Http\Middleware; use Closure; class BeforeMiddleware { public function handle($request, Closure $next) { // Perform action return $next($request); } } while &quot...

Page 632 of 1336