Skip to content

Instantly share code, notes, and snippets.

View vpodk's full-sized avatar
💻
Coding ...

Valentin Podkamennyi vpodk

💻
Coding ...
View GitHub Profile
@vpodk
vpodk / numbers.js
Last active April 20, 2020 21:20
Manipulating numbers in JavaScript.
var n = 1;
console.log(n.toFixed(2));
// To change the number directly:
// 1. Use parentheses:
console.log((1).toFixed(2));
// 2. Use two dots:
console.log(1..toFixed(2));
// Number binary representation:
console.log(20..toString(2));
@vpodk
vpodk / factorial.js
Last active May 31, 2019 20:44
Computing the factorial in JavaScript.
/**
* Computes the factorial of a given non-negative integer using iterative solution.
* @param {number} n The positive integer.
* @return {number} Returns a factorial of 'n'.
* @see https://en.wikipedia.org/wiki/Factorial
*/
function factorial(n) {
var result = 1;
for (var i = 1; i <= n; ++i) {
@vpodk
vpodk / fibonacci.js
Last active May 30, 2019 19:00
Calculating the value of the Fibonacci number.
/**
* +------------------------------------+
* | FIBONACCI TABLE |
* +------------------------------------+
* | n 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
* | xn 0 | 1 | 1 | 2 | 3 | 5 | 8 | 13 |
* +------------------------------------+
*
* @see https://en.wikipedia.org/wiki/Big_O_notation
* @see https://en.wikipedia.org/wiki/Fibonacci_number#Sequence_properties
@vpodk
vpodk / komito-analytics.html
Last active December 9, 2021 06:52
Integration of Komito Analytics
<script src="https://komito.net/komito.js" async></script>
<script>
// The default configuration can be omitted and only changed properties can be included.
var _komito = _komito || {
'trackTwitter': 1, // Tracks Twitter events if widget is presented on page.
'trackFacebook': 1, // Tracks Facebook events if widget is presented on page.
'trackLinkedIn': 1, // Tracks LinkedIn events if plugin is presented on page.
'trackDownloads': 1, // Tracks files download links.
'trackOutbound': 1, // Tracks outbound links.
@vpodk
vpodk / merge-sorted-arrays.js
Last active March 12, 2024 01:19
Given two sorted arrays, merge them into a new array that is also sorted.
/**
* Merge two sorted integer arrays nums1 and nums2 into nums1, sorted in non-decreasing order.
* The time complexity of this function is O(m + n),
* @param {number[]} nums1 The first sorted array containing elements to be merged.
* @param {number} m The number of elements in nums1 (excluding additional space for merging).
* @param {number[]} nums2 The second sorted array containing elements to be merged into nums1.
* @param {number} n The number of elements in nums2.
* @see https://leetcode.com/problems/merge-sorted-array/
*/
var merge = function(nums1, m, nums2, n) {
@vpodk
vpodk / clap-layout-flex.css
Last active April 20, 2020 01:34
Clean Application — Flexible Box Layout
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
@vpodk
vpodk / clap-layout-index.html
Last active April 20, 2020 01:32
Clean Application — Flexible Box Layout
<body>
<header>Header</header>
<div id="main">
<article>Content</article>
<aside>Left sidebar</aside>
<aside>Right sidebar</aside>
</div>
<footer>Footer</footer>
</body>
@vpodk
vpodk / clap-layout-flex-update.css
Last active April 20, 2020 01:34
Clean Application — Flexible Box Layout
aside, footer, header, #main > article {
padding: 1em;
}
@vpodk
vpodk / clap-layout-theme.css
Last active April 20, 2020 01:33
Clean Application — Flexible Box Layout
body {
background-color: White;
color: DarkSlateGray;
}
header,
footer {
background-color: Indigo;
color: White;
}
#main > aside {
@vpodk
vpodk / clap-positions-app.css
Created April 20, 2020 01:47
Clean Application - Block Positions
body {
font-family: arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
#main {
margin: 5em auto 0;
}
header,