Skip to content

Instantly share code, notes, and snippets.

View dimasch's full-sized avatar

Dmitry Schegolihin dimasch

View GitHub Profile
@jgoodall
jgoodall / README.md
Last active September 19, 2023 18:06
This is a sample of how to send some information to logstash via the TCP input from node.js or python.

This is a sample of how to send some information to logstash via the TCP input in nodejs or python. It assumes the logstash host is on 10.10.10.100 and the TCP listening input is 9563.

The logstash.conf should look something like the sample file.

The log message should be a stringified JSON object with the log message in the @message field.

To use, run the node script node sendMessageToLogstash.js, or the python script python sendMessageToLogstash.js

@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).

@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);
@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.

@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
@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) {
@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
@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
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())
@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');
}
});
}