Tutorial by Examples: er

You can create a CALayer and set its frame like this: Swift: let layer = CALayer() layer.frame = CGRect(x: 0, y: 0, width: 60, height: 80) Objective-C: CALayer *layer = [[CALayer alloc] init]; layer.frame = CGRectMake(0, 0, 60, 80); You can then add it as a sublayer to an existing CALayer...
Note that you cannot overload a function based on its return type. For example: // WRONG CODE std::string getValue() { return "hello"; } int getValue() { return 0; } int x = getValue(); This will cause a compilation error as the compiler will not be able to work out wh...
It is also possible to write a context manager using generator syntax thanks to the contextlib.contextmanager decorator: import contextlib @contextlib.contextmanager def context_manager(num): print('Enter') yield num + 1 print('Exit') with context_manager(2) as cm: # the ...
Intents can be used to broadcast messages to other components of your application (such as a running background service) or to the entire Android system. To send a broadcast within your application, use the LocalBroadcastManager class: Intent intent = new Intent("com.example.YOUR_ACTION"...
This code selects data out of a table and displays it in the query tool (usually SSMS) SELECT Column1, Column2, Column3 FROM MySourceTable; This code inserts that data into a table: INSERT INTO MyTargetTable (Column1, Column2, Column3) SELECT Column1, Column2, Column3 FROM MySourceTable;
Since C# 6.0 exceptions can be filtered using the when operator. This is similar to using a simple if but does not unwind the stack if the condition inside the when is not met. Example try { // ... } catch (Exception e) when (e.InnerException != null) // Any condition can go in here. { ...
You can access SharedPreferences in several ways: Get the default SharedPreferences file: import android.preference.PreferenceManager; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Get a specific SharedPreferences file: public static final String PREF_FILE_NAM...
The shift operators allow programmers to adjust an integer by shifting all of its bits to the left or the right. The following diagram shows the affect of shifting a value to the left by one digit. Left-Shift uint value = 15; // 00001111 uint doubled = value << 1; // Resu...
You can use the CONVERT function to cast a datetime datatype to a formatted string. SELECT GETDATE() AS [Result] -- 2016-07-21 07:56:10.927 You can also use some built-in codes to convert into a specific format. Here are the options built into SQL Server: DECLARE @convert_code INT = 100 -- See ...
@Provider public class CORSResponseFilter implements ContainerResponseFilter { public void filter( ContainerRequestContext requestContext, ContainerResponseContext responseContext ) throws IOException { MultivaluedMap<String, Object> headers = responseCo...
The display CSS property is fundamental for controlling the layout and flow of an HTML document. Most elements have a default display value of either block or inline (though some elements have other default values). Inline An inline element occupies only as much width as necessary. It stacks horiz...
When creating a recyclerview with a gridlayout layout manager you have to specify the span count in the constructor. Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts f...
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the e...
Define your class that will represent your custom error. public class ErrorDto { public int Code { get; set; } public string Message { get; set; } // other fields public override string ToString() { return JsonConvert.SerializeObject(this); } } Then put nex...
angular.module("app") .service("counterService", function(){ var service = { number: 0 }; return service; });
angular.module("app") // Custom services are injected just like Angular's built-in services .controller("step1Controller", ['counterService', '$scope', function(counterService, $scope) { counterService.number++; // bind to...
DELETE FROM `table_name` WHERE `field_one` = 'value_one' This will delete all rows from the table where the contents of the field_one for that row match 'value_one' The WHERE clause works in the same way as a select, so things like >, <, <> or LIKE can be used. Notice: It is necessa...
CommandDescription<C-w>Delete word before cursor<C-t>Indent current line with by one shiftwidth<C-d>Unindent current line with by one shiftwidth<C-f>reindent the line, (move cursor to auto indent position)<C-a>Insert previously inserted text<C-e>Insert the charact...
In C#, there are two different kinds of equality: reference equality and value equality. Value equality is the commonly understood meaning of equality: it means that two objects contain the same values. For example, two integers with the value of 2 have value equality. Reference equality means that ...
Controller class names are pluralized. The reason is the controller controls multiple instances of object instance. For Example: OrdersController would be the controller for an orders table. Rails will then look for the class definition in a file called orders_controller.rb in the /app/controllers ...

Page 58 of 417