Skip to content

Instantly share code, notes, and snippets.

View dkrnl's full-sized avatar

Dmitri Pyatkov dkrnl

View GitHub Profile
U+0000
U+0002
U+000D
U+0020
U+0021
U+0022
U+0023
U+0024
U+0025
U+0026
@znechai
znechai / pluralize-ru.js
Last active April 26, 2025 16:57
JavaScript - Plural forms for russian words
/**
* Plural forms for russian words
* @param {Integer} count quantity for word
* @param {Array} words Array of words. Example: ['депутат', 'депутата', 'депутатов'], ['коментарий', 'коментария', 'комментариев']
* @return {String} Count + plural form for word
*/
function pluralize(count, words) {
var cases = [2, 0, 1, 1, 1, 2];
return count + ' ' + words[ (count % 100 > 4 && count % 100 < 20) ? 2 : cases[ Math.min(count % 10, 5)] ];
}
@wochap
wochap / main.js
Last active March 3, 2019 13:11
Webpack for create emails
// require('./email.scss')
const css = require('!!raw-loader!inline-style!sass!./email.scss')
// const template = require('ejs-compiled!./emails/contact.ejs')
// const template = require('ejs-compiled!./emails/a-customer.ejs')
const template = require('ejs-compiled!./emails/l-customer.ejs')
function getStyles (...selectors) {
return selectors.reduce((styles, selector) => {
if (!css[selector]) {
console.warn(`The '${selector}' selector doesn't exist.`)
@niieani
niieani / throttle-and-debounce.sh
Last active September 21, 2024 21:50
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@minazou67
minazou67 / howto-upgrade-debian-jessie-kernel.md
Last active August 13, 2019 18:13
How to upgrade the Linux Kernel of debian 8 jessie

How to upgrade the Linux Kernel of debian 8 jessie

Debian 8 のカーネルをアップグレードする方法です。

Environment

  • Microsoft Windows Server 2012 R2
  • Hyper-V
  • Debian 8.2 jessie
@iAdramelk
iAdramelk / .md
Last active December 2, 2024 14:50
Длинная телега про Бутстрап

Английская версия: https://evilmartians.com/chronicles/bootstrap-an-intervention

Вводная часть

У CSS есть несколько базовых проблем, которые позволяют очень быстро отстрелить себе ногу при неправильном использовании:

  1. Глобальный неймспейс – в серверном программировании все что написано в файле, в файле и остается. Все же что написано в css и js засирает глобальное пространство имен со всеми вытекающими. В JS эту проблему сейчас побороли всякими модульными системами, а вот с css сложнее. В идеальном мире это должен починить Shadow DOM и настоящие Web Components, но пока их нет единственный способ с этим бороться – следовать какой-то системе именований селекторов, которая по возможности уменьшает и исключает возможные конфликты.

  2. Каскадность – если на один элемент может сработать несколько правил, то они все и сработают последовательно. Если есть элемент h1.title, на него сработают все правила для тегов h1 и все правила для класса .title. Так как весь html состоит из тегов, то правил которые п

@paulirish
paulirish / what-forces-layout.md
Last active May 16, 2025 17:21
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 28, 2025 12:59
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@adriancmiranda
adriancmiranda / browserify-shim.json
Last active January 17, 2019 19:05
RequireJS + Greensock
{
"name": "ambox",
"description": "Ambox generator",
"version": "0.0.0",
"main": "source/scripts/boot.js",
"devDependencies": {
"browserify": "latest",
"browserify-shim": "latest",
"connect-livereload": "latest",
"deamdify": "latest",