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 / 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
const prefetch = document.createElement('link');
prefetch.setAttribute('rel', 'prefetch');
prefetch.setAttribute('href', url);
document.head.appendChild(prefetch);
@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();
@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 / 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 / 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 / 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 / README.md
Created September 27, 2016 16:09 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@arturparkhisenko
arturparkhisenko / .profile
Created November 4, 2016 19:01 — forked from sindresorhus/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@arturparkhisenko
arturparkhisenko / cors.js
Created February 27, 2019 16:19 — forked from balupton/cors.js
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);