Skip to content

Instantly share code, notes, and snippets.

View areinull's full-sized avatar

Andrey Lebedev areinull

View GitHub Profile
Алгоритм крестики-нолики, действия по приоритету:
1 Ход в позицию, приводящую к победе
2 Блокировка победы противника на следующем ходу
3 Создание вилки
4 Ход в центр
5 Если противник пошел в угол, ход в противоположный угол
6 Ход в любой угол
7 Ход в любую свободную позицию
@areinull
areinull / self_owned.cpp
Created July 9, 2014 09:19
Self owned class using std::shared_ptr. Destroys itself after work() is done.
#include <memory>
#include <iostream>
#include <unistd.h>
#include <thread>
using namespace std;
class a: public std::enable_shared_from_this<a>
{
std::shared_ptr<a> self;
public:
@areinull
areinull / genImeiIccid.cpp
Created July 11, 2014 11:16
Generate random IMEI (15 digits) and ICCID (19 digits) with Lune checksum
#include <iostream>
#include <stdlib.h>
std::string generateIccid()
{
char res[20];
int sum = 0;
int num = 0;
for (size_t i = 0; i < sizeof res - 2; i++)
@areinull
areinull / transcode.c
Created July 17, 2014 12:34
Transcode audio from amr-nb/amr to vorbis/ogg with ffmeg libs
#include <stdio.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavutil/audio_fifo.h>
#include <libavutil/avstring.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
/** The number of output channels */
#define OUTPUT_CHANNELS 2
@areinull
areinull / concurrent_queue.cpp
Created September 3, 2014 11:30
simple concurrent queue with Boost
template<typename Data>
class concurrent_queue
{
private:
std::queue<Data> the_queue;
mutable boost::mutex the_mutex;
boost::condition_variable the_condition_variable;
public:
void push(Data const& data)
{
@areinull
areinull / .vimrc
Last active October 2, 2015 08:58
My vimrc
"Use Vim settings, rather then Vi settings (much better!).
"This must be first, because it changes other options as a side effect.
set nocompatible
"colors zenburn
set background=dark
set exrc
set secure