Skip to content

Instantly share code, notes, and snippets.

View zivce's full-sized avatar
🕹️
Focusing

Милош Живковић zivce

🕹️
Focusing
View GitHub Profile
@zivce
zivce / remove-wishlist-products.js
Created April 17, 2020 08:26
Removing products from wishlist. A lot of if blocks, hard to follow paths.
static removeProductFromWishListHandler(e) {
e.stopPropagation();
const target = $(e.currentTarget);
const $wishlistList = $(".wishlist-list__body");
const productCode = target.data("product-code");
const $myFavouritesRollover = $(".mini-favourites");
const $myFavouritesSendList = $(".wishlist-send-list");
const emptyWishlistHTML = $("#emptyWishlistPopupTemplate").html();
const $myFavouritesRolloverContainer = $(
@zivce
zivce / remove-wishlist-products-refactored.js
Last active April 19, 2020 10:46
Extracted logic to strategies. Possible re-use. Easier to follow paths.
static $wishlistList = $(".wishlist-list__body");
static $myFavouritesRollover = $(".mini-favourites");
static $myFavouritesSendList = $(".wishlist-send-list");
static emptyWishlistHTML = $("#emptyWishlistPopupTemplate").html();
static $wishlistCount = $("[data-wishlist-item-count]");
static $myFavouritesRolloverContainer = $(
".my-favourites-rollover__content",
$myFavouritesRollover
);
@zivce
zivce / remove-wishlist-products-strategy.js
Last active April 19, 2020 11:14
Added strategy factory.
export class Strategy {
constructor(name, handler) {
this._name = name;
this._handler = handler;
}
execute() {
this._handler();
}
}
@zivce
zivce / test.js
Created May 26, 2020 16:11
Simple test for resolving csv
let assert = require('assert')
let CSVImageDownloader = require("./index");
const fs = require('fs');
const path = require('path')
describe("CSV Image Downloader", function () {
const VALID_FILE = 'data.csv'
const INVALID_FILE = 'data2.csv'
const VALID_COLUMN = 'IMAGE'
let columnValues = []
@zivce
zivce / scrape-police.js
Created June 7, 2020 08:35
Scraping for police info on local FB page
const puppeteer = require('puppeteer');
const dotenv = require('dotenv');
dotenv.config();
const WAIT_FOR_PAGE = 5000;
const DELAY_USER_INPUT = 2000;
const DELAY_PW_INPUT = 1000;
(async () => {
final List<String> categories = source.getCategories().stream()
.map(category -> {
return getIDService().getItem(category).map(item -> {
return item.getId();
}).get();
}).collect(Collectors.toList());
final List<String> categories = source.getCategories().stream()
.map(getUniqueItemIdentifierService()::getItemData)
.filter(Optional::isPresent)
.map(Optional::get)
.map(ItemData::getItemId)
.collect(Collectors.toList());
return Optional.ofNullable(discounts)
.map(Collection::stream)
.orElseGet(Stream::empty)
.map(DiscountValue::getAppliedValue)
.reduce(itemPrice, (price, discount) -> price - discount);
final Map<String, String> map = Optional.ofNullable(target.getMap())
.orElseGet(() -> getNewMap(target));