Skip to content

Instantly share code, notes, and snippets.

View nitely's full-sized avatar
🟢
online

Esteban C Borsani nitely

🟢
online
View GitHub Profile
@nitely
nitely / unicode_collation.nim
Created June 27, 2026 20:42
unicode_collation.nim
# 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:
@nitely
nitely / pipelining.md
Last active September 3, 2025 22:03
HTTP pipelining pros and cons

HTTP pipelining pros and cons

Pros

  • 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.
@nitely
nitely / gist:db7ada4b3d63bd77f15cda4f7fe2f37e
Created May 23, 2025 01:33
hyperx multi thread windows
## HTTP/2 server
import std/asyncdispatch
import std/asyncnet
import std/net
import std/nativesockets
when defined(ssl):
import ./atexit
import ./clientserver
@nitely
nitely / gist:5a7af5de98e834e6860424634931caf9
Created March 11, 2025 03:17
Nim unbuffered channel / value async
# from hyperx
import std/asyncdispatch
import ./utils
import ./errors
template fut[T](f: FutureVar[T]): Future[T] = Future[T](f)
type
@nitely
nitely / decorators.py
Created March 20, 2013 04:20
Django, django-ratelimit on login admin view
#-*- 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
@nitely
nitely / pushd.py
Created August 7, 2015 12:49
python pushd
from contextlib import contextmanager
import os
@contextmanager
def pushd(new_dir):
prev_dir = os.getcwd()
os.chdir(new_dir)
yield
os.chdir(prev_dir)
@nitely
nitely / font_width.py
Last active December 10, 2023 20:13
get glyph width from ttf font (python 3)
# -*- 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):
@nitely
nitely / flatten.js
Last active May 13, 2023 17:07
Flatten array in JavaScript
// 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);
@nitely
nitely / idle_queue.py
Created October 15, 2012 22:19
Pyqt / Pyside: thread-safe global queue + main loop integration
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()
@nitely
nitely / sqrt.js
Last active May 2, 2023 18:37
Square root (sqrt) in JavaScript using a binary search
/*
sqrt(8)
(0 + 8) / 2 = 4
4 * 4 = 16
(0 + 4) / 2 = 2
2 * 2 = 4
(2 + 4) / 2 = 3
3 * 3 = 9