Skip to content

Instantly share code, notes, and snippets.

@newmen
newmen / raw_species_find_algorithms.clj
Last active August 29, 2015 14:08
Чтобы переосознать процесс, можно попробовать его написать на другом языке
; bridge
(defn find [anchor]
(if (is anchor 3)
(if (havent anchor BRIDGE 3)
(def nbrs (cross_110 (crystal anchor) anchor))
(if (and (all nbrs) (is nbrs[0] 6) (is nbrs[1] 6)
(has_bond anchor nbrs[0]) (has_bond anchor nbrs[1]))
(def atoms [anchor nbrs[0] nbrs[1]])
(create BRIDGE atoms)))))
@newmen
newmen / maks.rb
Last active August 29, 2015 14:01
vd-config-description
# Описываем используемые хим. элементы и их валентность
elements
atom H, valence: 1
atom C, valence: 4
# Описываем используемые крист. решётки и структуры, состоящие из атомов описанных
# выше. Поверхностные структуры не могут состоять из одновалентных атомов. Конечное
# валентное состояние атомов структур задаваемых в этом разделе, определяется при
# описании уравнений реакций кинетической схемы (см. ниже).
surface
@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