To use typescript with react in a node project, you must first have a project directory initialized with npm. To initialize the directory with npm init
Installing via npm or yarn
You can install React using npm by doing the following:
npm install --save react react-dom
Facebook released its ow...
The simplest react component without a state and no properties can be written as:
import * as React from 'react';
const Greeter = () => <span>Hello, World!</span>
That component, however, can't access this.props since typescript can't tell if it is a react component. To access ...
VueJS can be used to easily handle user input as well, and the two way binding using v-model makes it really easy to change data easily.
HTML :
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
{{message}}
<input v-model="...
In case you have json with an ISO date string like this
JSON.stringify({date: new Date()})
// -> "{"date":"2016-12-12T13:24:34.470Z"}"
You can map it to elm Date type:
import Html exposing (text)
import Json.Decode as JD
import Date
payload = ""&...
This technique relies on padding at the table cell level to structure the button, and both HTML attributes and CSS to style the button. No VML means simpler code, but no background images in Outlook.
<table width="100%" border="0" cellspacing="0" cellpadding="0...
This technique relies on adding thick borders to the link itself to build the button's CTA. Using borders is universally understood by email clients, but limit button appearance solid colors.
<table width="100%" border="0" cellspacing="0" cellpadding="0"&g...
This technique uses a combination of border-based and padding-based buttons, styling the link with both padding and at least a solid 1px border. The background color needs to be applied to the instead of the in this instance because Outlook does recognize horizontal padding on the tag (since it's...
If the first parameter is NOT NULL, NVL2 will return the second parameter. Otherwise it will return the third one.
SELECT NVL2(null, 'Foo', 'Bar'), NVL2(5, 'Foo', 'Bar') FROM DUAL;
NVL2(NULL,'FOO','BAR')NVL2(5,'FOO','BAR')BarFoo
π's Metaprogramming bits & bobs
Goals:
Teach through minimal targeted functional/useful/non-abstract examples (e.g. @swap or @assert) that introduce concepts in suitable contexts
Prefer to let the code illustrate/demonstrate the concepts rather than paragraphs of explanation
Avoi...
MQTT(Message Queue Telemetry Transport) is a Publish-Subscribe based "lightweight" messaging protocol for use on top of the TCP/IP stack.
It is quite useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.
Ther...
import cv2
def canny_webcam():
"Live capture frames from webcam and show the canny edge image of the captured frames."
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read() # ret gets a boolean value. True if reading is successful (I think). frame ...
Reading from an input port can be done in many ways. We can use the read method used by the REPL. It will read and interpret space separated expressions.
Taking the example from the string port above. We can read from the port like this:
(define p
(open-input-string "(a . (b . (c . ()))) 3...
There is a particular syntax that allow us to write cons cell in a more compact way than using the cons constructor.
A pair can be written as such:
'(1 . 2) == (cons 1 2)
The big difference is that we can create pairs using quote. Otherwise, Scheme would create a proper list (1 . (2 . '())).
T...
A enum declares a set of ordered values - the typedef just adds a handy name to this. The 1st element is 0 etc.
typedef enum {
Monday=1,
Tuesday,
Wednesday
} WORKDAYS;
WORKDAYS today = Monday;//value 1
Here’s an example vector asset which we’re actually using in AppCompat:
res/drawable/ic_search.xml
<vector xmlns:android="..."
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeig...
Here is a simple VectorDrawable in this vectordrawable.xml file.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="64dp"
android:width="64dp"
android:viewportHeight="600"
android:viewportWidth="...
This is for those moving to data.table >= 1.9.8
You have a data set of pet owners and names, but you suspect some repeated data has been captured.
library(data.table)
DT <- data.table(pet = c("dog","dog","cat","dog"),
owner = c("...