Skip to content

Instantly share code, notes, and snippets.

View SleepWalker's full-sized avatar

Sviatoslav SleepWalker

View GitHub Profile
@SleepWalker
SleepWalker / README.md
Last active May 28, 2024 01:35
swagger-jsdoc with koa2-swagger-ui middleware example

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 December 4, 2023 12:02
tuya-localKey-demo
# 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 December 10, 2018 07:45
unregister service worker
// 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
@SleepWalker
SleepWalker / node-sass-iconfont-importer.js
Created July 23, 2016 12:29
sass-loader: resolve @import as modules
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 October 24, 2015 11:42
Language codes and their translations
{
ar: "عربي", // Арабский
az: "Azərbaycan", // Азербайджанский
be: "Беларускі", // Беларусский
bg: "Български", // Болгарский
bs: "Bosanski", // Боснийский
ca: "Català", // Каталанский
cs: "Čeština", // Чешский
da: "Dansk", // Датский
de: "Deutsch", // Немецкий
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla 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;
@SleepWalker
SleepWalker / flexbox.less
Last active August 29, 2015 14:18 — forked from jayj/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}";
(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") {