This file contains hidden or 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
| use tokio::process; | |
| use std::process::Stdio; | |
| use std::time::Instant; | |
| async fn sleep() -> Result<String, Box<dyn std::error::Error>> { | |
| let ps = process::Command::new("sleep") | |
| .stdout(Stdio::piped()) | |
| .arg("3") | |
| .output().await?; |
This file contains hidden or 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
| use regex::Regex; // 1.1.8 | |
| fn split_keep<'a>(r: &Regex, text: &'a str) -> Vec<&'a str> { | |
| let mut result = Vec::new(); | |
| let mut last = 0; | |
| for (index, matched) in text.match_indices(r) { | |
| if last != index { | |
| result.push(&text[last..index]); | |
| } | |
| result.push(matched); |
This file contains hidden or 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
| use std::net::{TcpStream, IpAddr, SocketAddr}; | |
| use std::time::Duration; | |
| use threadpool::ThreadPool; | |
| use std::sync::mpsc::{channel, Sender}; | |
| use ipnet::Ipv4Net; | |
| use std::thread::sleep; | |
| static NETWORK: &str = "172.111.0.0/10"; | |
| static PORT: u16 = 80; | |
| static POOLSIZE: usize = 7000; |
This file contains hidden or 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
| use tokio::sync::mpsc; | |
| #[tokio::main] | |
| pub async fn main() { | |
| let (tx, mut rx) = mpsc::channel(32); | |
| let tx2 = tx.clone(); | |
| tokio::spawn(async move { | |
| tx.clone().send("sending from first handle").await; | |
| }); |
This file contains hidden or 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 asyncio | |
| import signal | |
| from random import randint | |
| class Timeout(Exception): | |
| pass | |
| def handle_timeout(signum, frame): |
This file contains hidden or 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 asyncio | |
| import logging | |
| import os | |
| from dataclasses import dataclass | |
| from typing import Iterable | |
| from aiofile import AIOFile | |
| logging.basicConfig(level=logging.INFO) |
This file contains hidden or 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
| extern crate tokio; | |
| use std::fs; | |
| use std::path::{Path, PathBuf}; | |
| use std::os::linux::fs::MetadataExt; | |
| use tokio::fs::File; | |
| use tokio::io::AsyncReadExt; | |
| use tokio::time::{sleep, Duration}; | |
| use log::{info, LevelFilter}; | |
| use simple_logger::SimpleLogger; |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Hello API!</title> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css"> | |
| <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> |
This file contains hidden or 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 app = Vue.createApp({ | |
| data: function () { | |
| return { | |
| output: null | |
| } | |
| } | |
| }) | |
| app.component('poll-button', { |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Hello API!</title> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css"> | |
| <script src="https://unpkg.com/vue@next"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> |