Tutorial by Examples: check

public class ConnectSocketExample { private int HTTP_PORT = 80; /** * example method to create unconnected socket * then connect to it * at end return connected socket * * @param httpHostName - endpoint host name fot socket connection * @throws IOEx...
When rendering a form 'by hand', it can be useful to know if there are fields left to render or not. The function isRendered() from the FormView class returns true if there are still fields left to be rendered to the template. This snippet prints <h3>Extra fields</h3> if there are fiel...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
This attribute is applied to the class property. You can use ConcurrencyCheck attribute when you want to use existing columns for concurrency check and not a separate timestamp column for concurrency. using System.ComponentModel.DataAnnotations; public class Author { public int AuthorId { ...
You can disable Lint checking from your Java and XML source files. Configuring lint checking in Java To disable Lint checking specifically for a Java class or method in your Android project, add the @SuppressLint annotation to that Java code. Example: @SuppressLint("NewApi") @Override...
Go to Help → About Eclipse → Check if the m2e feature is there: .
Sometimes the shell prompt doesn't display the name of the virtual environment and you want to be sure if you are in a virtual environment or not. Run the python interpreter and try: import sys sys.prefix sys.real_prefix Outside a virtual, environment sys.prefix will point to the system p...
Sometimes it's useful to check if a field is present or absent on your JSON to avoid some JSONException on your code. To achieve that, use the JSONObject#has(String) or the method, like on the following example: Sample JSON { "name":"James" } Java code String jsonStr...
Lets assume we have this class and we would like to test doSmth method. In this case we want to see if parameter "val" is passed to foo. Object foo is mocked. public class Bar { private final Foo foo; public Bar(final Foo foo) { this.foo = foo; } public ...
$productFound = ($product->getId() !== null)
count() will return the number of times and element appears in an array. In the following example we see that the value 3 occurs twice. my_array = array('i', [1,2,3,3,5]) my_array.count(3) # 2
You can check if a variable has been defined in a scope by using ColdFusion's built in StructKeyExists() function. This can be used inside a <cfif> tag to prevent error messages in the event you attempt to refer to a variable that does not exist. You can also use this function to determine whe...
functions.php: function rm_init_js() { wp_enqueue_script( 'custom-ajax-script', get_template_directory_uri() . '/js/ajax.js', array( 'jquery', 'wp-util' ), '1.0', true ); // pass custom variables to JS wp_localize_script( 'custom-ajax-script', 'BEJS', array( 'action' => ...
Many bugs in knockout data binds are caused by undefined properties in a viewmodel. Knockout has two handy methods to retrieve the binding context of an HTML element: // Returns the binding context to which an HTMLElement is bound ko.contextFor(element); // Returns the viewmodel to which ...
Sub Main() Dim People = New List(Of String)({"Bob Barker", "Ricky Bobby", "Jeff Bridges"}) Console.WriteLine(People.Contains("Rick James")) Console.WriteLine(People.Contains("Ricky Bobby")) Console.WriteLine(Pe...
It's possible to call functions from the pygame.key and pygame.mouse module to receive the state of the key and mouse. However, it's not the recommended way to process events in pygame since there are some flaws with it: You'll receive the states when the function is called, which means you mig...
The n & (n - 1) trick (see Remove rightmost set bit) is also useful to determine if an integer is a power of 2: bool power_of_2 = n && !(n & (n - 1)); Note that without the first part of the check (n &&), 0 is incorrectly considered a power of 2.
Before you start the cherry-pick process, you can check if the commit you want to cherry-pick already exists in the target branch, in which case you don't have to do anything. git branch --contains <commit> lists local branches that contain the specified commit. git branch -r --contains <...
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection"); } else { ...
To check exact strength in decibels use this- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection");...

Page 7 of 12