Tutorial by Examples: f

Self types can be used in traits and classes to define constraints on the concrete classes it is mixed to. It is also possible to use a different identifier for the this using this syntax (useful when outer object has to be referenced from an inner object). Assume you want to store some objects. Fo...
#!/bin/bash FILENAME="/etc/passwd" while IFS=: read -r username password userid groupid comment homedir cmdshell do echo "$username, $userid, $comment $homedir" done < $FILENAME In unix password file, user information is stored line by line, each line consisting of i...
In Object Oriented Programming a common task is to compose objects (values). In Functional Programming it is as common task to compose values as well as functions. We are used to compose values from our experience of other programming languages using operators like +, -, *, / and so on. Value co...
In a statically typed language like F# we work with types well-known at compile-time. We consume external data sources in a type-safe manner using type providers. However, occassionally there's need to use late binding (like dynamic in C#). For instance when working with JSON documents that have...
Assumptions: TableView - reference to the TableView DataSource - is a class which inherits UITableViewSource DataSource.Objects - is a public List< object >(), accessible to the UIViewController private UIRefreshControl refreshControl; public override void ViewDidLoad() { base.V...
A for loop iterates from the starting value to the ending value inclusive. program SimpleForLoop; {$APPTYPE CONSOLE} var i : Integer; begin for i := 1 to 10 do WriteLn(i); end. Output: 1 2 3 4 5 6 7 8 9 10
This example demonstrates POSIX Timer usage with CLOCK_REALTIME clock and SIGEV_THREAD notification method. #include <stdio.h> /* for puts() */ #include <string.h> /* for memset() */ #include <unistd.h> /* for sleep() */ #include <stdlib.h> /* for EXIT_SUCCESS */ #inc...
C# using OpenQA.Selenium using OpenQA.Selenium.Chrome; using System.Threading; namespace WebDriver Tests { class WebDriverWaits { static void Main() { IWebDriver driver = new ChromeDriver(@"C:\WebDriver"); driver.Na...
scrollViewDidEndDecelerating: this tells the delegate that the scroll view has ended decelerating the scrolling movement. Objective C: - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self stoppedScrolling]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView w...
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...
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...
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 ...
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...
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 { ...

Page 211 of 457