Skip to content

Instantly share code, notes, and snippets.

View dmitru's full-sized avatar
🎯

Dmitry Borody dmitru

🎯
  • Inkarnate
  • Remote
  • 08:27 (UTC -04:00)
View GitHub Profile
@dmitru
dmitru / 000.c
Created September 13, 2011 15:22
MIPT EJudge problems
/*
MIPT, task #000
"A + B"
12.09.2011
*/
#include <stdio.h>
int main ()
{
@dmitru
dmitru / reader.c
Created October 5, 2012 22:31
One-way communication with FIFOs
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define BUF_SIZE 4096
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
struct thr_data{
double b;
double e;
double step;
double count;
};
@dmitru
dmitru / server.c
Created May 16, 2013 19:37
A simple UNIX socket server
// You can test your server programs with 'telnet' UNIX tool.
// see man telnet!
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
@dmitru
dmitru / client.c
Created May 16, 2013 20:05
A UNIX socket client
// Usage:
// client <address> <port>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
@dmitru
dmitru / hw.cpp
Last active December 19, 2015 04:49
My learning of concurrent programming in C++11
#include <iostream>
#include <thread>
void hello()
{
std::cout << "HW!" << std::endl;
}
int main()
{
@dmitru
dmitru / functional.cpp
Created September 26, 2015 21:08
An example showing how to use some functional constructs in C++
#include <iostream>
#include <string>
#include <vector>
int main()
{
// Enter lambda functions..
auto sum = [] (int x, int y) {
std::cout << "Hello, side-effects!" << std::endl;
return x + y;
@dmitru
dmitru / containers.cpp
Created September 26, 2015 21:08
An example showing usage of some std containers in C++11
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
int main()
{
std::vector<int> a = {1, 2, 3, 4, 5};
a.push_back(42);
@dmitru
dmitru / send_inmemory_zipfile_flask.py
Created January 18, 2016 10:44
How to create and file_send() in-memory zipfiles in Flask
memory_file = BytesIO()
with zipfile.ZipFile(memory_file, 'w') as zf:
files = result['files']
for individualFile in files:
data = zipfile.ZipInfo(individualFile['fileName'])
data.date_time = time.localtime(time.time())[:6]
data.compress_type = zipfile.ZIP_DEFLATED
zf.writestr(data, individualFile['fileData'])
memory_file.seek(0)
return send_file(memory_file, attachment_filename='capsule.zip', as_attachment=True)
@dmitru
dmitru / delete_all_orders_at_price.cpp
Last active April 1, 2016 11:56
HFTBattle Blog, article #2
void delete_all_at_price(Dir dir, Price price) {
auto orders_map = trading_book_info.orders().get_orders_by_dir_to_map(dir);
auto it = orders_map.find(price);
if (it == orders_map.end()) {
return;
}
auto& active_orders = it->second;
for (auto& order : active_orders) {
delete_order(order);
}