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
# reading npm log files from terminal using python (linux) | |
import os, glob, sys | |
log_path = os.path.expanduser('~/.npm/_logs/*.log') | |
log_files = glob.glob(log_path) | |
for file in log_files: | |
f = open(file) | |
sys.stdout.write(f.read()) | |
f.close() |
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
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
os.Chdir("~/.npm/_logs") | |
file, err := os.Open("2020-04-20T09_38_57_076Z-debug.log") |
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: |
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
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
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 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 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
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 './App.css'; | |
export default class Get extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
error: null, | |
isLoaded: false, |