Skip to content

Instantly share code, notes, and snippets.

View 1st1's full-sized avatar

Yury Selivanov 1st1

View GitHub Profile
{
scene_max_dpr: 1,
scene_max_samples: 3,
scene_camera_fov: 55,
scene_camera_rot: { x: 0, y: 0, z: 0 },
scene_camera_pos: { x: 0, y: 0, z: 5 },
bg_nspace: 7,
bg_lines: 2,
bg_line_size_vari: { min: 0.3, max: 0.8 },
bg_line_brightness: 87.04,
@1st1
1st1 / example.py
Last active November 15, 2023 09:43
asyncio queues example
import asyncio
import random
import time
async def worker(name, queue):
while True:
# Get a "work item" out of the queue.
sleep_for = await queue.get()
@1st1
1st1 / bench.py
Last active November 1, 2022 11:43
immutables benchmark
import pyrsistent
import immutables
import time
I = 1_000_000
KEY = '5'
for N in [5, 10, 20, 30, 100, 200, 300, 400, 500, 1000]:
print('=============')
import pyrsistent
import immutables
import time
I = 1000000
KEY = '5'
for N in [5, 10, 20, 30, 100, 200, 300, 400, 500, 1000]:
print('=============')
@1st1
1st1 / ares1.log
Created January 27, 2016 16:51
Caching in ceval + LOAD_METHOD
yury@ares ~/benchmarks $ uname -a
Linux ares.sprymix.net 4.1.2 #10 SMP Fri Jul 10 19:14:52 EDT 2015 x86_64 Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz GenuineIntel GNU/Linux
yury@ares ~/benchmarks $ ../tmp/cpython/python -c 'import sys; print(sys.version)'
3.6.0a0 (default, Jan 26 2016, 19:04:11)
[GCC 4.9.3]
yury@ares ~/benchmarks $ cat /proc/meminfo | grep MemTotal
MemTotal: 65948368 kB
@1st1
1st1 / get_buffer_bench.py
Created December 8, 2017 01:47
get_buffer_bench.py
import struct
try:
from time import perf_counter as clock
except ImportError:
from time import time as clock
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@1st1
1st1 / pyssl.sh
Created October 20, 2016 20:08
Compile Python on Mac OS with openssl from macports
export LDFLAGS="-L/opt/local/lib/"
export LD_LIBRARY_PATH="/opt/local/lib/"
export CPPFLAGS="-I/opt/local/include -I/opt/local/include/openssl"
./configure
make -j8
const buf = Buffer.allocUnsafe(16);
function f1(buf) {
return (
buf.slice(0, 4).toString("hex") +
"-" +
buf.slice(4, 6).toString("hex") +
"-" +
buf.slice(6, 8).toString("hex") +
"-" +
@1st1
1st1 / ag.py
Created October 22, 2019 21:39
import time
import threading
def generator():
try:
print('STARTED')
time.sleep(5)
yield 1
finally:
@1st1
1st1 / fileio.py
Last active April 25, 2019 03:47
# in asyncio:
class asyncio.AbstractFileIOImplementation:
async def open(self):
raise NotImplementedError
async def open(...):
return await get_current_loop(). get_file_io_implementation().open(...)