Tutorial by Examples: ect

Reflection is useful when it is properly used for right purpose. By using reflection, you can access private variables and re-initialize final variables. Below is the code snippet, which is not recommended. import java.lang.reflect.*; public class ReflectionDemo{ public static void main(St...
Suppose we want to select a word with a surrounding white space, use the text object aw for around a word using visual mode: Got to normal mode by pressing ESC Type vaw at the beginning of a word This will select the word with white space
Quite often it's necessary to send/upload a file to a remote server, for example, an image, video, audio or a backup of the application database to a remote private server. Assuming the server is expecting a POST request with the content, here's a simple example of how to complete this task in Andro...
You can loop over a Structure or COM collection. <cfset myBooks = StructNew()> <cfset myVariable = StructInsert(myBooks,"ColdFusion","ColdFusion MX Bible")> <cfset myVariable = StructInsert(myBooks,"HTML","HTML Visual QuickStart")> <cf...
To create a libary , you should use File -> New -> New Module -> Android Library. This will create a basic library project. When that's done, you must have a project that is set up the following manner: [project root directory] [library root directory] [gradle] build.gradle...
To use the library, you must include it as a dependency with the following line: compile project(':[library root directory]')
Add the [Serializable] attribute to mark an entire object for binary serialization: [Serializable] public class Vector { public int X; public int Y; public int Z; [NonSerialized] public decimal DontSerializeThis; [OptionalField] public string Name; } All...
Problem In a similar way that SQL injection allows an attacker to execute arbitrary queries on a database, command-line injection allows someone to run untrusted system commands on a web server. With an improperly secured server this would give an attacker complete control over a system. Let's sa...
This is a nice trick to add a link to code, so it will be easy to jump to the code that issued the log. With the following code, this call: MyLogger.logWithLink("MyTag","param="+param); Will result in: 07-26...012/com.myapp D/MyTag: MyFrag:onStart(param=3) (MyFrag.java:236...
This is the basic way to insert data from another table with the SELECT statement. INSERT INTO `tableA` (`field_one`, `field_two`) SELECT `tableB`.`field_one`, `tableB`.`field_two` FROM `tableB` WHERE `tableB`.clmn <> 'someValue' ORDER BY `tableB`.`sorting_clmn`; You can...
Reflection is useful but fragile. Consider this: let mi = typeof<System.String>.GetMethod "StartsWith" The problems with this kind of code are: The code doesn't work because there are several overloads of String.StartsWith Even if there wouldn't be any overloads right now la...
os.mkdir('newdir') If you need to specify permissions, you can use the optional mode argument: os.mkdir('newdir', mode=0700)
Use the os.getcwd() function: print(os.getcwd())
Remove the directory at path: os.rmdir(path) You should not use os.remove() to remove a directory. That function is for files and using it on directories will result in an OSError
All constructors in Java must make a call to the Object constructor. This is done with the call super(). This has to be the first line in a constructor. The reason for this is so that the object can actually be created on the heap before any additional initialization is performed. If you do not spe...
SELECT is used to retrieve rows of data from a table. You can specify which columns will be retrieved: SELECT Name, Position FROM Employees; Or just use * to get all columns: SELECT * FROM Employees;
This query will return all columns from the table sales where the values in the column amount is greater than 10 and the data in the region column in "US". SELECT * FROM sales WHERE amount > 10 AND region = "US" You can use regular expressions to select the columns you wan...
Oozie is developed on a client-server architecture. Oozie server is a Java web application that runs Java servlet container within an embedded Apache Tomcat. Oozie provides three different type of clients to interact with the Oozie server: Command Line, Java Client API and HTTP REST API. Oozie serv...
Not all objects can be converted to a JSON string. When an object has cyclic self-references, the conversion will fail. This is typically the case for hierarchical data structures where parent and child both reference each other: const world = { name: 'World', regions: [] }; world.region...
Create a MongoDB connection, that later you can query: $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); In the next example, you will learn how to query the connection object. This extension close the connection automatically, it's not necessary to close manually.

Page 41 of 99