Tutorial by Examples: c

The Hello World Web Script handles GET HTTP methods. But what if you want to create data on the server? For that your web script should handle POST. Here is a simple example that creates new folders in Company Home. It is invoked by making a POST call with a JSON body that looks like: {'name':'tes...
A single instance of Node.js runs in a single thread. To take advantage of multi-core systems, application can be launched in a cluster of Node.js processes to handle the load. The cluster module allows you to easily create child processes that all share server ports. Following example create the ...
interface IService { void ProcessRequest(); } interface IRepository { IEnumerable<string> GetData(); } class HelloWorldRepository : IRepository { public IEnumerable<string> GetData() { return new[] { "Hello", "World" }; } ...
Dagger 2 supports creating a component from multiple modules. You can create your component this way: @Singleton @Component(modules = {GeneralPurposeModule.class, SpecificModule.class}) public interface MyMultipleModuleComponent { void inject(MyFragment myFragment); void inject(MyServic...
QRCodeReaderView implements an Android view which show camera and notify when there's a QR code inside the preview. It uses the zxing open-source, multi-format 1D/2D barcode image processing library. Adding the library to your project Add QRCodeReaderView dependency to your build.gradle dependen...
To receive an event it is necessary to implement a method with the event type as parameter and annotate it using @Subscribe. Furthermore you have to register/unregister the instance of your object at the BusProvider (see example Sending an event): public class MyFragment extends Fragment { pri...
Variables in Go are always initialized whether you give them a starting value or not. Each type, including custom types, has a zero value they are set to if not given a value. var myString string // "" - an empty string var myInt int64 // 0 - applies to all types of int an...
In slices the zero value is an empty slice. var myIntSlice []int // [] - an empty slice Use make to create a slice populated with values, any values created in the slice are set to the zero value of the type of the slice. For instance: myIntSlice := make([]int, 5) // [0, 0, 0, 0, 0] - a s...
When creating a struct without initializing it, each field of the struct is initialized to its respective zero value. type ZeroStruct struct { myString string myInt int64 myBool bool } func main() { var myZero = ZeroStruct{} fmt.Printf("Zero values are: %q, %d...
A layout is a view file, which is extended by other views which inject blocks of code into their parent. For example: parent.blade.php: <html> <head> <style type='text/css'> @yield('styling') </style> </head> <body> ...
Shortcodes are useful when you want to be able add more complex elements inline into the normal content editor. A shortcode in it's simplest for would look like this: function my_shortcode( ){ return "This is a shortcode"; } add_shortcode( 'my_shortcode', 'my_shortcode' ); It w...
Here is an example of a simple button short code: <?php function my_button_shortcode( $atts ) { // Parse the input attributes and assgn default values for the // attributes that are not specified on the shortcode $a = shortcode_atts( array( 'id' => '', 'ur...
btn class of Twitter-bootstrap can be used with any of the following html elements. anchor button input with both type="button" and type="submit" Below are examples of all possible use cases of btn class <a class="btn" href="#" role="button&qu...
A tsconfig.json file can contain both line and block comments, using the same rules as ECMAScript. //Leading comment { "compilerOptions": { //this is a line comment "module": "commonjs", //eol line comment "target" /*inline bl...
A boolean array can be created manually by using dtype=bool when creating the array. Values other than 0, None, False or empty strings are considered True. import numpy as np bool_arr = np.array([1, 0.5, 0, None, 'a', '', True, False], dtype=bool) print(bool_arr) # output: [ True True False ...
Function pointers are the most basic way of passing functions around, which can also be used in C. (See the C documentation for more details). For the purpose of callable objects, a function pointer can be defined as: typedef returnType(*name)(arguments); // All using name =...
Every class which overloads the operator() can be used as a function object. These classes can be written by hand (often referred to as functors) or automatically generated by the compiler by writing Lambdas from C++11 on. struct Person { std::string name; unsigned int age; }; // Func...
Checkbox is a control that allow user to get boolean values from user for a spesific question like "Are you ok?". Has a event called CheckedChanged, which occurs whenever the check property is changed. Here is a CheckBox that has a question "Is Checked?". We got this Message...
in the index.html, link the CSS from Google CDN <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.css"> Required dependencies: angular angular-aria angular-animate angular-messages <!-- Angular M...
Same as, with writing classes - start with the simple cases, then add requirement (aka tests) and implementation (aka production code) case by case: [Test] public void EnsureThat_IsLeapYearIfDecimalMultipleOf4() {...} [Test] public void EnsureThat_IsNOTLeapYearIfDecimalMultipleOf100 {...} [Tes...

Page 519 of 826