Skip to content

Instantly share code, notes, and snippets.

/**
* detect IE
*
*/
detectIE = () =>
/MSIE|Trident|Edge/.test(window.navigator.userAgent);
@gapurov
gapurov / parseDateDINToISO.js
Last active May 22, 2019 08:11
parseDateDINToISO
parseDateDINToISO = str => {
if (/^(\d{4})-(\d{1,2})-(\d{1,2})$/.test(str)) return str;
const m = str.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/);
// return m ? new Date(m[3], m[2] - 1, m[1]) : undefined;
return m ? `${m[3]}-${m[2]}-${m[1]}` : undefined;
};
@gapurov
gapurov / node-and-npm-in-30-seconds.sh
Created December 25, 2018 16:34 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@gapurov
gapurov / file-with-video.html
Last active December 9, 2018 22:16
Lazy Loading Video iFrame from Youtube https://glitch.com/edit/#!/12-pepelsbey
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Как вставить двадцать видео с Ютуба</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="page">
<div class="video">
<a class="video__link" href="https://youtu.be/neHA4MJwpnY">
@gapurov
gapurov / beep-workaroud.md
Last active March 23, 2021 13:44
Workaround for the Annoying Shortcut Beep Sound in VSCODE on MacOSX

The workaround given in the upstream Chromium issue is to setup key bindings at the OS-level that are just noops.

$ mkdir -p ~/Library/KeyBindings
$ cat > ~/Library/KeyBindings/DefaultKeyBinding.dict <<EOF
{
  "^@\UF701" = "noop";
  "^@\UF702" = "noop";
  "^@\UF703" = "noop";
}
@gapurov
gapurov / compose.js
Created November 27, 2018 16:27 — forked from WaldoJeffers/compose.js
JavaScript one-line compose (ES6)
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)))
// Usage : compose functions right to left
// compose(minus8, add10, multiply10)(4) === 42
//
// The resulting function can accept as many arguments as the first function does
// compose(add2, multiply)(4, 10) === 42
@gapurov
gapurov / .eslintrc.json
Last active December 10, 2018 13:19
eslint + prettier config react
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
@gapurov
gapurov / refresh_css_v2.js
Created November 15, 2018 00:42
refresh css v2 bookmarklet by Lea Verou
// http://lea.verou.me/2018/09/refresh-css-bookmarklet-v2/
{
let $$ = (selector, root = document) => Array.from(root.querySelectorAll(selector));
let refresh = (document) => {
for (let link of $$("link[rel=stylesheet][href]", document)) {
let href = new URL(link.href);
href.searchParams.set("forceReload", Date.now());
link.href = href;
}
@gapurov
gapurov / refresh_css_v2.js
Created November 15, 2018 00:42
refresh css v2 bookmarklet by Lea Verou
{
let $$ = (selector, root = document) => Array.from(root.querySelectorAll(selector));
let refresh = (document) => {
for (let link of $$("link[rel=stylesheet][href]", document)) {
let href = new URL(link.href);
href.searchParams.set("forceReload", Date.now());
link.href = href;
}
@gapurov
gapurov / gist:3ee72d1949b065aeadd11c294da9a148
Created November 14, 2018 15:41
git clone all remote branches locally
#!/bin/bash
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done