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 { put, take, takeEvery, call, select } from "redux-saga/effects"; | |
import { eventChannel } from "redux-saga"; | |
import { io, Socket } from "socket.io-client"; | |
/* Event channel for converting incoming socket messages to saga events. */ | |
function createEventChannel(mySocket: Socket<any>) { | |
return eventChannel((emit) => { | |
mySocket.onAny((type: string, payload: any) => emit({ type, payload })); | |
return () => { | |
mySocket.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
from pathlib import Path | |
import json | |
for path in Path('node_modules').rglob('package.json'): | |
with open(path) as jsonFile: | |
try: | |
jsonObject = json.load(jsonFile) | |
except: | |
print("ERROR: json load failed") | |
jsonFile.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
from importlib.metadata import metadata | |
print(metadata("flask-cors")["License"]) |
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
from flask import Flask | |
from flask_cors import CORS | |
from flask_socketio import SocketIO, emit | |
import os | |
app = Flask(__name__) | |
CORS(app) | |
socketio = SocketIO(app, cors_allowed_origins="*") | |
@socketio.on('connect', namespace="/items") |
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
from datetime import datetime, date, time, timezone | |
dt = datetime.utcnow() | |
print(dt) | |
newtime = dt.replace(microsecond=0) | |
print(newtime) |
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
/** | |
HTML: | |
<header style="display: flex; justify-content: space-between;"> | |
<div class="dropdown--container"> | |
<button>Menu</button> | |
<div class="dropdown--content"> | |
<ul> | |
<li><a href="#">Link</a></li> |
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, useEffect, useRef, useState } from 'react'; | |
import { render } from 'react-dom'; | |
import './style.css'; | |
interface AppProps {} | |
interface AppState { | |
name: string; | |
} | |
function useDropdown(props: any) { |
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 { Todo } from '../models/todo.model'; | |
const TodoService = { | |
get: () => { | |
return new Promise((resolve) => { | |
return fetch('http://localhost:5000/todos') | |
.then((resp) => resp.json()) | |
.then((data) => { | |
resolve(data); | |
}); |
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
items = { | |
"123": { | |
"id": '123', | |
"title": 'title1', | |
"description": 'Description text', | |
"tag": 'Tag1', | |
"timestamp": '2021-06-21', | |
}, | |
"456": { | |
"id": '456', |
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 datetime | |
timestamps = [] | |
for i in range(30): | |
new_date = datetime.datetime(2021, 7, i+1, 12, 00, 00, 000, | |
tzinfo=datetime.timezone.utc) | |
timestamp = int(datetime.datetime.timestamp(new_date) * 1000) | |
timestamps.append(timestamp) |