Skip to content

Instantly share code, notes, and snippets.

@Kreozot
Kreozot / README.md
Last active August 29, 2015 14:21
Adds the function to an object that returns a parameter value or a default value (in case of parameter is missing in object)

Adds the function to an object that returns a parameter value or a default value (in case of parameter is missing in object)

Use cases:

  • Options backward compatability
  • Local and global parameters (global as defaults)
  • Getting missing localization strings

Example:

	var obj = {
/**
* Создание бэкапа Битрикса
*
* Требуется файл secret.json, в котором будут храниться данные пользователя Битрикса и URL локального проекта:
* {
* "bitrix": {
* "username": "v.pupkin",
* "password": "mySecretPassword"
* },
* "localUrl": "http://mysite.local/"
@Kreozot
Kreozot / index.js
Created September 9, 2015 07:26 — forked from mogelbrod/index.js
Simple apply-loader module for webpack
var loaderUtils = require('loader-utils');
module.exports = function(source) {
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
var args = [];
// apply?config=key => sourceFn(require('webpack.config').key)
if (typeof query.config === 'string') {
if (!query.config in this.options)
@Kreozot
Kreozot / index.html
Last active October 28, 2015 08:30
Polymaps / Andrew Mager
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tipsy/1.0.2/jquery.tipsy.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/polymaps/2.2.0/polymaps.js"></script>
<style type="text/css">
@import url("https://cdnjs.cloudflare.com/ajax/libs/jquery.tipsy/1.0.2/jquery.tipsy.css");
@import url("http://github.com/simplegeo/polymaps/raw/v2.2.0/examples/example.css");
const TRACKS_SELECTOR = 'div.d-track__overflowable-column > div.d-track__overflowable-wrapper.deco-typo-secondary.block-layout';
const TRACK_NAME_SELECTOR = '.d-track__title';
const TRACK_VERSION_SELECTOR = '.d-track__version';
const TRACK_ARTISTS_SELECTOR = '.d-track__artists > a';
const trackElements = document.querySelectorAll(TRACKS_SELECTOR);
const tracks = [];
trackElements.forEach((trackElement) => {
const name = trackElement.querySelector(TRACK_NAME_SELECTOR).innerHTML.trim();
const version = trackElement.querySelector(TRACK_VERSION_SELECTOR)?.innerHTML.trim();
const SEARCH_INPUT_SELECTOR = 'div[role="search"] input[role="searchbox"]';
const ADD_BUTTON_SELECTOR = 'div[role="presentation"] > div[role="row"] button[aria-label="Add to Playlist"]';
const input = document.querySelector(SEARCH_INPUT_SELECTOR);
const tracks = ['test'];
const wait = async (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
const findTracks = async (track) => {
const taskIdRegex = /([A-Z]+-[0-9]+)/;
const contributionRegex = /(pushed to branch|pushed new branch)/;
const SELECT_DATE_INTERVAL = 2000;
const getDateTitle = (date) => {
const month = date.toLocaleString('default', { month: 'short' });
const day = date.getDate();
const year = date.getFullYear();
return `${month} ${day}, ${year}`;