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
type Store = { | |
name: string; | |
age: number; | |
hobbies: string[]; | |
}; | |
function createStore<T extends Record<string, any>>(initialStore: T) { | |
const store = initialStore; | |
return { | |
get<K extends keyof Store>(key: K) { |
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
class LinkedList { | |
constructor() { | |
this.head = null | |
this.tail = null | |
} | |
append (data) { | |
const node = {data, next: null} | |
if(!this.head) { | |
this.head = node | |
} |
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 base64 | |
import requests | |
image_path = 'YOUR_IMAGE_PATH' | |
secret_key = 'YOUR_SECRET_KEY' | |
with open(image_path, 'rb') as image_file: | |
img_base64 = base64.b64encode(image_file.read()) | |
url = 'https://api.openalpr.com/v2/recognize_bytes'+'?recognize_vehicle=1&country=ru&secret_key={}'.format(secret_key) |
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 { View, Text, StyleSheet } from 'react-native'; | |
import { MaterialCommunityIcons } from '@expo/vector-icons'; | |
import PropTypes from 'prop-types'; | |
import { weatherConditions } from '../utils/WeatherConditions'; | |
const Weather = ({ weather, temperature }) => { | |
return ( | |
<View | |
style={[ |
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
export const weatherConditions = { | |
Rain: { | |
color: '#005BEA', | |
title: 'Raining', | |
subtitle: 'Grab a cup of coffee', | |
icon: 'weather-rainy' | |
}, | |
Clear: { | |
color: '#f7f033', |
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 { StyleSheet, Text, View } from 'react-native'; | |
import Weather from './components/weather' | |
import Constants from 'expo' | |
const KEY = Expo.Constants.manifest.extra.mysecret | |
export default class App extends React.Component { | |
state = { |
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 { View, Text, StyleSheet } from 'react-native'; | |
import { MaterialCommunityIcons } from '@expo/vector-icons'; | |
const Weather = () => { | |
return ( | |
<View style={styles.weatherContainer}> | |
<View style={styles.headerContainer}> | |
<MaterialCommunityIcons size={48} name="weather-sunny" color={'#fff'} /> | |
<Text style={styles.tempText}>Temperature˚</Text> |
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 { StyleSheet, Text, View } from 'react-native'; | |
export default class App extends React.Component { | |
state = { | |
isLoading: true | |
}; | |
render() { |
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
const initialState = { | |
currentUser: {} | |
} | |
export default function reducer(state = initialState, action) { | |
switch (action.type) { | |
case 'LOGIN_USER': | |
return {...state, currentUser: action.payload} | |
case 'LOGOUT_USER': | |
return {...state, currentUser: {} } |
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
export const logoutUser = () => ({ | |
type: 'LOGOUT_USER' | |
}) |
NewerOlder