Even when all your work is directed at a single worksheet, it's still a very good practice to explicitly specify the worksheet in your code. This habit makes it much easier to expand your code later, or to lift parts (or all) of a Sub or Function to be re-used someplace else. Many developers establi...
Given a file sample:
hello
Hello
HELLO_there
A normal grep for "hello" returns:
$ grep "hello" sample
hello
Using -i allows to ignore case and match any "hello":
$ grep -i "hello" sample
hello
Hello
HELLO_there
Given a file sample:
hello world
ahello here
hello_there
A normal grep for "hello" returns:
$ grep hello sample
hello world
ahello here
hello_there
Using -w allows to select those lines containing matches that form whole words:
$ grep -w hello sample
hello world
DBContract.java
//Define the tables and columns of your local database
public final class DBContract {
/*Content Authority its a name for the content provider, is convenient to use the package app name to be unique on the device */
public static final String CONTENT_AUTHORITY =...
A module is an importable file containing definitions and statements.
A module can be created by creating a .py file.
# hello.py
def say_hello():
print("Hello!")
Functions in a module can be used by importing the module.
For modules that you have made, they will need to be in t...
This object, Shape has a property image that depends on numberOfSides and sideWidth. If either one of them is set, than the image has to be recalculated. But recalculation is presumably long, and only needs to be done once if both properties are set, so the Shape provides a way to set both propertie...
In C#, types can define custom Conversion Operators, which allow values to be converted to and from other types using either explicit or implicit casts. For example, consider a class that is meant to represent a JavaScript expression:
public class JsExpression
{
private readonly string expres...
Suppose you have types like the following:
interface IThing { }
class Thing : IThing { }
LINQ allows you to create a projection that changes the compile-time generic type of an IEnumerable<> via the Enumerable.Cast<>() and Enumerable.OfType<>() extension methods.
IEnumerabl...
A Closure is a function taken together with an environment. The function is typically an anonymous function defined inside another function. The environment is the lexical scope of the enclosing function (very basic idea of a lexical scope of a function would be the scope that exists between the fun...
Suppose you have many changes in one or more files but from each file you only want to commit some of the changes, you can select the desired changes using:
git add -p
or
git add -p [file]
Each of your changes will be displayed individually, and for each change you will be prompted to choose...
A simple context tree (containing some common values that might be request scoped and included in a context) built from Go code like the following:
// Pseudo-Go
ctx := context.WithValue(
context.WithDeadline(
context.WithValue(context.Background(), sidKey, sid),
time.Now().A...
A database is created with the following SQL command:
CREATE DATABASE myDatabase;
This would create an empty database named myDatabase where you can create tables.
Matplotlib supports both object-oriented and imperative syntax for plotting. The imperative syntax is intentionally designed to be very close to Matlab syntax.
The imperative syntax (sometimes called 'state-machine' syntax) issues a string of commands all of which act on the most recent figure or a...
First, ensure you have imported sessions from flask
from flask import session
To use session, a Flask application needs a defined SECRET_KEY.
app = Flask(__name__)
app.secret_key = 'app secret key'
Sessions are implemented by default using a cookie signed with the secret key. This ensures t...
props are used to pass data and methods from a parent component to a child component.
Interesting things about props
They are immutable.
They allow us to create reusable components.
Basic example
class Parent extends React.Component{
doSomething(){
console.log("Parent comp...
defaultProps allows you to set default, or fallback, values for your component props. defaultProps are useful when you call components from different views with fixed props, but in some views you need to pass different value.
Syntax
ES5
var MyClass = React.createClass({
getDefaultProps: ...
propTypes allows you to specify what props your component needs and the type they should be. Your component will work without setting propTypes, but it is good practice to define these as it will make your component more readable, act as documentation to other developers who are reading your compone...
When a React component is created, a number of functions are called:
If you are using React.createClass (ES5), 5 user defined functions are called
If you are using class Component extends React.Component (ES6), 3 user defined functions are called
getDefaultProps() (ES5 only)
This is the firs...
componentWillReceiveProps(nextProps)
This is the first function called on properties changes.
When component's properties change, React will call this function with the new properties. You can access to the old props with this.props and to the new props with nextProps.
With these variables, you c...