Tutorial by Examples: and

The "child" components of a component are available on a special prop, props.children. This prop is very useful for "Compositing" components together, and can make JSX markup more intuitive or reflective of the intended final structure of the DOM: var SomeComponent = function ...
While you can use the NSUserDefaults methods anywhere, it can sometimes be better to define a manager that saves and reads from NSUserDefaults for you and then use that manager for reading or writing your data. Suppose that we want to save a user’s score into NSUserDefaults. We can create a class ...
When committing changes it is possible to specify that the commit will in future be squashed to another commit and this can be done like so, git commit --squash=[commit hash of commit to which this commit will be squashed to] One might also use, --fixup=[commit hash] alternatively to fixup. It is...
You can use Modules to build more complex classes through composition. The include ModuleName directive incorporates a module's methods into a class. module Foo def foo_method puts 'foo_method called!' end end module Bar def bar_method puts 'bar_method called!' end end ...
This method allows a command to be sent to Cmd.exe, and returns the standard output (including standard error) as a string: private static string SendCommand(string command) { var cmdOut = string.Empty; var startInfo = new ProcessStartInfo("cmd", command) { ...
Given a Day, we can perform simple arithmetic and comparisons, such as adding: import Data.Time addDays 1 (fromGregorian 2000 1 1) -- 2000-01-02 addDays 1 (fromGregorian 2000 12 31) -- 2001-01-01 Subtract: addDays (-1) (fromGregorian 2000 1 1) -- 1999-12-31 addDays (-1) (fromGregorian...
<?php echo do_shortcode("[footag foo='Hi! I am a foo output']"); ?> To print a shortcode using php use the do_shortcode function and echo the returned value.
This program draws some shapes and 'hello world!' and let an image go to every corner of the window. the complete code: import pygame,sys from pygame.locals import * pygame.init() FPS = 30 #frames per second setting fpsClock = pygame.time.Clock() #set up the window screen = pygame.disp...
Although GameplayKit (which is introduced with iOS 9 SDK) is about implementing game logic, it could also be used to generate random numbers, which is very useful in apps and games. Beside the GKRandomSource.sharedRandom which is used in the following chapters there are three additional types of GK...
Charts can be created by working directly with the Series object that defines the chart data. In order to get to the Series without an exisitng chart, you create a ChartObject on a given Worksheet and then get the Chart object from it. The upside of working with the Series object is that you can s...
x = np.random.random([100,100]) x.tofile('/path/to/dir/saved_binary.npy') y = fromfile('/path/to/dir/saved_binary.npy') z = y.reshape(100,100) all(x==z) # Output: # True
# example data DT = data.table(iris) To modify factor levels by reference, use setattr: setattr(DT$Species, "levels", c("set", "ver", "vir") # or DT[, setattr(Species, "levels", c("set", "ver", "vir"))] The sec...
Batch file command line arguments are parameter values submitted when starting the batch. They should be enclosed in quotes if they contain spaces. In a running batch file, the arguments are used for various purposes, i.e. redirection to :labels, setting variables, or running commands. The argument...
If you want to clear your current Activity stack and launch a new Activity (for example, logging out of the app and launching a log in Activity), there appears to be two approaches. 1. Target (API >= 16) Calling finishAffinity() from an Activity 2. Target (11 <= API < 16) Intent intent ...
HTML email is the use of a subset of HTML and CSS to format an email message like a web page using colors, graphics, table columns and links. When you send an email it’s important to send both plain text and HTML. You do this by sending your email as multi-part MIME. Most email service providers ha...
The syntax for using the aws cli is as follows: aws [options] <command> <subcommand> [parameters] Some examples using the 'ec2' command and the 'describe-instances' subcommand: aws ec2 describe-instances aws ec2 describe-instances --instance-ids <your-id> Example with a ...
$ mplayer Lecture_video_part1.mkv $ ^1^2^ mplayer Lecture_video_part2.mkv This command will replace 1 with 2 in the previously executed command. It will only replace the first occurrence of the string and is equivalent to !!:s/1/2/. If you want to replace all occurrences, you have to use !!:gs...
$ apt-get install r-base E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? $ sudo !! sudo apt-get install r-base [sudo] password for <user>:
Sometimes conversion of primitive types to boxed types is necessary. To convert the array, it's possible to use streams (in Java 8 and above): Java SE 8 int[] primitiveArray = {1, 2, 3, 4}; Integer[] boxedArray = Arrays.stream(primitiveArray).boxed().toArray(Integer[]::new); With lowe...
You can use the plus (+) operator to concatenate strings: 'Dart ' + 'is ' + 'fun!'; // 'Dart is fun!' You can also use adjacent string literals for concatenation: 'Dart ' 'is ' 'fun!'; // 'Dart is fun!' You can use ${} to interpolate the value of Dart expressions within strings. The curly...

Page 77 of 153