Skip to content

Instantly share code, notes, and snippets.

View justlstn's full-sized avatar
👨‍💻
Write some code. Sometimes it works

Viacheslav Matsenko justlstn

👨‍💻
Write some code. Sometimes it works
  • alao AG
  • Kharkiv, Ukraine
View GitHub Profile
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// using
// await sleep(300);
@justlstn
justlstn / move_head_scripts_to_footer.php
Last active July 9, 2018 15:43
Wordpress. Script to move all Head scripts to the Footer
@justlstn
justlstn / _animations.scss
Last active July 9, 2018 15:50
Block UI & Preloader with spin animations
@keyframes block-ui-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
@justlstn
justlstn / fileUpload.vue
Created August 23, 2018 23:09 — forked from raisiqueira/fileUpload.vue
Simple file upload with Vue and Axios
<style>
input[type="file"]{
position: absolute;
top: -500px;
}
div.file-listing{
width: 200px;
}
@justlstn
justlstn / add-files-to-custom-fields.php
Created August 24, 2018 10:18
Add multiple files to acf repeater field
$files = $_FILES[ 'attachments' ];
$attachments = [];
foreach ( $files['name'] as $key => $value ) {
if ( $files[ 'name' ][ $key ] ) {
$file = array(
'name' => $files[ 'name' ][ $key ],
'type' => $files[ 'type' ][ $key ],
'tmp_name' => $files[ 'tmp_name' ][ $key ],
'error' => $files[ 'error' ][ $key ],
@justlstn
justlstn / simple-pagination.js
Created August 26, 2018 18:00 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@justlstn
justlstn / script.js
Created September 27, 2018 11:05
Receiving video via webcam
let getUserMedia;
let browserUserMedia = navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia
|| navigator.getUserMedia;
if (!browserUserMedia) throw 'Your browser doesn\'t support WebRTC';
getUserMedia = browserUserMedia.bind(navigator);
let successCb = stream => {
@justlstn
justlstn / install-docker.sh
Created February 18, 2019 23:57 — forked from dweldon/install-docker.sh
Install docker CE on Linux Mint 18.3
#!/usr/bin/env bash
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt-get install docker-ce
# https://docs.docker.com/compose/install/
@justlstn
justlstn / parallax-mouse-moving.js
Last active May 14, 2019 08:15
Returns an object with coors that you can use for CSS transition { top, left }
export const getOffset = (e, offset = 3, isCentered = true) => {
const pageX = e.pageX
const pageY = e.pageY
const scrollTop = window.pageYOffset // To remove a {scrollTop} from the {pageY}
const winWidth = window.innerWidth
const winHeight = window.innerHeight
const centerTop = winHeight / 2
const centerLeft = winWidth / 2
const onePercentWidth = centerLeft / offset
const onePercentHeight = centerTop / offset
@justlstn
justlstn / class_decorator.ts
Created May 9, 2020 22:22 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}