Skip to content

Instantly share code, notes, and snippets.

template <class Fun>
class ScopeGuard {
Fun f_;
bool active_;
public:
ScopeGuard(Fun f)
: f_(std::move(f))
, active_(true) {
}
~ScopeGuard() { if (active_) f_(); }
import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.math;
class Summator
import std.stdio;
import core.stdc.stdio;
import std.string;
import std.algorithm;
public class Item
{
public int value;
public int weight;
}
@phaser
phaser / CF_755A.cs
Created September 4, 2017 06:32
Solution to CodeForces 755/A problem.
using System;
public class CF_755A
{
static int Main(string[] args)
{
uint n = Convert.ToUInt32(Console.ReadLine());
Console.WriteLine(new CF_755A().solve(n));
return 0;
}
@phaser
phaser / CF_285B.cs
Created September 4, 2017 06:33
Solution to CodeForces 285 B problem.
using System;
public class CF_285B
{
public int solve(int[] p, int s, int t)
{
s--; t--;
for (int i = 0; i < p.Length; p[i]--, i++) { }
int cp = s;
int numelems = 0;
@phaser
phaser / effective_modern_cmake.md
Created August 7, 2018 14:39 — forked from mbinna/effective_modern_cmake.md
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@phaser
phaser / configure_muliple_gcc.sh
Created August 20, 2018 09:38 — forked from SunnyRaj/configure_muliple_gcc.sh
Configure multiple GCC versions on ubuntu
#!/usr/bin/env bash
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo apt-get install -y gcc-4.8 g++-4.8 gcc-4.9 g++-4.9 gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10

Install packages (Ubuntu 18.10)

  sudo apt-get install qemu-kvm qemu virt-manager virt-viewer

Create initial image

Building DPDK kernel module with DKMS

cd /usr/src
sudo wget https://fast.dpdk.org/rel/dpdk-18.11.1.tar.xz
sudo tar -xvf dpdk-18.11.1.tar.xz

Before doing anything do an in-place build of DPDK. The build system uses some of the things it creates during this build process.

make T=x86_64-native-linuxapp-gcc config

To make sure that Hyper-V is really disabled run the following command in PowerShell with Administrator rights:

bcdedit /set hypervisorlaunchtype off 

Usually when VirtualBox stops working with a message complaining about VT-x missing then this might solve it.