Skip to content

Instantly share code, notes, and snippets.

Alican Çubukçuoğlu AlicanC

Block or report user

Report or block AlicanC

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gitClean.sh
# Helpers
ask() {
# http://djm.me/ask
local prompt default REPLY
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
View doWithRetries.js
/* @flow */
export default async function doWithRetries<TFnResolveValue>(
retryCount: number,
fn: () => Promise<TFnResolveValue>,
): Promise<TFnResolveValue> {
let retriesLeft = retryCount;
let lastError;
do {
@AlicanC
AlicanC / asyncComponentDidMount.js
Created Feb 27, 2016
A legacy decorator for React components with componentDidMount methods that do asynchronous tasks
View asyncComponentDidMount.js
import _ from 'lodash';
export default function asyncComponentDidMount(rejector = 'Component was unmounted.') {
return (component) => {
const cancelMap = new WeakMap();
const isCancelled = async (promise) => {
let cancelled = cancelMap.get(this);
if (cancelled) return cancelled;
View ordered-limited-promise-queue.js
/*
Queue
- Push task runners (async functions) to its "list"
- Run it
- Subscribe to its observable and wait for results
Runs "threadCount" amount of tasks in the "list"
When any of those tasks are completed, runs another task
If task #2 finishes before #1, it waits for #1 to finish and published before it publishes #2 so results are delivered in order
You can’t perform that action at this time.