Skip to content

Instantly share code, notes, and snippets.

@PlushBeaver
PlushBeaver / 2016-04-08_server.cc
Last active April 9, 2016 10:22
Код с практического занятия 08.04.2016
struct Client {
int channel;
std::vector<char> buffer;
uint64_t to_receive = 8;
uint64_t received = 0;
bool on_receive();
};
int main() {
@PlushBeaver
PlushBeaver / kozlyuk_basic.cc
Last active March 3, 2017 19:51
Входной тест для http://cpp-school.unigine.com без изысков.
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <algorithm>
using namespace std;
void skip_to_word(istream& stream);
string scan_word(istream& stream);
@PlushBeaver
PlushBeaver / kozlyuk_utf8.cc
Created March 3, 2017 19:56
Входной тест для http://cpp-school.unigine.com/ с поддержкой UTF-8 при помощи велосипеда.
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <algorithm>
using namespace std;
using Code = uint16_t;
enum Symbol { Letter, Delimiter, Unsupported, Invalid, End };
@PlushBeaver
PlushBeaver / record.sh
Created May 28, 2019 19:05
Record video from remote PTZ camera into chunks
# Adjust parameters in CAPS to your needs.
SEGMENT_HOURS=6
RECORD_DAYS=7
exec ffmpeg \
-y -hide_banner -nostats -loglevel info \
-i 'http://IP:PORT/videostream.cgi?user=USERNAME&pwd=PASSWORD' \
-f segment -segment_time $((SEGMENT_HOURS*60*60)) -segment_wrap $((RECORD_DAYS * 24 / SEGMENT_HOURS)) -segment_atclocktime 1 \
-strftime 1 \
"recording_%Y-%m-%d_%H-%M.webm"
@PlushBeaver
PlushBeaver / iocp.c
Created August 21, 2020 22:28
IOCP alertable wait (buggy)
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <windows.h>
#include <stdio.h>
OVERLAPPED overlapped = {};
VOID
timer_proc(LPVOID arg, DWORD low, DWORD high)
{
/*
* gcc -O2 matrix.c -o matrix
*
* for i in {1..30}; do echo 768 | ./matrix; done > matrix.csv
*
* R
* data = read.csv("matrix.csv", header = FALSE)
* wilcox.test(data$V1, data$V2, alternative = "two.sided")
*/