This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class StarIcon extends Component { | |
render() { | |
const {color, width, height} = this.props; | |
return ( | |
<svg className="star" width={width} height={height} fill={color} viewBox="0 0 200 200"> | |
<path d="M100,10 L150,140 20,50 180,50 50,140 Z" /> | |
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
// import { createBrowserHistory } from 'history'; | |
import Chats from './Chats'; | |
import Contacts from './Contacts'; | |
import 'bootstrap/dist/css/bootstrap.min.css'; | |
import './App.css'; | |
/* Error: Property 'path' is missing in type '{}' but required in type 'Readonly<Props>'. TS2741 | |
Error: Type 'Props' is not assignable to type 'string'.ts(2322) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import './App.css'; | |
export default class Get extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
error: null, | |
isLoaded: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Iterator<T> { | |
next(value?: any): IteratorResult<T>; | |
return?(value?: any): IteratorResult<T>; | |
throw?(e?: any): IteratorResult<T>; | |
} | |
interface IteratorResult<T> { | |
done: boolean; | |
value?: T; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
//import TextBlock from './TextBlock'; | |
import {BlogPostWithSubscription} from './withSubscription'; | |
class BlogPost extends Component { | |
render() { | |
const {post, handlePostChange, handlePostSubmit} = this.props; | |
return ( | |
<div className="MyApp"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './App.css'; | |
import MyFunctionComponent from './MyFunctionComponent'; | |
import MyClassComponent from './MyClassComponent'; | |
import MyAnotherClassComponent from './MyAnotherClassComponent'; | |
function App() { | |
return ( | |
<div className="App"> | |
<MyFunctionComponent /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import Toolbar from './Toolbar' | |
import {ThemeContext, themes} from './ThemeContext' | |
export default class App extends Component { | |
constructor(props) { | |
super(props) | |
this.state = {theme: themes.light} | |
this.toggleTheme = this.toggleTheme.bind(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Paper from '@material-ui/core/Paper'; | |
import Grid from '@material-ui/core/Grid'; | |
import TextField from '@material-ui/core/TextField'; | |
import InputAdornment from '@material-ui/core/InputAdornment'; | |
import AddCircleRoundedIcon from '@material-ui/icons/AddCircleRounded'; | |
import {TodoContext} from './TodoContext'; | |
export default class AddTodo extends Component { | |
static contextType = TodoContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "Python's built-in interfaces to operating-system services make it ideal for writing portable, maintainable system-administration tools and utilities (sometimes called shell tools)." | |
import re | |
fields = re.split(r'[;,.()?!\s]\s*', text) | |
fields = filter(None, fields) | |
print(fields) | |
#["Python's", 'built-in', 'interfaces', 'to', 'operating-system', 'services', 'make', 'it', 'ideal', 'for', 'writing', 'portable', 'maintainable', 'system-administration', 'tools', 'and', 'utilities', 'sometimes', 'called', 'shell', 'tools'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mapping Keys to Multiple Values in a Dictionary with defaultdict (multidict) | |
# A dictionary is a mapping where each key is mapped to a single value. If you want to | |
# map keys to multiple values, you need to store the multiple values in another container | |
# such as a list or set. | |
from collections import defaultdict | |
first_dict = {'a': 1, 'b': 2, 'c': 3} | |
second_dict = defaultdict(list) | |
for key in first_dict: |
OlderNewer