Skip to content

Instantly share code, notes, and snippets.

View kikill95's full-sized avatar

Kirill Gusyatin kikill95

View GitHub Profile
@kikill95
kikill95 / promises.js
Last active March 15, 2023 17:55
Promises
// create Promise
var promise = new Promise(function(fulfill, reject) {
if (/* condition */) { // for example, statusCode === 200 or something else, whatever
fulfill(/* success params */);
} else {
reject(/* fail params */);
}
});
// work with Promise
@kikill95
kikill95 / index.html
Created April 17, 2018 10:15
Detect file mime type using magic numbers and JavaScript
<!doctype html>
<html lang="en">
<head>
<title>Filereader</title>
<style>
div {
font-family: "Helvetica Neue";
line-height:22px;
font-size:15px;
margin:10px 0;
@kikill95
kikill95 / index.html
Last active October 13, 2020 11:40
LevelUp:coding - sample file for intro
<!doctype html>
<html lang="en">
<head>
<title>Мой сайт</title>
<style>
p {
color: red;
}
</style>
</head>
@kikill95
kikill95 / Pass callbacks
Last active October 19, 2019 07:33
perform.js
//by Denys Pysmennyi
function perform() {
//TODO implement
}
perform(20, function(value) {
console.log(value) // 20
var param = 1;
console.log(param); // 1
@kikill95
kikill95 / timer.js
Last active October 17, 2019 20:25
This is a module (short version) for gathering timers
// full version (with functions for cluster) can be found here:
// https://github.com/kikill95/profiler-demo/blob/master/timer.js
/*
** Example of usage (more samples there - https://github.com/kikill95/profiler-demo)
...
timer.time('metrics', 'wrapper')
...
timer.timeEnd('metrics', 'wrapper')
@kikill95
kikill95 / oop.js
Last active October 17, 2019 19:28
Short about OOP in JS
function Animal() {
}
Animal.prototype.drink = function() {
console.info('drink!');
};
function Cat(shortName, longName) {
this.longName = longName;
@kikill95
kikill95 / capture.html
Created June 12, 2018 13:49
Capture thumbnail on client side and prepare file to upload
<!DOCTYPE html>
<head>
<script type='text/javascript'>
window.onload = function () {
var video = document.getElementById('videoId')
var canvas = document.getElementById('canvasId')
canvas.style.display = 'block'
// fake loading
setTimeout(() => {
// start when video loaded
@kikill95
kikill95 / ExcelToJsDate.js
Last active April 25, 2018 14:18 — forked from christopherscott/ExcelToJsDate.js
Convert Excel date values to JavaScript date objects
// Convert Excel dates into JS date objects
//
// @param excelDate {Number}
// @return {Date}
function getJsDateFromExcel(excelDate) {
// JavaScript dates can be constructed by passing milliseconds
// since the Unix epoch (January 1, 1970) example: new Date(12312512312);
@kikill95
kikill95 / index.vr.js
Last active December 3, 2017 22:05
Example of ReactVR usage
import React from 'react'
import Location from 'Location'
import {
AppRegistry,
asset,
Pano,
View,
VrButton,
Model,
Sound,
@kikill95
kikill95 / client.js
Created December 3, 2017 21:31
Example of simple-raycaster usage
import {VRInstance} from 'react-vr-web'
import * as SimpleRaycaster from 'simple-raycaster'
function init (bundle, parent, options) {
const vr = new VRInstance(bundle, 'gdg_reactvr', parent, {
raycasters: [
SimpleRaycaster // Add SimpleRaycaster to the options
],
cursorVisibility: 'visible', // Add cursorVisibility
...options