Skip to content

Instantly share code, notes, and snippets.

Avatar

Sviatoslav SleepWalker

View GitHub Profile
@SleepWalker
SleepWalker / README.md
Last active Aug 5, 2020
swagger-jsdoc with koa2-swagger-ui middleware example
View README.md

This is an example how to setup swagger docs api endpoint for your koa app.

Usage

const Koa = require('koa');
const path = require('path');
const http = require('http');

const swagger = require('./swagger');
@SleepWalker
SleepWalker / .editorconfig
Last active Jun 24, 2020
tuya-localKey-demo
View .editorconfig
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@SleepWalker
SleepWalker / unregisterServiceWorkers.js
Last active Dec 10, 2018
unregister service worker
View unregisterServiceWorkers.js
// browser way
navigator.serviceWorker.getRegistrations().then(registrations => {
for (const registration of registrations) {
registration
.unregister()
.then(boolean => {
console.log(
boolean ? 'Successfully unregistered' : 'Failed to unregister',
`ServiceWorkerRegistration\n${
registration.installing
View message.md

Hello,

I've received your product. The delivery was really fast!

But it looks like something wrong with the earphones. The sound is good, but after ~5mins of usage the earphones starting to lose the signal. One after another. So frequently, that it is impossible to use them at all.

In the description is written, that it should work on standard for bluetooth distance of 10m. But in my case the distance was less than 50cm and there was already issues with connection.

I've tested earphones with my phone (bluetooth 5.0) and laptop (bluetooth 2.1). In both cases I experiencing the same problems.

View node-sass-iconfont-importer.js
var loaderUtils = require("loader-utils");
module.exports = function createImporter(options) {
return function(url, fileContext, done) {
if (options.test.test(url)) {
var request = loaderUtils.urlToRequest(url);
loaderContext.loadModule(request, function(err, source) {
if (err) return done(new Error(err));
@SleepWalker
SleepWalker / gist:08e26f5e53fb2e1d5ea8
Created Oct 24, 2015
Language codes and their translations
View gist:08e26f5e53fb2e1d5ea8
{
ar: "عربي", // Арабский
az: "Azərbaycan", // Азербайджанский
be: "Беларускі", // Беларусский
bg: "Български", // Болгарский
bs: "Bosanski", // Боснийский
ca: "Català", // Каталанский
cs: "Čeština", // Чешский
da: "Dansk", // Датский
de: "Deutsch", // Немецкий
@SleepWalker
SleepWalker / swipe.js
Created Sep 30, 2015
A simple swipe detection on vanilla js
View swipe.js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
View flexbox.less
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-moz-@{display}";
View jquery.ajax.progress.js
(function addXhrProgressEvent($) {
// Patch for progress event support
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: $.noop,
xhr: function() {
var xhr = originalXhr(), that = this;
if (xhr) {
if (typeof xhr.addEventListener == "function") {
You can’t perform that action at this time.