Tutorial by Examples: c

The System.String class supports a number of methods to convert between uppercase and lowercase characters in a string. System.String.ToLowerInvariant is used to return a String object converted to lowercase. System.String.ToUpperInvariant is used to return a String object converted to upper...
The System.String.Join method allows to concatenate all elements in a string array, using a specified separator between each element: string[] words = {"One", "Two", "Three", "Four"}; string singleString = String.Join(",", words); // singleString =...
String Concatenation can be done by using the System.String.Concat method, or (much easier) using the + operator: string first = "Hello "; string second = "World"; string concat = first + second; // concat = "Hello World" concat = String.Concat(first, second); // ...
Configure profiling for a project via stack. First build the project with the --profile flag: stack build --profile GHC flags are not required in the cabal file for this to work (like -prof). stack will automatically turn on profiling for both the library and executables in the project. The next...
To find out what packages your project directly depends on, you can simply use this command: stack list-dependencies This way you can find out what version of your dependencies where actually pulled down by stack. Haskell projects frequently find themselves pulling in a lot of libraries indirec...
Add the following code to the onCreate()/onResume() method: SensorManager sensorManager; Sensor mAccelerometer; final float movementThreshold = 0.5f; // You may have to change this value. boolean isMoving = false; float[] prevValues = {1.0f, 1.0f, 1.0f}; float[] currValues = new float[3]; ...
Consider the following code as an illustration: public String joinWords(List<String> words) { String message = ""; for (String word : words) { message = message + " " + word; } return message; } Unfortunate this code is inefficient if the w...
Get all files in Directory var FileSearchRes = Directory.GetFiles(@Path, "*.*", SearchOption.AllDirectories); Returns an array of FileInfo, representing all the files in the specified directory. Get Files with specific extension var FileSearchRes = Directory.GetFiles(@Path, "*...
Put your dbname.sqlite or dbname.db file in assets folder of your project. public class Databasehelper extends SQLiteOpenHelper { public static final String TAG = Databasehelper.class.getSimpleName(); public static int flag; // Exact Name of you db file that you put in as...
By going to Settings >> Keymap A window will popup showing All the Editor Actions with the their name and shortcuts. Some of the Editor Actions do not have shortcuts. So right click on that and add a new shortcut to that. Check the image below
Problem: If after the AsyncTask starts there is a screen rotation the owning activity is destroyed and recreated. When the AsyncTask finishes it wants to update the UI that may not valid anymore. Solution: Using Loaders, one can easily overcome the activity destruction/recreation. Example: ...
When a Google Map is displayed in lite mode clicking on a map will open the Google Maps application. To disable this functionality you must call setClickable(false) on the MapView, e.g.: final MapView mapView = (MapView)view.findViewById(R.id.map); mapView.setClickable(false);
com.android.dex.DexException: Multiple dex files define Lcom/example/lib/Class; This error occurs because the app, when packaging, finds two .dex files that define the same set of methods. Usually this happens because the app has accidentally acquired 2 separate dependencies on the same library....
Having more than one element with the same ID is a hard to troubleshoot problem. The HTML parser will usually try to render the page in any case. Usually no error occurs. But the pace could end up in a mis-behaving web page. In this example: <div id="aDiv">a</div> <div id...
A spring bean can be configured such that it will register only if it has a particular value or a specified property is met. To do so, implement Condition.matches to check the property/value: public class PropertyCondition implements Condition { @Override public boolean matches(ConditionC...
Find meaningful names for computation units. Use for comprehensions or map to combine computations together. Let's say you have something like this: if (userAuthorized.nonEmtpy) { makeRequest().map { case Success(respone) => someProcessing(..) if (resendToUser) { ...
By default: Use val, not var, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution. Use recursion and comprehensionss, not loops. Use immutable collections. This is a corrolary to using val whenever possible. Focus on da...
HTML5 is not based on SGML, and therefore does not require a reference to a DTD. HTML 5 Doctype declaration: <!DOCTYPE html> Case Insensitivity Per the W3.org HTML 5 DOCTYPE Spec: A DOCTYPE must consist of the following components, in this order: A string that is an ASCII case-inse...
This example shows a white Snackbar with custom Undo icon. Snackbar customBar = Snackbar.make(view , "Text to be displayed", Snackbar.LENGTH_LONG); customBar.setAction("UNDO", new View.OnClickListener() { @Override public void onClick(View view) { //Put the logic...
The blob.slice() method is used to create a new Blob object containing the data in the specified range of bytes of the source Blob. This method is usable with File instances too, since File extends Blob. Here we slice a file in a specific amount of blobs. This is useful especially in cases where yo...

Page 400 of 826