Skip to content

Instantly share code, notes, and snippets.

import std/httpclient
import std/net
import std/strutils
import std/json
import std/re
var client = newHttpClient(sslContext=newContext(verifyMode=CVerifyNone))
# const extEvent = "vereya-gruppa2023"
# const urlEvent = "https://mysport.photo/public/photo-service/api/v1/events?externalEventId=" & extEvent
@inv2004
inv2004 / d.nim
Last active November 1, 2022 19:26
Activity simulation
import os
import osproc
const sleepMs = 500
proc exec(cmd: string) =
if 0 != execCmd cmd:
echo "Error during: "&cmd
quit 1
@inv2004
inv2004 / a.py
Last active October 5, 2022 13:34
Python question
import threading
c = 0 # counter
def inc():
global c
c = c + 1
threads = list()
proc counter*[T: byte](a: openArray[T]): Counter[T] =
let mask0 = set1_epi8(0)
let mask1 = set1_epi8(1)
let mask2 = set1_epi8(2)
let mask3 = set1_epi8(3)
var i = 0
while i < a.len-avx.width:
let ymm = loadu_byte(unsafeAddr a[i])
if 0 < popcnt_u32 movemask_epi8 cmpgt_epi8(ymm, mask3):
unroll for off in 0..<(avx.width):
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, tag2__eD00OL9aGxJKms4Pcav4Eew)(tyObject_StreamFix2__puuL7GxzNXmsnKOJJ8DRDw* f, NimStringDesc* tag) {
NimStringDesc* result;
size_t tLen;
NIM_CHAR* tAddr;
{ result = (NimStringDesc*)0;
tLen = ((size_t) ((tag ? tag->Sup.len : 0)));
tAddr = (&tag->data[((NI) 0)]);
{
while (1) {
if (!((*f).pos < (*f).last)) goto LA2;
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, tag1__HiKHrrLOYR4hBpllSVCC1A)(tyObject_StreamFix__b69b4grKaFTd4YkM1TSIRbA* f, NI tag) {
NimStringDesc* result;
NI l;
NI t;
{ result = (NimStringDesc*)0;
l = ((*f).msg ? (*f).msg->Sup.len : 0);
t = (NI)0;
{
while (1) {
NI c;
@inv2004
inv2004 / k.nim
Last active April 13, 2020 23:33
import tables
import threadpool
proc count(i: int): CountTable[int] =
for x in 0..i:
result.inc(x)
proc calc() =
var res = newSeq[FlowVar[CountTable[int]]](3)
for i in 0..2:
import asyncdispatch, json
proc f(): Future[seq[JsonNode]] {.async.} =
let fullJson = %*{"list": [{"c":1}, {"c":2}]}
for json in fullJson["list"]:
result.add(json)
when isMainModule:
let cs = waitFor f()
use std::thread;
use std::time::Duration;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
fn main() {
let m = MultiProgress::new();
let sty = ProgressStyle::default_bar()
.template("[{elapsed_precise}] {bar:40.cyan/blue} {pos:>7}/{len:7} {msg}")
.progress_chars("##-");
#![feature(duration_as_u128)]
#[macro_use]
extern crate bson;
extern crate mongo_driver;
use std::time::Instant;
use std::sync::Arc;
use mongo_driver::client::{ClientPool, Uri};