Skip to content

Instantly share code, notes, and snippets.

View sergey-shambir's full-sized avatar

Sergey Shambir sergey-shambir

  • iSpring Solutions
View GitHub Profile
@sergey-shambir
sergey-shambir / install-clang.sh
Last active November 20, 2023 10:16
install clang on Debian 9
# Add apt.llvm.org repository and install clang
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch main"
sudo apt-get update
sudo apt-get install -y clang clang-format clang-tidy lldb libc++-8-dev libc++abi-8-dev
# Check version
clang --version
clang++ --version
@sergey-shambir
sergey-shambir / format_1_2.bat
Last active October 26, 2018 07:48
Pascal ptop config file for out coding conventions
@echo off
:: formats file 1.pas, puts output to 2.pas
ptop.exe -l 255 -c "%~dp0\ptop.cfg" "%~dp0\1.pas" "%~dp0\2.pas"
@sergey-shambir
sergey-shambir / docker-samples.md
Last active May 31, 2018 19:28
Docker Samples

Вывод версии Docker:

docker --version

Запуск специального тестового контейнера:

docker run hello-world
@sergey-shambir
sergey-shambir / teapot-normals.cpp
Created May 28, 2018 06:16
Correct Utah Teapot normals calculation
MeshDataP3N3 utils::tesselateTeapot(const Material &material, unsigned latitudeDivisions, unsigned longitudeDivisions)
{
const size_t pointCount = std::size(kTeapotPatches) * (latitudeDivisions + 1) * (longitudeDivisions + 1);
const size_t vertexCount = 6 * std::size(kTeapotPatches) * latitudeDivisions * longitudeDivisions;
// TODO: (cg14.3) замените тип элемента в массиве на VertexP3N3.
std::vector<VertexP3N3> points(pointCount);
// Veticies
for (size_t p = 0; p < std::size(kTeapotPatches); p++)
@sergey-shambir
sergey-shambir / ubuntu-lts-migration.md
Last active May 12, 2018 06:59
Guide: migrate from old Ubuntu LTS to new Ubuntu LTS

Migration steps

  1. Upgrade installed packages: sudo apt update && sudo apt upgrade
  2. Remove all packages installed with checkinstall
    • You can search with Synaptic using 'checkinstall' query
  3. Remove all ppa repositories (see "How to remove PPAs " below)
  4. Run Update Manager and upgrade distribution: sudo update-manager -d
  5. After upgrade, use lsb_release -a to see Ubuntu version
@sergey-shambir
sergey-shambir / eratosthenes_sieve_size.py
Created April 22, 2018 15:29
Estimate Erastosthenes Sieve size required to find I-th prime number
import math
def sieve_size_bytes(number_bits):
max_index = 2**number_bits
max_prime = max_index * math.log(max_index)
number_bytes = (number_bits) + 7) / 8
sieve_size = long(math.sqrt(max_prime) * number_bytes / 3)
return sieve_size
print("size for 32-bit index: " + str(sieve_size_bytes(32)))
#include "SimpleScene.h"
#include "RandomColorGenerator.h"
#include <algorithm>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/vec2.hpp>
namespace
{
@sergey-shambir
sergey-shambir / float_equal.cpp
Last active October 27, 2017 10:36
Relative equal comparison
#include <cmath>
// Сравнение с допустимой абсолютной погрешностью
bool areCloseAbsolute(float a, float b, float tolerance = 0.001f)
{
return std::abs(a - b) < tolerance;
}
// Сравнение с допустимой относительной погрешностью
bool areCloseRelative(float a, float b, float tolerance = 0.001f)
@sergey-shambir
sergey-shambir / .clang-format
Last active December 8, 2017 06:19
C++ coding style for Volgatech courses
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
@sergey-shambir
sergey-shambir / build_all.py
Last active October 10, 2017 14:23
Build script for student labs
#!/usr/bin/env python2
from __future__ import print_function
import subprocess
import os
import shutil
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
def prepare_dir(dir, prepare_git):