Tutorial by Examples: dc

' Making a factory with parameter to the class Public Function new_Car(wheels) Set new_Car = New Car new_Car.Wheels = wheels End Function ' Creating a car through a factory Dim semiTrailer Set semiTrailer = new_Car(18)
Currently there is no one-click-button method to actually enforce any code style guidelines across a team but there are two methods to make sure a certain code style is applied to your product. Import PhpStorm Code Style Schemes The first and more easier solution is to set up a code style scheme o...
Show how to create simple IMultiValueConverter converter and use MultiBinding in xaml. Get summ of all values passed by values array. public class AddConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ...
Note: There will be some Objective-c in this example.. We will make a wrapper to C++ in this example, So don't worry to much about it. First start Xcode and create a project. And select a Cocoa application Delete all sources except the Info.plist file.(Your app won't work without it) Creat...
Session Types are a way to tell the compiler about the protocol you want to use to communicate between threads - not protocol as in HTTP or FTP, but the pattern of information flow between threads. This is useful since the compiler will now stop you from accidentally breaking your protocol and causi...
The macro() function allows you to add new functionality to Illuminate\Support\Collection objects Usage: Collection::macro("macro_name", function ($parameters) { // Your macro }); For example: Collection::macro('uppercase', function () { return $this->map(function ($i...
class Message DEFAULT_MESSAGE = "Hello, world" def speak(message = nil) if message puts message else puts DEFAULT_MESSAGE end end end The constant DEFAULT_MESSAGE can be changed with the following code: Message::DEFAULT_MESSAGE = "Hullo, wo...
Example: Invoke different constructors by passing relevant parameters import java.lang.reflect.*; class NewInstanceWithReflection{ public NewInstanceWithReflection(){ System.out.println("Default constructor"); } public NewInstanceWithReflection( String a){ ...
When we use a condition within another condition we say the conditions are "nested". One special case of nested conditions is given by the elseif option, but there are numerous other ways to use nested conditons. Let's examine the following code: a = 2; if mod(a,2)==0 % MOD - modulo o...
Notice, that in order to change file prmissions, your device need to be rooted, su binary doesn't come with factory shipped devices! Convention: adb shell su -c "chmod <numeric-permisson> <file>" Numeric permission constructed from user, group and world sections. For exa...
add permission in your manifest file <uses-permission android:name="android.permission.BLUETOOTH" /> In your Fragment(or Activity) Add the receiver method private BroadcastReceiver mBluetoothStatusChangedReceiver = new BroadcastReceiver() { @Override public void o...
If you want to create an instance of an inner nested class you need to provide a class object of the enclosing class as an extra parameter with Class#getDeclaredConstructor. public class Enclosing{ public class Nested{ public Nested(String a){ System.out.println("Constru...
A lot of the value from local JVM unit tests comes from the way you design your application. You have to design it in such a way where you can decouple your business logic from your Android Components. Here is an example of such a way using the Model-View-Presenter pattern. Lets practice this out by...
We can load components in two ways. By initialize or override $components property in Controller By using loadComponent() method in initialize() method of Controller. Way-1 It should be override loading component by AppsController.php load one or more component class UsersController extend...
To enable or disable a BroadcastReceiver, we need to get a reference to the PackageManager and we need a ComponentName object containing the class of the receiver we want to enable/disable: ComponentName componentName = new ComponentName(context, MyBroadcastReceiver.class); PackageManager packageM...
To list all available schemes for the project in your current directory xcodebuild -list Optionally you can pass a path to a project or workspace file xcodebuild -list -workspace ./MyApp.xcworkspace xcodebuild -list -project ./MyApp.xcodeproj Example output Information about project "...
Example below shows how to create a BroadcastReceiver which is able to receive BOOT_COMPLETED events. This way, you are able to start a Service or start an Activity as soon device was powered up. Also, you can use BOOT_COMPLETED events to restore your alarms since they are destroyed when device is ...
Casting: The Basics Casting is used to transform data from long to wide format. Starting with a long data set: DT = data.table(ID = rep(letters[1:3],3), Age = rep(20:22,3), Test = rep(c("OB_A","OB_B","OB_C"), each = 3), Result = 1:9) We can cast our data using the...
Manually open and close a file. # Using new method f = File.new("test.txt", "r") # reading f = File.new("test.txt", "w") # writing f = File.new("test.txt", "a") # appending # Using open method f = open("test.txt", "r&...
Knitr is an R package that allows us to intermingle R code with LaTeX code. One way to achieve this is external code chunks. External code chunks allow us to develop/test R Scripts in an R development environment and then include the results in a report. It is a powerful organizational technique....

Page 12 of 28