Tutorial by Examples: ast

You can do a permissions check when sending an Intent to a registered broadcast receiver. The permissions you send are cross-checked with the ones registered under the tag. They restrict who can send broadcasts to the associated receiver. To send a broadcast request with permissions, specify the p...
Use Spliterators.spliterator() or Spliterators.spliteratorUnknownSize() to convert an iterator to a stream: Iterator<String> iterator = Arrays.asList("A", "B", "C").iterator(); Spliterator<String> spliterator = Spliterators.spliteratorUnknownSize(itera...
To initialize a static final fields that require using more than a single expression, a static initializer can be used to assign the value. The following example initializes a unmodifiable set of Strings: public class MyClass { public static final Set<String> WORDS; static {...
Person = Struct.new :name do def greet(someone) "Hello #{someone}! I am #{name}!" end end Person.new('Alice').greet 'Bob' # => "Hello Bob! I am Alice!"
JSON is textual format, so it is stored in standard NVARCHAR columns. NoSQL collection is equivalent to two column key value table: CREATE TABLE ProductCollection ( Id int identity primary key, Data nvarchar(max) ) Use nvarchar(max) as you are not sure what would be the size of your JSON ...
SQL Server 2012 It converts value to specified data type and if conversion fails it returns NULL. For example, source value in string format and we need it in double/integer format. Then this will help us in achieving it. Syntax: TRY_CAST ( expression AS data_type [ ( length ) ] ) TRY_CAST() retu...
The Cast() function is used to convert a data type variable or data from one data type to another data type. Syntax CAST ( [Expression] AS Datatype) The data type to which you are casting an expression is the target type. The data type of the expression from which you are casting is the source ty...
When performance is a concern, invoking a method via reflection (i.e. via the MethodInfo.Invoke method) is not ideal. However, it is relatively straightforward to obtain a more performant strongly-typed delegate using the Delegate.CreateDelegate function. The performance penalty for using reflecti...
Any String can be evaluated at runtime. class Example def self.foo :foo end end eval "Example.foo" #=> :foo
In Internet Explorer 10+ and Edge, Microsoft provides the -ms-high-contrast media selector to expose the "High Contrast" setting from the browser, which allows the programmer to adjust their site's styles accordingly. The -ms-high-contrast selector has 3 states: active, black-on-white, ...
The @switch annotation tells the compiler that the match statement can be replaced with a single tableswitch instruction at the bytecode level. This is a minor optimization that can remove unnecessary comparisons and variable loads during runtime. The @switch annotation works only for matches again...
This is relevant for apps that implement a BootListener. Test your app by killing your app and then test with: adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n your.app/your.app.BootListener (replace your.package/your.app.BootListener with proper ...
NSMutableDictionary *attributesDictionary = [NSMutableDictionary dictionary]; [attributesDictionary setObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName]; //[attributesDictionary setObject:[UIColor redColor] forKey:NSForegroundColorAttributeName]; NSMutableAttributedString *attri...
public static async Task<IRandomAccessStream> ConvertWriteableBitmapToRandomAccessStream(WriteableBitmap writeableBitmap) { var stream = new InMemoryRandomAccessStream(); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); Stream pixe...
A BroadcastReceiver is basically a mechanism to relay Intents through the OS to perform specific actions. A classic definition being "A Broadcast receiver is an Android component which allows you to register for system or application events." LocalBroadcastManager is a way to send ...
You can communicate two activities so that Activity A can be notified of an event happening in Activity B. Activity A final String eventName = "your.package.goes.here.EVENT"; @Override protected void onCreate(Bundle savedInstanceState) { registerEventReceiver(); super.onCre...
A use case that comes across frequently, is creating a String from a stream, where the stream-items are separated by a certain character. The Collectors.joining() method can be used for this, like in the following example: Stream<String> fruitStream = Stream.of("apple", "banana...
You can select the last day of month. SELECT (date_trunc('MONTH', ('201608'||'01')::date) + INTERVAL '1 MONTH - 1 day')::DATE; 201608 is replaceable with a variable.
Ordinary Least Squares is a method for finding the linear combination of features that best fits the observed outcome in the following sense. If the vector of outcomes to be predicted is y, and the explanatory variables form the matrix X, then OLS will find the vector β solving minβ|y^ - y|22, w...
$ mysqlimport --fields-optionally-enclosed-by='"' --fields-terminated-by=, --lines-terminated-by="\r\n" mycompany employee.csv

Page 17 of 26