Skip to content

Instantly share code, notes, and snippets.

View barbagrigia's full-sized avatar

Vlad Trukhin barbagrigia

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@barbagrigia
barbagrigia / gist:d61d70cf15859a44e3ef34ba77b0c86a
Created June 27, 2017 22:44 — forked from realmyst/gist:1262561
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@barbagrigia
barbagrigia / .spacemacs
Created May 15, 2017 00:03 — forked from practicalli-johnny/.spacemacs
Latest configuration for Spacemacs - 1st August 2016
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
(ns birch.core
(:require [clojure.string :as str]))
;; (println ">>>" (first *command-line-args*))
(def node-fs (js/require "fs"))
(def node-path (js/require "path"))
(def read-dir (.-readdirSync node-fs))
(def stat (.-statSync node-fs))
@barbagrigia
barbagrigia / shadowlisten.js
Created May 12, 2017 21:40 — forked from samthor/shadowlisten.js
Listener to provide up-to-date Shadow DOM focus events
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@barbagrigia
barbagrigia / safari-nomodule.js
Created May 12, 2017 21:40 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
* <script nomodule>alert('no modules');</script>.
*
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
* This allows us to trap the module and nomodule load.
<!doctype html>
<style>
html, body {
margin: 0;
background-color: #CCC;
box-sizing: border-box;
}
.item {
margin: 20px;
padding: 20px;
@barbagrigia
barbagrigia / convert.sh
Created May 12, 2017 21:30 — forked from surma/convert.sh
Convert video to gif
#!/bin/bash
FUZZ="0.0% 0.5% 1.0% 1.5% 2.0% 2.5% 3.0%"
COLORS="128 256"
CONV_OPTS="-resize 450 -layers optimize-plus -layers optimize-transparency"
mkdir output
for f in $FUZZ; do
convert +repage -fuzz $f -delay 4 -loop 0 $@ $CONV_OPTS ./output/im-$f.gif
for c in $COLORS; do
lol1 lol2
lol3 lol4
@barbagrigia
barbagrigia / importPolyfill.js
Created May 12, 2017 21:13 — forked from surma/importPolyfill.js
Polyfill for dynamic module loading
_registry = {};
importPolyfill = path => {
if(!(path in _registry)) {
const entry = _registry[path] = {};
entry.promise = new Promise(resolve => entry.resolve = resolve);
document.head.appendChild(Object.assign(
document.createElement('script'),
{
type: 'module',
innerText: `import * as X from '${path}'; _registry['${path}'].resolve(X);`,