Skip to content

Instantly share code, notes, and snippets.

@newmen
newmen / sfinae.cpp
Last active March 7, 2020 15:52
SFINAE in C++03 and C++11 implementations
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
class Base
{
protected:
Base() {}
public:
@newmen
newmen / uninstall_old_gems.rb
Last active January 2, 2016 05:29
This little code is more useful if you doesn't want keep old versions of installed gems
`gem list`.split("\n").each do |line|
next if line == ''
name = line.scan(/^\S+/).first
versions = line.scan(/\(([^\)]+)\)/).first.first.split(', ')
versions.shift
unless versions.empty?
versions.each do |version|
`gem uninstall #{name} -v #{version} --force`
end
end
@newmen
newmen / poisson_2d.cpp
Last active December 29, 2015 13:09
Uniform and Poisson distributions: Generating random numbers in parallel mode, where "bad" is using just one common generator, and "good" is using undependent generator for each thread.
#include <assert.h>
#include <chrono>
#include <iostream>
#include <omp.h>
#include <random>
#include <vector>
using namespace std;
#define Nx 50