Skip to content

Instantly share code, notes, and snippets.

View SynCap's full-sized avatar

Constantin Losk SynCap

View GitHub Profile
@SynCap
SynCap / input-number-extra-keys.js
Created August 16, 2020 06:15
<INPUT type=number > extra keys
const isMac = navigator.platform === 'MacIntel';
const KEY = {
UP: 38,
DOWN: 40,
};
document.querySelector("input").addEventListener("keydown", e => {
if ([KEY.UP, KEY.DOWN].includes(e.keyCode)) {
e.preventDefault();
@SynCap
SynCap / launch.json
Created July 15, 2020 11:23
Debug Nuxt.JS app with VS Code
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "client: chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
@SynCap
SynCap / setup_push-all_git_alias.sh
Created March 20, 2020 02:15
Push all remote repositories at the same time
git config --global alias.pushall '!f(){ for var in $(git remote show); do echo "pushing to $var"; git push $var; done; }; f'
@SynCap
SynCap / README.MD
Created March 3, 2020 15:22
Nuxt components automatic registration

in nuxt.config:

....

  /*
   ** Plugins to load before mounting the App
   */
  plugins: ['~/plugins/autoloads.js' /*, ... */],
@SynCap
SynCap / README.MD
Last active March 23, 2020 11:55
Vanilla Javascript number padding functions

Disadvantages of String.padStart()

  • works only in modern browsers and environments;
  • don't care about negative
  • works only on String primitives not a Number
> (-4+'').padStart(7,'0')
"00000-4"
@SynCap
SynCap / smart-reset.css
Last active January 15, 2020 16:54
Really smart CSS reset
/* Указываем box sizing */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Убираем внутренние отступы */
ul[class],
ol[class] {
@SynCap
SynCap / common_HTML_HEAD_METAs.pug
Last active March 3, 2019 13:06
Most common HTML HEAD content. PUG version
// most restricted user zoom possibilities
meta(name="viewport", content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=1.0, user-scalable=no")
// iOs safari kick-ass
meta(name="apple-mobile-web-app-capable", content="yes")
meta(name="apple-mobile-web-app-status-bar-style", content="black-translucent")
// detections in mobile Chrome & FF are on by default
// following directives helps to switch them off
// in some desktop browsers (webkit & FF) can be switched on
meta(name="format-detection", content="telephone=yes")
meta(name="format-detection", content="address=yes")
@SynCap
SynCap / common_HTML_HEAD_METAs.html
Last active March 3, 2019 13:06
Most common HEAD content
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=yes">
<meta name="format-detection" content="address=yes">
@SynCap
SynCap / __randomN.js
Created September 22, 2018 14:59
Javascript universal random function (ES6+ !!!)
function __randomN(...args) {
if (Array.isArray(args[0])) return __randomN(args[0]);
function getRandomIntMax(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
@SynCap
SynCap / gg.sh
Last active August 24, 2019 04:44
Shallow clone git repository with automatic README and optional install/start NPM
#!/bin/bash
# Shallow clone the Git repository to specified folder and launch showing
# README files. Optimized to use under Windows
#
# Optionally:
# - Deep clone
# - install NPM depedancy with NPM or Yarn
# - launch `start` script from `package.json`
#