Skip to content

Instantly share code, notes, and snippets.

@bekapod
bekapod / machine.js
Last active February 27, 2020 13:58
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@bekapod
bekapod / toggleDir.js
Created February 28, 2017 09:58
Toggle LTR/RTL dir
if (document.querySelector('html').getAttribute('dir') == 'rtl') {
document.querySelector('html').setAttribute('dir', 'ltr');
} else {
document.querySelector('html').setAttribute('dir', 'rtl');
}
@bekapod
bekapod / style.css
Created January 20, 2017 09:29
Fluid font sizing
body {
font-size: calc(1em + 1vw);
}
@bekapod
bekapod / script.js
Created November 28, 2016 11:29
JS: returning functions
function setup() {
var count = 0;
return function() {
return ++count;
};
}
var next = setup();
next(); // 1
@bekapod
bekapod / style.css
Created November 16, 2016 16:27
CSS: Masonry Grid
.masonry-grid {
column-count: 1;
column-gap: 0;
column-fill: auto;
@media (min-width: 768px) {
column-count: 3;
}
}
@bekapod
bekapod / style.css
Created November 16, 2016 16:27
CSS: Flex Grid
.flex-grid {
clear: both;
display: flex;
flex-wrap: wrap;
&-item {
display: flex;
}
.panel {
@bekapod
bekapod / style.css
Created March 1, 2016 11:03
CSS: Better global box-sizing
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@bekapod
bekapod / script.js
Created October 26, 2015 14:40
JQUERY: detach
/* Title: detach
* Description: take element off the DOM while manipulating them
*/
var table = $('#some-table');
var parent = table.parent();
table.detach();
table.addLotsAndLotsOfRows();
parent.append(table);
@bekapod
bekapod / index.html
Created October 15, 2014 09:52
MAGENTO: Include static block on another static block / cms page
{{block type="cms/block" block_id="your_block_id"}}
@bekapod
bekapod / script.js
Last active November 28, 2016 11:03
JS: Replace URL Parameter
function replaceUrlParam(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"),
separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
} else {
return uri + separator + key + "=" + value;
}
}