Skip to content

Instantly share code, notes, and snippets.

View hqhs's full-sized avatar

Dima hqhs

View GitHub Profile
from functools import reduce
class A:
def __init__(self, obj_list):
self.obj_list = obj_list
class B:
def __init__(self, number):
// Package provides basic http server capable of creating, viewing and
// savind text files as txt.
// To make it run you need to have two files: edit.html and view.html
// where must be {{.Title}} and {{printf "%s" .Body}} directives, for
// title text and body text. Form action="/save/{{.Title}}", method="POST"
package main
import (
"errors"
"fmt"
set-option -sg escape-time 10
set-option -g default-terminal "screen-256color"
# set allow-rename off
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# better prefixes
bind-key ` last-window
#include <exception>
#include <stdexcept>
#include <utility>
#include <typeinfo>
template <class T> class Expected
{
union
{
T ham;
@hqhs
hqhs / Expected.hpp
Created December 8, 2019 14:18
Updated "expected" version from Andrei Alexandrescu
template <class T, class E> class expected
{
union {
T yay;
E nay;
};
bool ok = true;
public:
expected() { new (&yay) T(); }

попробовать можно так:

import aiohttp
import asyncio
import sys
from aiohttp import web
from aiojobs.aiohttp import setup, spawn

async def handle(request):
 response = web.StreamResponse()
import asyncio
import aiohttp
from time import monotonic
from random import randrange
async def send_request_to_expona(session):
i = (randrange(1000) + 50)/1000
print('waiting: {}', i)
await asyncio.sleep(i)
@hqhs
hqhs / main.c
Last active May 3, 2021 12:11
wait child process to receive signal
/**
Author: Dmitry Afanasyev
Compiler version:
gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Compile:
gcc main.c -o test && ./test
PHP version:
php --version
UTF-8 encoded sample plain-text file
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25 CC BY
The ASCII compatible UTF-8 encoding used in this plain-text file
is defined in Unicode, ISO 10646-1, and RFC 2279.
@hqhs
hqhs / .clang-format
Last active November 16, 2023 08:47
BasedOnStyle: WebKit
AlignAfterOpenBracket: BlockAlign
AlignConsecutiveMacros: AcrossEmptyLines
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AllowShortEnumsOnASingleLine: false
AlwaysBreakAfterReturnType: All
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman