Skip to content

Instantly share code, notes, and snippets.

View amberlex78's full-sized avatar
🏠
Working from home

Oleksii Abrosymov amberlex78

🏠
Working from home
View GitHub Profile
@amberlex78
amberlex78 / Dockerfile
Created March 17, 2023 05:46
py-hello-word-docker
FROM python:3.9-alpine
RUN mkdir /app
WORKDIR /app
COPY . /app
CMD ["python", "app.py"]
@amberlex78
amberlex78 / num_2_words.php
Last active June 11, 2023 15:03
Преобразование количества "цифрой" в количество "словом"
/**
* Преобразование количества "цифрой" в количество "словом"
* Чтобы было удобнее формировать массивы со склонениями, запомните ряд чисел 1-2-5,
* а потом мысленно подставляйте их в массив: (один "рубль", два "рубля", пять "рублей")
* $num = 3;
* $words = array('новость', 'новости', 'новостей');
* echo $num . ' ' . num_2_word($num, $words); // сколько новостей
*
* @param $n
* @param $words
@amberlex78
amberlex78 / app.js
Last active October 24, 2023 06:57
dark-light switcher
(() => {
'use strict';
// Функция для работы с localStorage
const getStoredValue = (key, defaultValue) => localStorage.getItem(key) || defaultValue;
const setStoredValue = (key, value) => localStorage.setItem(key, value);
// Функции для установки фронт-темы и фронт-иконки
const setFrontTheme = theme => document.documentElement.setAttribute('data-bs-theme', theme);
const setFrontThemeIcon = themeIcon => document.querySelector('#themeIcon').setAttribute('xlink:href', themeIcon);
@amberlex78
amberlex78 / object-mutation.js
Last active February 19, 2024 00:16
Object Mutation in Javascript
const user = {
age: 22,
gender: 'male',
address: {
city: 'Kyiv'
}
}
// Copying objects
const user2 = user; // assignment of reference
function greet(person: string, date: Date): void {
console.log(`Hello, ${person}! Today is ${date.toDateString()}.`);
}
const getFullName = (first: string, last?: string): string =>
last ? `${first} ${last}` : `${first}`;
let fullName = getFullName("John");
greet(fullName, new Date());