Tutorial by Examples: ami

Here a simple portable way to get the current device family: /// <summary> /// All the device families /// </summary> public enum DeviceFamily { Desktop, Mobile, Iot, Xbox, } /// <summary> /// The helper to get the current device family /// </summ...
# example data DT = as.data.table(mtcars, keep.rownames = TRUE) To rename a column (while keeping its data the same), there is no need to copy the data to a column with a new name and delete the old one. Instead, we can use setnames(DT, "mpg_sq", "mpq_squared") to modify ...
io-streams is Stream-based library that focuses on the Stream abstraction but for IO. It exposes two types: InputStream: a read-only smart handle OutputStream: a write-only smart handle We can create a stream with makeInputStream :: IO (Maybe a) -> IO (InputStream a). Reading from ...
$router = new \Phalcon\Mvc\Router(false); $router->removeExtraSlashes(true); $request = new \Phalcon\Http\Request(); $action = strtolower($request->getMethod()); // get, post, etc. $modules = ['calendar', 'main', 'user']; // names of the modules you create // you can define other static...
You can execute a database query from a String rather than a regular SOQL expression: String tableName = 'Account'; String queryString = 'SELECT Id FROM ' + tableName + ' WHERE CreatedDate >= YESTERDAY'; List<SObject> objects = Database.query(queryString); Since dynamic SOQL queries a...
Ruby offers define_method as a private method on modules and classes for defining new instance methods. However, the 'body' of the method must be a Proc or another existing method. One way to create a method from raw string data is to use eval to create a Proc from the code: xml = <<ENDXML ...
When we attach the !important keyword to a mixin call, the Less compiler will automatically add the !important to all properties that are present within the mixin. For example, consider the below mixin: .set-default-props() { margin: 4px; padding: 4px; border: 1px solid black; font-wei...
Create a Security class to run your ACL logic. <?php namespace Plugins; use Phalcon\Events\Event; use Phalcon\Mvc\Dispatcher; use Phalcon\Acl; use Phalcon\Acl\Role; use Phalcon\Acl\Resource; use Phalcon\Acl\Adapter\Memory as AclList; class Security extends \Phalcon\Mvc\User\Plugin ...
Description The SQL standard provides two additional aggregate operators. These use the polymorphic value "ALL" to denote the set of all values ​​that an attribute can take. The two operators are: with data cube that it provides all possible combinations than the argument attributes o...
Newtonsoft's Json.NET allows you to bind json dynamically (using ExpandoObject / Dynamic objects) without the need to create the type explicitly. Serialization dynamic jsonObject = new ExpandoObject(); jsonObject.Title = "Merchent of Venice"; jsonObject.Author = "William Shakes...
There’s no API that can rename the blob file on Azure. This code snippet demonstrates how to rename a blob file in Microsoft Azure Blob Storage. StorageCredentials cred = new StorageCredentials("[Your storage account name]", "[Your storage account key]"); CloudBlobContainer c...
CROSS APPLY enables you to "join" rows from a table with dynamically generated rows returned by some table-value function. Imagine that you have a Company table with a column that contains an array of products (ProductList column), and a function that parse these values and returns a set ...
There is no single command to rename a MySQL database but a simple workaround can be used to achieve this by backing up and restoring: mysqladmin -uroot -p<password> create <new name> mysqldump -uroot -p<password> --routines <old name> | mysql -uroot -pmypassword <new na...
Renaming a table can be done in a single command: RENAME TABLE `<old name>` TO `<new name>`; The following syntax does exactly the same: ALTER TABLE `<old name>` RENAME TO `<new name>`; If renaming a temporary table, the ALTER TABLE version of the syntax must be used....
Renaming a column can be done in a single statement but as well as the new name, the "column definition" (i.e. its data type and other optional properties such as nullability, auto incrementing etc.) must also be specified. ALTER TABLE `<table name>` CHANGE `<old name>` `<n...
There are a few ways to inspect the contents of a zipfile. You can use the printdir to just get a variety of information sent to stdout with zipfile.ZipFile(filename) as zip: zip.printdir() # Out: # File Name Modified Size ...
Dynamic SQL enables us to generate and run SQL statements at run time. Dynamic SQL is needed when our SQL statements contains identifier that may change at different compile times. Simple Example of dynamic SQL: CREATE PROC sp_dynamicSQL @table_name NVARCHAR(20), @col_name NVARCHAR(2...
Important: Using the dynamic configuration files (.htaccess) is a big performance hit. When you have access to the static configuration file (httpd.conf or something similar) you should use that instead. In the static configuration file, allow dynamic configuration files to override "Filei...
To prevent memory leaks, one should not forget to close an input stream or an output stream whose job is done. This is usually done with a try-catch-finally statement without the catch part: void writeNullBytesToAFile(int count, String filename) throws IOException { FileOutputStream out = null...
DASH is the most widely deployed adaptive streaming technology in modern solutions, used to deliver video in a wide variety of scenarios. The best way to understand DASH presentations is to observe the network activity that takes place during playback. This example uses Fiddler to capture and analy...

Page 6 of 11