| Function | Shortcut |
|---|---|
| Fullscreen | ⌘+ Enter |
| Previous Tab | ⌘+ Left Arrow |
| Next Tab | ⌘+ Right Arrow |
| Go to Tab | ⌘ + Number |
| Go to Window | ⌘ + Option + Number |
| Go to Split Pane by Direction | ⌘ + Option + Arrow |
| > library(parallel) # load the library | |
| # create a cluster, which is made up by "detectCores()" of workers | |
| > cl <- makePSOCKcluster(rep("localhost",detectCores())) | |
| > use_multi_core_computing <- function(mat, threshold){ | |
| result <- parSapply(cl,mat, function(x){ # parSapply() can be treated as a multi-core version sapply() | |
| if(x > threshold){ | |
| x ** 2 | |
| }else{ | |
| sqrt(x) | |
| } |
| > set.seed(123) | |
| > N <- 10 | |
| > fake.vector <- runif(N, min = 0, max = 10) | |
| # and this time, let's tested 1000 times | |
| > microbenchmark(use_for_loop(fake.vector,5),use_apply_family_funcs(fake.vector,5),times = running_times) | |
| Unit: microseconds | |
| expr min lq mean median uq max neval cld | |
| use_for_loop(fake.vector, 5) 15.396 18.160 22.09172 19.343 27.239 62.372 1000 a | |
| use_apply_family_funcs(fake.vector, 5) 21.712 24.081 28.98297 25.660 34.542 138.165 1000 b |
| > set.seed(123) | |
| > N <- 10000 | |
| > fake.vector <- runif(N, min = 0, max = 10) | |
| # Here we want to use fake.vector to generate a new vector, without modifying the fake.vector | |
| > use_for_loop <- function(mat, threshold) { | |
| result <- numeric(length(mat)) | |
| for(i in 1:length(mat)) { | |
| if(mat[i] > threshold){ | |
| result[i] <- mat[i] ** 2 |
| > ret <- numeric(100000) | |
| > for_fun <- function(x){ | |
| for(i in 1:x){ | |
| ret[i] <- i^2 | |
| } | |
| } | |
| # firstly, type "?microbenchmark" to check its user doc | |
| > microbenchmark(for_fun(100000), times = 100) | |
| Unit: milliseconds |
| > ret <- numeric(100000) | |
| > for_fun <- function(x){ | |
| for(i in 1:x){ | |
| ret[i] <- i^2 | |
| } | |
| } | |
| > system.time(for_fun(100000)) | |
| user system elapsed | |
| 0.13 0.00 0.13 |
There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.
The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.
When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].
When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.
| test |