Skip to content

Instantly share code, notes, and snippets.

View rasy-js's full-sized avatar

Rasy rasy-js

  • Minsk
View GitHub Profile
@rasy-js
rasy-js / .jshintrc
Created March 4, 2018 10:00
jshint es6
{
"esversion": 6,
"node": true
}
@rasy-js
rasy-js / getNextWeekday.js
Created November 9, 2017 11:44
get next day, except holiday
var getNextWeekday = (function() {
var holidays = ['1/1', '7/1', '4/2', '23/2', '8/3', '1/4', '9/4'];
function checkHoliday(date) {
date.setDate(date.getDate() + 1);
var day = date.getDay();
if(day === 0 || day === 6 || holidays.indexOf(date.getDate() + '/' + (date.getMonth() + 1)) !== -1) {
@rasy-js
rasy-js / playing_youtube.html
Last active November 3, 2017 20:30
Video playback on the site on a schedule
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Воспроизведение видео на сайте по расписанию</title>
</head>
<body>
<div id="player"></div>
<div>
<button type="button" id="start">start</button>
@rasy-js
rasy-js / receptRemoveChildOptions.js
Created June 15, 2017 11:49
removeChildOptions
function removeOptionExeptFirstAndCurrent(e) {
var select = e.target;
var selected_value = options[options.selectedIndex].value;
while(select.children[1]) {
if (select.childElementCount == 2) break;
if (select.children[1].value == selected_value) {
select.removeChild(select.children[2]);
continue;
}
@rasy-js
rasy-js / innerjoin.sql
Created May 16, 2017 12:58
inner join many tables
SELECT
`p`.`product_ean`,
`p`.`product_price`,
`v`.`name_ru-RU`,
`p`.`extra_field_2`,
`v1`.`name_ru-RU`,
`v2`.`name_ru-RU`,
`p`.`extra_field_5`,
`p`.`extra_field_6`,
`p`.`extra_field_7`,
@rasy-js
rasy-js / regexp.sql
Created May 9, 2017 17:27
sql query with regexp instead IN and LIKE
SELECT
`w`.worker, `w`.time_with, `w`.time_to, `w`.foreman, `w`.object
FROM `workers_days` AS `w`
WHERE ( `worker` = 'Петров Игорь Васильвевич' )
AND ( `year` = '2017' )
AND ( `month` = '5' )
AND ( `day` = '1' )
AND ( `Пирожков_сорт` REGEXP '^4$|^4.1$' )
@rasy-js
rasy-js / mdlsnackbar.js
Created May 4, 2017 12:37
snackbar clean up
snackbar.MaterialSnackbar.cleanup_();
@rasy-js
rasy-js / ctrl_enter.js
Last active March 2, 2018 13:06
keypress calback (ctrl+enter)
(function() {
var k_a = [];
document.body.addEventListener('keydown', function(e) {
var k = e.keyCode;
// if esc
if (k == 27) {
// some act ...
} else {
@rasy-js
rasy-js / json.php
Created April 9, 2017 15:25
get json from request
<?php $json = json_decode(file_get_contents('php://input')); ?>
@rasy-js
rasy-js / doc.js
Created April 7, 2017 14:46
document implementation
var doc = document.implementation.createHTMLDocument();
doc.documentElement.innerHTML = response;