Tutorial by Examples: com

Following the Rcpp example in this documentation entry, consider the following tough-to-vectorize function, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <-...
You can create widgets composed of multiple widgets using MultiWidget. from datetime import date from django.forms.widgets import MultiWidget, Select from django.utils.dates import MONTHS class SelectMonthDateWidget(MultiWidget): """This widget allows the user to fill in ...
This assumes that you have read the documentation about starting a new Django project. Let us assume that the main app in your project is named td (short for test driven). To create your first test, create a file named test_view.py and copy paste the following content into it. from django.test impo...
If you have a f :: Lens' a b and a g :: Lens' b c then f . g is a Lens' a c gotten by following f first and then g. Notably: Lenses compose as functions (really they just are functions) If you think of the view functionality of Lens, it seems like data flows "left to right"—this might ...
What’s a component? A component is basically a directive that uses a simpler configuration and that is suitable for a component-based architecture, which is what Angular 2 is all about. Think of a component as a widget: A piece of HTML code that you can reuse in several different places in y...
TODO: Maybe move the explanations to remarks and add examples separately FOOF In Common Lisp, there is a concept of Generalized References. They allow a programmer to setf values to various "places" as if they were variables. Macros that make use of this ability often have a F-postfix in...
git diff 1234abc..6789def # old new E.g.: Show the changes made in the last 3 commits: git diff @~3..@ # HEAD -3 HEAD Note: the two dots (..) is optional, but adds clarity. This will show the textual difference between the commits, regardless of where they are in the tree.
Improper use of pointers are frequently a source of bugs that can include security bugs or program crashes, most often due to segmentation faults. Not checking for allocation failures Memory allocation is not guaranteed to succeed, and may instead return a NULL pointer. Using the returned value, w...
When contributors add to a project from different machines or operating systems, it may happen that they use different email addresses or names for this, which will fragment contributor lists and statistics. Running git shortlog -sn to get a list of contributors and the number of commits by them co...
Generally speaking, empty commits (or commits with state that is identical to the parent) is an error. However, when testing build hooks, CI systems, and other systems that trigger off a commit, it's handy to be able to easily create commits without having to edit/touch a dummy file. The --allow-e...
iex(1)> recompile Compiling 1 file (.ex) :ok
iex(1)> 1 + 1 2 iex(2)> v 2 iex(3)> 1 + v 3 See also: Get the value of a row with `v`
For instance, a computation involving commands to read and write from the prompt: First we describe the "commands" of our computation as a Functor data type {-# LANGUAGE DeriveFunctor #-} data TeletypeF next = PrintLine String next | ReadLine (String -> next) derivin...
The basics After making changes to your source code, you should stage those changes with Git before you can commit them. For example, if you change README.md and program.py: git add README.md program.py This tells git that you want to add the files to the next commit you do. Then, commit your...
Channels can be used to send data from one thread to another. Below is an example of a simple producer-consumer system, where the main thread produces the values 0, 1, ..., 9, and the spawned thread prints them: use std::thread; use std::sync::mpsc::channel; fn main() { // Create a channel...
JavaScript has four different equality comparison operations. SameValue It returns true if both operands belong to the same Type and are the same value. Note: the value of an object is a reference. You can use this comparison algorithm via Object.is (ECMAScript 6). Examples: Object.is(1, 1); ...
docker exec -it <container id> /bin/bash It is common to log in an already running container to make some quick tests or see what the application is doing. Often it denotes bad container use practices due to logs and changed files should be placed in volumes. This example allows us log in the...
If someone else wrote the code you are committing, you can give them credit with the --author option: git commit -m "msg" --author "John Smith <[email protected]>" You can also provide a pattern, which Git will use to search for previous authors: git commit -m &quo...
After the C pre-processor has included all the header files and expanded all macros, the compiler can compile the program. It does this by turning the C source code into an object code file, which is a file ending in .o which contains the binary version of the source code. Object code is not directl...
iex(1)> a = 10 10 iex(2)> b = 20 20 iex(3)> a + b 30 You can get a specific row passing the index of the row: iex(4)> v(3) 30 You can also specify an index relative to the current row: iex(5)> v(-1) # Retrieves value of row (5-1) -> 4 30 iex(6)> v(-5) # Retrieves...

Page 7 of 65