Tutorial by Examples: c

With Blade, you can also include partial views (called 'partials') directly into a page like so: @include('includes.info', ['title' => 'Information Station']) The code above will include the view at 'views/includes/info.blade.php'. It will also pass in a variable $title having value 'Informat...
Subclassing UIControl gives us access to the following methods: beginTrackingWithTouch is called when the finger first touches down within the control's bounds. continueTrackingWithTouch is called repeatedly as the finger slides across the control and even outside of the control's bounds. endTr...
With local image Swift let image = UIImage(named: "imageFromBundleOrAsset") Objective-C UIImage *image = [UIImage imageNamed:@"imageFromBundleOrAsset"]; Note The method imageNamed caches the image's contents to memory. Loading many large images that way can cause low...
Just add the using at the beginning and the [WebMethod] decorator to the static method to be called in the aspx page: using System.Web.Services; public partial class MyPage : System.Web.UI.Page { [WebMethod] public static int GetRandomNumberLessThan(int limit) { var r = ...
Just like char and int, a function is a fundamental feature of C. As such, you can declare a pointer to one: which means that you can pass which function to call to another function to help it do its job. For example, if you had a graph() function that displayed a graph, you could pass which functio...
import { Http, Request, RequestOptionsArgs, Response, RequestOptions, ConnectionBackend, Headers } from '@angular/http'; import { Router } from '@angular/router'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/empty'; import 'rxjs/add/observable/throw'; import 'rxjs/a...
After extending the Http class, we need to tell angular to use this class instead of Http class. In order to do this, in our main module(or depending on the needs, just a particular module), we need to write in the providers section: export function httpServiceFactory(xhrBackend: XHRBackend, reque...
A simple type switch: // assuming x is an expression of type interface{} switch t := x.(type) { case nil: // x is nil // t will be type interface{} case int: // underlying type of x is int // t will be int in this case as well case string: // underlying type of x is st...
A regular expression with grouped parts can be used as an extractor: scala> val address = """(.+):(\d+)""".r address: scala.util.matching.Regex = (.+):(\d+) scala> val address(host, port) = "some.domain.org:8080" host: String = some.domain.org por...
There are several ways to create an Observable in RxJava. The most powerful way is to use the Observable.create method. But it's also the most complicated way. So you must avoid using it, as much as possible. Emitting an exiting value If you already have a value, you can use Observable.just to emi...
Create a class which extends Service class and in overridden method onBind return your local binder instance: public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); /** * Class used for the client Binder. Bec...
Describe your service access interface through .aidl file: // IRemoteService.aidl package com.example.android; // Declare any non-default types here with import statements /** Example service interface */ interface IRemoteService { /** Request the process ID of this service, to do evil...
Actually you can use ReactJS's components in Typescript as in facebook's example. Just replace 'jsx' file's extension to 'tsx': //helloMessage.tsx: var HelloMessage = React.createClass({ render: function() { return <div>Hello {this.props.name}</div>; } }); ReactDOM.rende...
SharedPreferences Manager (Singleton) class to read and write all types of data. import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.google.gson.Gson; import java.lang.reflect.Type; /** * Singleton Class for accessing SharedPref...
Perform a basic GET request and prints the contents of a site (HTML). package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("https://example.com/") if err != nil { panic(err) } ...
You may pull (download) files from the device by executing the following command: adb pull <remote> <local> For example: adb pull /sdcard/ ~/ You may also push (upload) files from your computer to the device: adb push <local> <remote> For example: adb push ~/im...
You can reboot your device by executing the following command: adb reboot Perform this command to reboot into bootloader: adb reboot bootloader Reboot to recovery mode: adb reboot recovery Be aware that the device won't shutdown first!
This is an extension of Basic Example: Basic Structure import React, { Component } from 'react'; import { render } from 'react-dom'; class FirstComponent extends Component { render() { return ( <div> Hello, {this.props.name}! I am a FirstCompon...
To get a value from the map, you just have to do something like:00 value := mapName[ key ] If the map contains the key, it returns the corresponding value. If not, it returns zero-value of the map's value type (0 if map of int values, "" if map of string values...) m := map[string]s...
If you want to cancel an alarm, and you don't have a reference to the original PendingIntent used to set the alarm, you need to recreate a PendingIntent exactly as it was when it was originally created. An Intent is considered equal by the AlarmManager: if their action, data, type, class, and ca...

Page 108 of 826