Skip to content

Instantly share code, notes, and snippets.

View arturparkhisenko's full-sized avatar
:octocat:
www. www always changes

Artur Parkhisenko arturparkhisenko

:octocat:
www. www always changes
View GitHub Profile
@arturparkhisenko
arturparkhisenko / using-pipe.js
Created September 6, 2016 06:31 — forked from ericelliott/using-pipe.js
Using pipe()
const toSlug = pipe(
split(' '),
map(toLowerCase),
join('-'),
encodeURIComponent
);
console.log(toSlug('JS Cheerleader')); // 'js-cheerleader'
@arturparkhisenko
arturparkhisenko / pipe.js
Created September 6, 2016 06:31 — forked from ericelliott/pipe.js
Pipe
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x);
const fn1 = s => s.toLowerCase();
const fn2 = s => s.split('').reverse().join('');
const fn3 = s => s + '!'
const newFunc = pipe(fn1, fn2, fn3);
const result = newFunc('Time'); // emit!
@arturparkhisenko
arturparkhisenko / composables.js
Created September 6, 2016 06:31 — forked from ericelliott/composables.js
Composable utilities
const curry = fn => (...args) => fn.bind(null, ...args);
const map = curry((fn, arr) => arr.map(fn));
const join = curry((str, arr) => arr.join(str));
const toLowerCase = str => str.toLowerCase();
const split = curry((splitOn, str) => str.split(splitOn));
@arturparkhisenko
arturparkhisenko / mediator_trim.js
Created December 10, 2015 07:49 — forked from addyosmani/mediator_trim.js
Mediator revisited
//trimmed down version of jack lawsons mediator
(function (root) {
// We'll generate guids for class instances for easy referencing later on.
// Subscriber instances will have an id that can be refernced for quick
// lookups.
function guidGenerator() {
var S4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
@arturparkhisenko
arturparkhisenko / preconnect.js
Created November 17, 2015 14:28 — forked from cramforce/preconnect.js
link rel preconnect polyfill
const url = origin + '/amp_preconnect_polyfill?' + Math.random();
const xhr = new XMLHttpRequest();
xhr.open('HEAD', url, true);
xhr.send();
const prefetch = document.createElement('link');
prefetch.setAttribute('rel', 'prefetch');
prefetch.setAttribute('href', url);
document.head.appendChild(prefetch);
@arturparkhisenko
arturparkhisenko / break-word.sass
Created October 18, 2015 17:30 — forked from akella/break-word.sass
Breaking long words
=force-new-lines-for-long-words
-ms-word-break: break-all
word-break: break-all
word-break: break-word
-webkit-hyphens: auto
-moz-hyphens: auto
hyphens: auto
@arturparkhisenko
arturparkhisenko / ri-feature-detection.js
Created October 9, 2015 05:56 — forked from gregwhitworth/ri-feature-detection.js
Responsive images feature detection
(function (window) {
document.addEventListener("DOMContentLoaded", function (e) {
var supports = {
srcset: false,
currentSrc: false,
sizes: false,
picture: false
};
var img = new Image();
@arturparkhisenko
arturparkhisenko / functions.php
Last active September 10, 2015 14:38
wp excerpt lenght limit
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
var inFullScreen = document.fullscreenEnabled || document.fullscreenElement ||
window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled;
if (inFullScreen) {
//do something..
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();