Skip to content

Instantly share code, notes, and snippets.

View retina-media-query.css
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-resolution: 144dpi) { ... }
@monochromer
monochromer / sync-gh-pages.sh
Last active Mar 8, 2016
Работа с веткой gh-pages
View sync-gh-pages.sh
/* Синхронизация */
git checkout gh-pages
git rebase master
git push origin gh-pages
git checkout master
/* Deploy из папки dist */
git subtree push --prefix dist origin gh-pages
@monochromer
monochromer / package.json
Created Mar 8, 2016
npm-tasks-boilerplate
View package.json
{
"name": "npm-tasks-boilerplate",
"version": "0.0.1",
"description": "",
"author": "Monochromer <monochromer@mail.ru>",
"scripts": {
"clean": "rm -rf build/",
"server": "browser-sync start --server \"build\" --files 'build/**/*.*' --directory",
"stylus": "stylus src/styles/main.styl -o build/css --include-css",
"prefix": "postcss -u autoprefixer --autoprefixer.browsers \"> 1%\" -r build/css/*",
View closest-polyfill.js
;(function(Element) {
// matches polyfill
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matchesSelector ||
Element.prototype.webkitMatchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
function matches(selector) {
@monochromer
monochromer / decouple.js
Last active Feb 26, 2017
decouple event. Способ работы обработчиков событий через requestAnimationFrame
View decouple.js
// https://github.com/pazguille/decouple/
// Decouple the DOM events from expensive functions.
// https://www.html5rocks.com/en/tutorials/speed/animations
function decouple(node, event, fn) {
var eventData,
tracking = false;
function captureEvent(e) {
eventData = e;
@monochromer
monochromer / namespace-module.js
Last active Jul 17, 2016
Создание js-модуля с пространством имен
View namespace-module.js
;(function(global, utils) {
utils.namespace = function(namespace, closure) {
closure.call(
null,
namespace
.split('.')
.reduce(
function(parent, current, index, keys) {
if(!parent.hasOwnProperty(current)) parent[current] = {};
@monochromer
monochromer / transparent-image.txt
Last active Mar 10, 2017
base64 1px png anf gif
View transparent-image.txt
png
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=
gif
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
@monochromer
monochromer / fontfaceset.js
Last active Jul 31, 2018
загрузка шрифтов через FontFaceObserver.
View fontfaceset.js
let fontFace = new FontFace("MyWebFont", "url('MyWebFont.woff2') format('woff2'), url('MyWebFont.woff') format('woff')");
fontFace.load().then(function(loadedFontFace) {
document.fonts.add(loadedFontFace);
document.getElementById("target").style.fontFamily = "MyWebFont";
});
@monochromer
monochromer / status-drop-down.js
Created Jun 20, 2016
Выпадающий список со статусами
View status-drop-down.js
// выпадающий список со статусами
UI.commonFuncs.statusSelect = function () {
var selectSelector = 'select.select-status';
var $selects = $(selectSelector);
console.log($selects);
if (!$selects.length) return;
var template = [
@monochromer
monochromer / borrow.js
Last active Jul 11, 2016
Заимствование методов в JavaScript
View borrow.js
var slice = Function
.prototype
.call
.bind(Array.prototype.slice);
var args = slice(arguments);
// Пример
// http://davidshariff.com/blog/borrowing-methods-in-javascript/
You can’t perform that action at this time.