Skip to content

Instantly share code, notes, and snippets.

View ivan-stepaniuk's full-sized avatar
🏎️
"Working"

Ivan Stepaniuk ivan-stepaniuk

🏎️
"Working"
View GitHub Profile
function makeObservable(target) {
// 1. Initialize handlers store
target[handlers] = [];
// Store the handler function in array for future calls
target.observe = function (handler) {
this[handlers].push(handler);
};
// 2. Create a proxy to handle changes
<?php if (have_posts()): while (have_posts()) : the_post();
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists
$image = get_the_post_thumbnail_url();
endif; ?>
<article id="post-<?php the_ID(); ?>" class="project_item" style="background-image: url(<?php echo $image; ?>)">
<a href="<?php the_permalink(); ?>">
<div class="project_item_info_wrapper">
<div class="project_item_info">
var getall = function () {
var objectlist = canvas.getObjects();
var tablelist = '<table><tr><th>Name</th><th>ID</th><th>src</th></tr>'
objectlist.forEach(function (element) {
console.log(element);
tablelist += '<tr><td>';
if (element.type != 'rect' & element.type != 'circle' & element.type != 'text')
tablelist += element._element.name;
else
tablelist += element.type;
// 1
function arrayWithRanges(array) {
if (!array || !Array.isArray(array)) return;
let num = [...array];
let k = 0;
let lastElement = num.length - 1;
for (var i = lastElement; i >= 0; i--) {
if (num[i] == num[i - 1] + 1) {
@ivan-stepaniuk
ivan-stepaniuk / gist:3f5b979a34cbe94f53e280a1c1cee9b4
Created January 8, 2018 09:07
Wrapping an element in Vanilla JavaScript
function wrap(top, selector, bottom){
var matches = document.querySelectorAll(selector);
for (var i = 0; i < matches.length; i++){
var modified = top + matches[i].outerHTML + bottom;
matches[i].outerHTML = modified;
}
}
wrap("<div class='wrapper'>", ".getWrapped", "</div>");
@ivan-stepaniuk
ivan-stepaniuk / gist:8595b5a36e4c581203dac86cd7cc49aa
Created January 8, 2018 09:07
Wrapping an element in Vanilla JavaScript
function wrap(top, selector, bottom){
var matches = document.querySelectorAll(selector);
for (var i = 0; i < matches.length; i++){
var modified = top + matches[i].outerHTML + bottom;
matches[i].outerHTML = modified;
}
}
wrap("<div class='wrapper'>", ".getWrapped", "</div>");