Skip to content

Instantly share code, notes, and snippets.

#include <assert.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/errqueue.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/errqueue.h>
#include <iostream>
#include <string>
#include <array>
#include <type_traits>
using std::cout;
using std::endl;
using std::array;
void func() {
#include <iostream>
#include <string>
#include <array>
#include <type_traits>
using std::cout;
using std::endl;
using std::array;
template<typename... Ts>
@alekswn
alekswn / PolygonConcavityIndex.cpp
Created March 1, 2016 23:14
Codility lessons solutions
#include <algorithm>
static int sign(int64_t v) { return (0 < v) - (v < 0); };
static int rotDir (const Point2D& a, const Point2D& b, const Point2D& c) {
return sign(int64_t(b.x - a.x)*int64_t(c.y - a.y) - int64_t(b.y - a.y)*int64_t(c.x - a.x));
}
int solution(vector<Point2D> &A) {
if (A.size() < 3) return -1;
@alekswn
alekswn / adb_rotate.sh
Created January 22, 2016 23:41
Android: screen rotation from ADB
#!/bin/sh
if [ -z $1 ]
then
echo "Usage: $0 { p | l | a }. p - portrait, l - landscape, a - auto"
elif [[ $1 == a* ]]
then
echo "Turning on automatic rotation"
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:1
else
@alekswn
alekswn / Benchmark.h
Last active January 1, 2016 14:49
C++11 Performance and Memory Benchmark
/***********************************************************************************
* C++11 Performance and Memory Benchmark *
* Copyright (C) 2015 Alexey Novikov (Email: alexey_AT_novikov_DOT_io) *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, this *
* list of conditions and the following disclaimer. *
@alekswn
alekswn / bench.h
Created November 21, 2015 01:41
Dawn easy benchmark for C++
#ifdef BENCH
#include <ctime>
#include <chrono>
#define BENCHMARK_START \
auto t_start = std::chrono::high_resolution_clock::now(); \
std::clock_t c_start = std::clock();
#define BENCHMARK_FINISH( OUT_STREAM, NAME ) \
std::clock_t c_end = std::clock(); \
auto t_end = std::chrono::high_resolution_clock::now(); \
OUT_STREAM << "BENCHMARK \"" << NAME << "\" : " \
@alekswn
alekswn / .vimrc
Last active February 20, 2018 15:28
My .vimrc
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
" disable vi compatibility (emulation of old bugs)
set nocompatible
" use indentation of previous line
set autoindent
" use intelligent indentation for C
set smartindent