Skip to content

Instantly share code, notes, and snippets.

View dimasch's full-sized avatar

Dmitry Schegolihin dimasch

View GitHub Profile
@renatoccosta
renatoccosta / install-ha-opi5.adoc
Last active November 5, 2024 12:17
Install Home Assistant on OrangePi 5

Installing Home Assistant on OrangePi 5 Board

This tutorial will enable the use of Home Assistant on an OrangePi 5 board with the following characteristics:

  • OrangePi Debian OS

  • OS running on a SDCard

  • Home Assistant Supervised Instalation

The steps are a compilation with few modifications from instructions found over the web. Links are at the end.

@mborodov
mborodov / select-first-ption.js
Created January 14, 2019 06:13
Pre-select first option for Magento 2 options swatcher
if (this.options.jsonConfig.attributes.length > 0) {
var selectswatch = this.element.find('.' + this.options.classes.attributeClass + ' .' + this.options.classes.attributeOptionsWrapper);
$.each(selectswatch, function (index, item) {
var swatchOption = $(item).find('div.swatch-option').first();
if (swatchOption.length && !$(item).find('div.swatch-option').hasClass('selected')) {
swatchOption.trigger('click');
}
});
}
const fetch = require("node-fetch");
const { introspectionQuery } = require("graphql");
const fs = require("fs");
fetch("https://1jzxrj179.lp.gql.zone/graphql", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: introspectionQuery })
})
.then(res => res.json())
@shrop
shrop / curl-loop.sh
Created March 31, 2017 14:12
Script to loop through a text file list of URLs and output the curl -I to a text file
#!/bin/bash
for i in $(cat urls.txt); do
content=$(curl -I -s "{$i}")
echo "URL: $i" >> output.txt
echo "$content" >> output.txt
done
@mborodov
mborodov / magento2-cookies.MD
Last active January 18, 2020 10:33
Magento 2 Cookies

Sample work with Cookie in Magento 2

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cookieManager = $objectManager->get('Magento\Framework\Stdlib\CookieManagerInterface');

// set cookie value
$cookieManager->setPublicCookie('key', 'value');

//get cookie value
@mborodov
mborodov / gevent.js
Created February 2, 2016 07:48
Gevent helper class for jQuery event/gevent library
'use strict'
var GeventCheckout = Class.create({
subscribe: function(action, callback) {
$j.gevent.subscribe($j('body'), action, callback);
},
subscribeArray: function(arrayAction, callback) {
$j.each(arrayAction, function(index, action) {
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@nzajt
nzajt / gist:cfe7c5514ed662adda4b
Last active February 2, 2016 08:35
Magento on osx Mavricks with nginx, php-fmp

#Magento on osx Mavricks with nginx, php-fmp

##Step 1

###Make sure that brew is up to date and installed.

If you do not have home brew installed, go to the link below and install it.

@higuma
higuma / ArrayPermutation.js
Last active September 8, 2023 10:15
JavaScript Array permutation generator
// JavaScript Array permutation generator
// (optimized from CoffeeScript output: see ArrayPermutation.coffee)
(function() {
var generatePermutation = function(perm, pre, post, n) {
var elem, i, rest, len;
if (n > 0)
for (i = 0, len = post.length; i < len; ++i) {
rest = post.slice(0);
elem = rest.splice(i, 1);
generatePermutation(perm, pre.concat(elem), rest, n - 1);
@antonmakarenko
antonmakarenko / translation-magento2x.md
Last active March 21, 2021 21:26
Translation Mechanism in Magento 2.x Platform

Translation Mechanism in Magento 2.x Platform

This article discusses the translation mechanism in Magento 2.x, and contrasts it with that of Magento 1.x. The intended audience is Magento developers who would like to better learn the Magento architecture.

The Magento 2.x source code described here has been available since Magento 2.0.0.0-dev46 release and can be viewed on the GitHub at https://github.com/magento/magento2/commit/0849373d7636cfa17b70b8188bfc36d13ae749c1 or later commits.

Implementation Overview in Magento 1.x

Magento 1.x can present the user interface in different languages without modifying the actual application source code—it translates the system messages, error messages, and labels for display in the UI. Some messages may be displayed in logs for a system administrator or a developer—those don't need to be translated. By convention, in the source code, the labels and system messages for UI are expressed in English (en_US).