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
""" | |
Demonstrates how to cancel a task when the client disconnects in FastAPI. | |
This reduce cpu consumption and memory usage for long tasks if clients stop waiting for answers. | |
Code from Scott Driggers posted at https://gist.github.com/msdrigg/02c7716d6e2a0cb4e5ef08d14f180119 | |
Initial discussion at here https://github.com/tiangolo/fastapi/discussions/8805 | |
Note: using these methods will likely discard request body (because they call receive and discard the result) | |
So it is not suitable for websocket or streaming requests. |
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
int speed, __speed; | |
task music() | |
{ | |
while (true) | |
{ | |
PlayTone(262,40); Wait(50); | |
PlayTone(294,40); Wait(50); | |
PlayTone(330,40); Wait(50); | |
PlayTone(294,40); Wait(50); |
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
''' | |
Script to archive Slack messages from a channel list. | |
You have to create a Slack Bot and invite him to private channels. | |
View https://github.com/docmarionum1/slack-archive-bot for how to configure your account. | |
Then provide the bot token to this script with the list of channels. | |
''' | |
TOKEN='xoxb-xxxxx-xxxxxx-xxxxxxxxxxx' | |
channels = { |
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 requests | |
import os | |
''' | |
https://climateknowledgeportal.worldbank.org/download-data | |
''' | |
PATH = '/temp/' | |
nature_of_data = ['projection', 'historical'] | |
past_time_series = ["1901-1930", "1931-1960", "1961-1990", "1901-2016", "1991-2016"] |
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
# UPDATED : seems to work but I have still some problems I think | |
# use samplerate to resample as speexdsp resample is bad | |
defaults.pcm.rate_converter "samplerate" | |
pcm.!default { | |
type asym | |
playback.pcm "playback" | |
capture.pcm "ac108" | |
} |