Skip to content

Instantly share code, notes, and snippets.

View puemos's full-sized avatar
♨️
Something is cooking

Shy Alter puemos

♨️
Something is cooking
View GitHub Profile
Id Name Orbit level Love Reach Tags Email Company Title Location Url Github Github followers Twitter Twitter followers Discord Discourse Slack Topics Languages Activities count Last activity occurred at First activity occurred at Created at Updated at Orbit url
NQSD3Qd3 Moritz Mueller 2 3.0 0 [] Hannover, Germany Meins321 0 ["ch375","ch376","ch376s","arduino","arduino-library","pwm","ilett","julian","solar","lantiq"] ["C++","C","Python","HTML","Shell","JavaScript","Makefile","Haxe","Batchfile","C#"] 2 2022-03-14 21:34:08 UTC 2021-12-12 11:51:36 UTC 2021-12-16 08:43:39 UTC 2021-12-16 08:43:39 UTC https://app.orbit.love/hls-downloader/members/meins321-e3d691
QaSDGav6 4 2.0 0 [] israelmartins1 0 ["react","chrome-extension","chrome","hls-stream","hls"] ["HTML","Shell","TypeScript"] 1 2021-12-06 00:21:31 UTC 2021-12-06 00:21:31 UTC 2021-12-16 08:43:39 UTC 2021-12-16 08:43:39 UTC https://app.orbit.love/hls-
// the first to fire between "all done" and "cancel"
const { cancelDownload, allDone } = yield race({
allDone: take(allDoneChannel),
cancelDownload: take("CANCEL_DOWNLOAD")
});
// stop the queue manager
yield cancel(watcherTask);
// in case of cancellation just return;
const segmentsCount = segments.length
// transform the segments list to an action list
const actions = segments.map((segment, index) =>
put(queueChannel, { payload: { uri: segment.uri, index, segmentsCount } })
)
// fire them all together
yield all(actions);
const QUEUE_CONCURRENT = 5
const { watcher, queueChannel } = yield createConcurrentTaskQueue(
handler,
QUEUE_CONCURRENT
);
const watcherTask = yield fork(watcher)
function* handler({ uri, index, segmentsCount }) {
// get the data
const res = yield call(fetch, uri);
const blob = yield res.blob();
// report to the store
yield put({ type: "CHUNK_DONE", payload: { index, blob } })
// check if all the chunk are ready
const currentChunkCount = yield select(currentChunkCountSelector)
import { buffers, channel } from "redux-saga";
import { all, call, fork, put, take } from "redux-saga/effects";
/**
* creates a queue
*
* @param {GeneratorFunction} [handler] request handler
* @param {number} [workersCount=1] number of workers
*/
function* createConcurrentTaskQueue(handler, workersCount = 1) {
async function publishAll() {
const [payments, invoices, receipts] = await Promise.all([
getPayments(),
getInvoices(),
getReceipts()
]);
// do stuff with that
}
async function publishAll() {
const payments = await getPayments();
const invoices = await getInvoices();
const receipts = await getReceipts();
// do stuff with that
}
async function publishPipeline(post){
if (!validate(post)){
return { post, status: "failed" };
}
try {
await publish(post)
return { post, status: "published" };
} catch (e) {
return { post, status: "failed", error: e };
}
async function publishAll() {
// You get the posts
const posts = await getPosts();
const successes = [];
const failures = [];
for (const post of posts) {
// synchronous check for validtion
if (!validate(post)) {
failures.push({ post, status: "failed" });
} else {