Skip to content

Instantly share code, notes, and snippets.

View romannmk's full-sized avatar

Roman Naumenko romannmk

  • Calgary, Alberta
View GitHub Profile
@romannmk
romannmk / skew.js
Last active April 2, 2020 06:55
Skew on scroll
React.useEffect(() => {
const section = pageRef.current
let currentPixel = window.pageYOffset
const looper = () => {
const newPixel = window.pageYOffset
const diff = newPixel - currentPixel
const speed = diff * 0.01
if (section) {
const units = ['bytes', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb'];
export const getSizeFromBytes = x => {
let l = 0,
n = parseInt(x, 10) || 0;
while (n >= 1024 && ++l) n = n / 1024;
// include a decimal point and a tenths-place digit if presenting
// less than ten of KB or greater units
return n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l];
@romannmk
romannmk / apiCaller.js
Created January 17, 2019 10:14
call to api function
export default async (method, url, payload) => {
try {
const config = {
...(method !== 'GET' && { body: JSON.stringify(payload) }),
method: method,
headers: {
'Content-Type': 'application/json',
...(token && { Bearer: `token` })
}
};
@romannmk
romannmk / .vimrc
Last active March 14, 2022 20:39
Simple vimrc configuration
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plugin 'pangloss/vim-javascript', { 'for': ['javascript', 'javascript.jsx'] }
Plugin 'mxw/vim-jsx', { 'for': ['javascript', 'javascript.jsx'] }