Skip to content

Instantly share code, notes, and snippets.

@pongo
pongo / _breakpoints.less
Created July 23, 2017 18:41
Bootstrap v4 media queries mixins converted to Less via less-plugin-sass2less
// Breakpoint viewport sizes and media queries.
//
// Breakpoints are defined as a map of (name: minimum width), order from small to large:
//
// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)
//
// The map defined in the `@grid-breakpoints` global variable is used as the `@breakpoints` argument by default.
// Name of the next breakpoint, or null for the last breakpoint.
//
@pongo
pongo / webp-and-no-js.js
Last active August 17, 2017 02:18
Replace ".no-js" with ".js". Checks webp support and adds ".no-webp" or ".webp"
(function(document) {
'use strict';
// replace .no-js with .js
var html = document.documentElement;
html.className = html.className.replace(/(^|\\s)no-js(\\s|$)/, '$1js$2');
// webp support
var image = new Image();
image.onload = image.onerror = function() {
@pongo
pongo / .htaccess
Last active March 5, 2020 07:49
serves a .webp image instead of jpg/png
<IfModule mod_rewrite.c>
RewriteEngine On
# serves a .webp image instead of jpg/png
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} ^(.+)\.(jpe?g|png)$
RewriteCond %1\.webp -f
RewriteRule ^(.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
var OpenStatParser={_params:{},_parsed:!1,_decode64:function(r){if("function"==typeof window.atob)return atob(r);var t,a,e,n,i,s,o,h,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=0,f=0,u="",c=[];if(!r)return r;r+="";do n=d.indexOf(r.charAt(p++)),i=d.indexOf(r.charAt(p++)),s=d.indexOf(r.charAt(p++)),o=d.indexOf(r.charAt(p++)),h=n<<18|i<<12|s<<6|o,t=h>>16&255,a=h>>8&255,e=255&h,64==s?c[f++]=String.fromCharCode(t):64==o?c[f++]=String.fromCharCode(t,a):c[f++]=String.fromCharCode(t,a,e);while(p<r.length);return u=c.join("")},_parse:function(){var r=window.location.search.substr(1),t=r.split("&");this._params={};for(var a=0;a<t.length;a++){var e=t[a].split("=");this._params[e[0]]=e[1]}this._parsed=!0},hasMarker:function(){return this._parsed||this._parse(),"undefined"!=typeof this._params._openstat},buildCampaignParams:function(){if(!this.hasMarker())return!1;var r=this._decode64(this._params._openstat),t=r.split(";");return{utmcampaign:t[1],utmsource:t[0],utmcontent:t[2]}}};
if (OpenStat
@pongo
pongo / free.md
Last active August 18, 2022 08:13
Сервисы email-рассылок

На этих сервисах есть бесплатные тарифы

Можно в их редакторах придумать внешний вид письма и затем скопировать html. А так же и вовсе делать через них большие рассылки.

@pongo
pongo / index.md
Last active August 18, 2022 08:19
Обрабатывать ошибки бд
// ==UserScript==
// @name ozon.ru - для таблицы книжкой полки
// @namespace http://tampermonkey.net/
// @version 0.1
// @match https://www.ozon.ru/context/detail/id/*
// @grant GM_setClipboard
// @grant unsafeWindow
// ==/UserScript==
function trim(s) {
@pongo
pongo / README.md
Last active July 3, 2018 22:17
Загружаем babel-polyfill только для старых браузеров на примере vue.js

Загружаем babel-polyfill только для старых браузеров на примере vue.js

1. Используем polyfill.io

Это сервис, который на основании юзер-агента определяет какие полифиллы нужно загружать.

Попросту в index.html добавляем:

<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6"></script>
@pongo
pongo / index.ts
Created November 22, 2018 21:48
Получает типы из строковых констант
// models
const CREATE_ENTITY = 'CREATE_ENTITY'
const UPDATE_ENTITY = 'UPDATE_ENTITY'
type TEntityActionTypes = typeof CREATE_ENTITY | typeof UPDATE_ENTITY
type TCreateAction = {
type: typeof CREATE_ENTITY,
payload: string
}
@pongo
pongo / livereload-parcel-css.md
Created July 15, 2019 14:25
Liveload (hotreload) css for parcel with live-server

If you want to reload after file changes, you can run Parcel in watch mode, which compiles changes to another directory (default ./dist/) but does not run a server.

parcel watch index.html --no-hmr

Then run a live-server, which listens to file changes and reloads (assuming your output is to the ./dist/ directory)

live-server ./dist/

Here's what my npm start script looks like: