Skip to content

Instantly share code, notes, and snippets.

View olecksamdr's full-sized avatar

Oleksandr olecksamdr

View GitHub Profile
@olecksamdr
olecksamdr / localhost-replicaset.md
Last active February 15, 2021 13:22
Run mongoDb Replica Set on localhost
  1. Find mongodb data folder
grep -i dbPath /etc/mongod.conf
  1. Let's say that data folder is /data/db. Create the necessary data directories for each member by issuing a command similar to the following:
@olecksamdr
olecksamdr / caesar_cipher.py
Last active May 2, 2022 09:00
Шифр Цезаря (caesar cipher) на python
abc = 'абвгґдеєжзиіїйклмнопрстуфхцчшщьюя'
msg = input('Введіть повідомлення: ')
key = int(input('Введіть зміщення: '))
msg = msg.lower()
count = len(abc)
for letter in msg:
idx = abc.index(letter)
@olecksamdr
olecksamdr / string.md
Created March 9, 2021 12:45
Завдання по рядкових велечинах у python

Завдання взяті із підручника Інформатика. Підручник для 7 кл. закладів загальної середньої освіти / Н. В. Морзе, О. В. Барна. — Київ : УОВЦ «Оріон», 2020. — 176 с.

ст.91 завдання 14

Результат Введене значення Отримане значення
1 Усі літери написано двічі школа шшккооллаа
2 Змінено порядок літер у парах книга нкгиа
3 Після кожної літери додано останню літеру слова книга нкгиа
4 Кожну літеру замінено на відповідний код у кодовій таблиці зошит 10791086109610801090
5 [Кожна літера замінена на наступну в кодовій таблиці](#5-кожна-літера-замінена-на-наступну-в-кодовій-таблиц
@olecksamdr
olecksamdr / камінь ножниці папір.py
Created April 6, 2021 12:58
Консольна гра "Камінь, Нижниці, Папір" на Python
import random
choises = ['Камінь', 'Ножниці', 'Папір']
print('0 - ', choises[0])
print('1 - ', choises[1])
print('2 - ', choises[2])
user = int(input('Виберіть цифру: '))
@olecksamdr
olecksamdr / differenceWith.js
Last active July 8, 2021 09:32
differenceWith function. Performs two arrays difference
/**
* Filter out element from excludeFrom array if it equals
* to some of the elements in valuesToExclude array
* Inspired by lodash differenceWith
*
* @param {Array} excludeFrom array to exclude from
* @param {Array} valuesToExclude values which we need to exclude from first array
* @param {Function} comparator returns true if two elements are equal
* @returns {Array} Returns the new array.
* @example
@olecksamdr
olecksamdr / Цикл з параметром.md
Last active March 14, 2022 16:56
Короткий конспект про цикл з параметром Python

Тема: цикл з параметром

Функція range - повертає діапазон

Функція range приймає 3 аргументи range(start, end, step) і повертає діапазон

  • start - початок діапазону
  • end - кінець діапазону. Кінець діапазону не включається
  • step - крок

Приклади використання range

@olecksamdr
olecksamdr / phyllotaxis.py
Last active March 25, 2022 12:36
Draw Phyllotaxis with turtle graphics
import math
from turtle import *
shape('circle')
speed(0)
c = 15
for n in range(500):
a = n * 137.507764050
@olecksamdr
olecksamdr / fractalTree.js
Created April 30, 2024 07:44
Fractal Tree on HTML Canvas
const canvas = document.getElementById('canvas')
const ctx = canvas.getContext('2d')
canvas.width = window.innerWidth
canvas.height = window.innerHeight
const { width, height } = canvas
const startX = width / 2
const startY = height - 100
@olecksamdr
olecksamdr / rayMarching.glsl
Last active September 27, 2024 09:29
GLSL Ray Marching Template
// https://youtu.be/khblXafu7iA?si=jo4m_TubKhM_ct7u
float sdSphere(vec3 p, float r) {
// signed distance to a sphere of radius 1 located at the origin
return length(p) - r;
}
float sdBox(vec3 p, vec3 a) {
vec3 q = abs(p) - a;