Skip to content

Instantly share code, notes, and snippets.

View peacefulseeker's full-sized avatar

Alexey Vorobyov peacefulseeker

  • Riga
View GitHub Profile
@peacefulseeker
peacefulseeker / tilda-output-only-related-cards.js
Last active July 18, 2021 06:41
MadeOntilda Search cards
@peacefulseeker
peacefulseeker / calculatePrices.js
Last active April 8, 2019 17:31
Calculate minimum and maximum expected total cart price on AliExpress my wishes page
//https://my.aliexpress.com/wishlist/wish_list_product_list.htm?&currentGroupId=0&page=1
const priceNodes = document.querySelectorAll('.price');
const pricesCollection = Array.from(priceNodes);
var prices = pricesCollection.reduce((total, prc) => {
const prices = prc.textContent.trim().replace(/[^\d,-]/g, '').replace(/,/g, '.').split('-');
const lowestPrice = Number(prices[0]);
const highestPrice = Number(prices[1]) || lowestPrice;
@peacefulseeker
peacefulseeker / launch.json
Last active January 27, 2019 10:43
BackEnd and FrontEnd Debug config for VSCode
{
"configurations": [
{"source": "https://github.com/Microsoft/vscode-recipes/tree/master/nodemon"},
{
"debug": "nodemon -e --inspect-brk js,graphql -x node src/index.js"
},
{
"type": "node",
"request": "attach",
"name": "BackEnd - Nodemon Debug",
@peacefulseeker
peacefulseeker / Random-string
Created January 5, 2019 15:16 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@peacefulseeker
peacefulseeker / listAllEventListeners.js
Created November 8, 2018 11:07 — forked from dmnsgn/listAllEventListeners.js
List all event listeners in a document
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@peacefulseeker
peacefulseeker / mq2x.css
Created February 15, 2018 08:02
CSS: Media Query to target retina devices.
@media only screen and (min-resolution: 2dppx), (min-resolution: 192dpi) {
background-image: url('/assets/build/img/sprite-2x.png');
}
@peacefulseeker
peacefulseeker / debounce.js
Last active February 17, 2018 15:38
JavaScript Debounce Function
//source: https://remysharp.com/2010/07/21/throttling-function-calls
/* Let us work on performance issues while making resource-intensive things */
/* Will wait until event is not stopped and wait param is finished, then the callback will be fired */
function _debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
@peacefulseeker
peacefulseeker / throttle.js
Last active February 17, 2018 15:38
JavaScript Throttle Function
//source: https://remysharp.com/2010/07/21/throttling-function-calls
/* Let us work on performance issues while making resource-intensive things */
/* Will wait every `limit` miliseconds until the callback is executed */
function _throttle(fn, threshold, scope) {
threshold || (threshold = 250);
var last,
deferTimer;
return function () {
var context = scope || this;
@peacefulseeker
peacefulseeker / historyRelaceState.js
Last active January 24, 2018 08:52
History Replace State. Append smth to url without refreshing
var query = '?param=param';
window.history.replaceState(null, null, location.pathname + query);
@peacefulseeker
peacefulseeker / getUrlParameter.js
Last active January 23, 2018 14:15
getUrlParameter
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];