- Client sends all requests without waiting for the server responses.
- This saves at least one roundtrip since the server no longer needs to wait for the client to receive the response in order to get the next request.
- Client does less OS calls to send the requests, as it can concatenate them.
- Server can process all requests at the same time, saving total latency time for all requests and responses combined.
- Even if the server does not support pipelining, the client sending all requests combined still saves up to N half-roundtrips. Where N is the number of requests.
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
| # MIT License | |
| # | |
| # Copyright (c) 2026 Esteban Castro Borsani | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: |
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
| ## HTTP/2 server | |
| import std/asyncdispatch | |
| import std/asyncnet | |
| import std/net | |
| import std/nativesockets | |
| when defined(ssl): | |
| import ./atexit | |
| import ./clientserver |
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
| # from hyperx | |
| import std/asyncdispatch | |
| import ./utils | |
| import ./errors | |
| template fut[T](f: FutureVar[T]): Future[T] = Future[T](f) | |
| type |
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
| #-*- coding: utf-8 -*- | |
| from django.contrib import messages | |
| from django.core.urlresolvers import reverse | |
| from django.shortcuts import redirect | |
| # https://github.com/jsocol/django-ratelimit | |
| from ratelimit.decorators import ratelimit | |
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
| from contextlib import contextmanager | |
| import os | |
| @contextmanager | |
| def pushd(new_dir): | |
| prev_dir = os.getcwd() | |
| os.chdir(new_dir) | |
| yield | |
| os.chdir(prev_dir) |
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
| # -*- coding: utf-8 -*- | |
| from fontTools.ttLib import TTFont | |
| font = TTFont('/home/esteban/Downloads/unifont-10.0.07.ttf') | |
| cmap = font['cmap'] | |
| t = cmap.getBestCmap() | |
| s = font.getGlyphSet() | |
| def width(c): |
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
| // Space complexity: O(n) | |
| // Time complexity: O(n) where n includes nested elements | |
| function flatten(arr) { | |
| return arr.reduce((acc, elem) => { | |
| if (Array.isArray(elem)) | |
| acc.push(...flatten(elem)); | |
| else | |
| acc.push(elem); | |
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 Queue | |
| #Global queue, import this from anywhere, you will get the same object. | |
| #real life example: https://github.com/nitely/ochDownloader/blob/master/core/idle_queue.py | |
| idle_loop = Queue.Queue() |
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
| /* | |
| sqrt(8) | |
| (0 + 8) / 2 = 4 | |
| 4 * 4 = 16 | |
| (0 + 4) / 2 = 2 | |
| 2 * 2 = 4 | |
| (2 + 4) / 2 = 3 | |
| 3 * 3 = 9 |
NewerOlder