Skip to content

Instantly share code, notes, and snippets.

use std::time::{Duration, Instant};
use async_io::{block_on, Timer};
use async_stream::stream;
use futures::StreamExt;
use futures_lite::future::yield_now;
fn main() {
let result = block_on(async {
stream! {
loop {
yield async {
@ethe
ethe / stream.rs
Last active January 9, 2024 10:57
use std::pin::pin;
use std::time::{Duration, Instant};
use async_io::{block_on, Timer};
use async_stream::stream;
use futures::StreamExt;
use futures_lite::future::yield_now;
async fn item() -> Duration {
let start = Instant::now();
use snafu::Snafu;
use std::future::Future;
use std::pin::Pin;
use std::thread;
use tokio::runtime::Builder;
use tokio::sync::mpsc;
use tokio::sync::mpsc::Receiver;
use tokio::sync::mpsc::Sender;
use tokio::task::{spawn_local, LocalSet};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF6n+K0BEAChGyyyxLlkJ8CUD/hd6XlJQHAg1+/THhxR4UcYoDcnGO2iJPUE
WQpDARt7A3ot7bj6L0l7QLahHF/M4XHe8pDs/uNgmPzOq9rCwQ8mVcUpblZ6Fmks
HrBe3nmYk3sESeowOjwRaIKHSAjc/rwCd6A0xdk+YI8Pfe3QZhV+CZ2E1JSkxigB
ReveybwemY3V730wX2vVksBh+JwCDkYFKD4aZuHMcbTDqZyJFYV4TkkEOF2Zgp9+
bfmCL1XMZpSVw/xGVoOHS8t6U/M0OlSVl7aPqOw9Hdr4DSIfWVe2vXJ7Vf8gdEUO
To/XeHzFtIhI8PkxpI2GR2mngCLoEo/DKXMY31bE8Hg/Tr1qx/huSqboRh4Jt7DJ
m0MViPWjz1hJx1/wTCr1IH1dB369WuAGLnLRM0gu+Qv5vBVTVUg+ZAQlZTUxRo1J
83qcdrSgO/orxIId4X5xh1RetUqhS2GE2KyXMbNqdKczGlkrC8pTsUGTICw5+fWH
function f()
cnt = 1
function add()
cnt += 1
cnt
end
end
a = f()
println(a())
def foo
cnt = 0
return lambda {
cnt += 1
return cnt
}
end
func = foo
@ethe
ethe / HPS.m
Created December 3, 2019 09:45 — forked from sakamoto-poteko/HPS.m
HPS algorithm for tone detection
function [ freq ] = HPS(audiofile)
CORRECTFACTOR=1;
[sample, fs] = audioread(audiofile);
fftn = fs;
sample = sample .* hann(length(sample));
fftr = abs(fft(sample,fftn));
fftr = fftr(1:fftn/2);
@ethe
ethe / test.py
Last active August 13, 2019 11:10
from multiprocessing import Pool
import requests
def process_url(url):
print('start')
requests.get(url)
print('done')
return
import asyncio
async def sleep():
print('start')
try:
await asyncio.sleep(100)
except:
print('canceld')