Skip to content

Instantly share code, notes, and snippets.

View imposeren's full-sized avatar

Yaroslav Klyuyev imposeren

View GitHub Profile

Keybase proof

I hereby claim:

  • I am imposeren on github.
  • I am imposeren (https://keybase.io/imposeren) on keybase.
  • I have a public key whose fingerprint is 9CC5 255F 09FB A398 B7B8 50FE 94A6 EAF2 5253 2CA7

To claim this, I am signing this object:

#!/usr/bin/env python3
"""Dummy straight-forward implementation of Langton's Ant and with ugly `main`
(uglyness allows to calculate some good defaults...).
Less ugly version: https://gist.github.com/imposeren/107bd5b311432ad40cdcfe959fb69c55
"""
import argparse
import math # Only used for "example code" that is not needed really.
import os
import shutil
#!/usr/bin/env python3
"""Dummy straight-forward implementation of Langton's Ant.
More ugly version but with better defaults for stdout drawings:
https://gist.github.com/imposeren/f8dcfa1791b6efb296a2b9428df15dfa
"""
import argparse
import math # Only used for "example code" that is not needed really.
import os
import shutil
#Например: window_rate_limit=500, time_window_seconds = 3600, cooldown_steps=4 (cooldown 4 times during time_window_seconds)
#
#Храним:
#* key=api_key — self explanatory
#* last_timestamp — self explanatory
#* last_cooldown_timestamp — last time cooldown of avg rate was done.
#* current_rate — current average requests rate
#* cooldown_amounts — tracks how much cooling down is needed. Defaults to empty list: `[]`.
#
#При получении запроса:
class MutableInt:
def __init__(self, value):
self.value = value
def __iadd__(self, other):
self.value += other
return self
def __imul__(self, other):
import random
import timeit
number = 100000000
variations = 300
test_vals = tuple(tuple(random.randint(4, 10) for _x in range(6)) for i in range(variations))
t = timeit.timeit(
'num_good = 0\nfor (x,y,z,a,b,c) in test_vals:\n\tif 7 in (x,y,z,a,b,c):\n\t\tnum_good += 1',
globals={'test_vals': (vars_tuple for vars_tuple in test_vals)}, number=number
"""Sortable by time "id-generator" with configurable bit-length of time-, node-, random-based parts"""
import time
import random
import uuid
_last_delta_time_val = None
_default_offset_nanosecs = 1463565297762000000
_bit_masks = {}
#!/bin/sh
cd "${HOME}/.local/Sublime Text 2"
./sublime_text & st_pid=$!
urxvt -name borderless_urxvt & rxvt_pid=$!
onExit() {
echo
echo Exiting
kill -15 $rxvt_pid 2>/dev/null