Skip to content

Instantly share code, notes, and snippets.

View YaroslavShapoval's full-sized avatar

Yaroslav Shapoval YaroslavShapoval

  • Moldova, Tiraspol
View GitHub Profile
du -h --max-depth=1 ./ | sort -h -r
const ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const N = 9;
const LIST = new Array(N).fill(undefined);
const RESPONSES = [6,4,0,4,0,0,2,1,0];
for (let i = 0; i < N; i++) {
let cur_index = -1;
let free_place_index = 0;
const START = 1;
const LENGTH = 990;
const ONE_COUNTS = 261;
let cur_length = 0;
let cur_number = 0;
let one_occurences = 0;
// while (cur_length < LENGTH) {
while (one_occurences < ONE_COUNTS) {
const ways = {
// number: 10 => steps: [A, B, C, A, B, C]
};
const START = 3;
const FINISH = 22;
let minWayToFinish = undefined;
function check(number, steps = []) {
@YaroslavShapoval
YaroslavShapoval / Slider.js
Created June 7, 2020 12:20
Pure js slider class (work in progress - swipes don't work)
import { throttle } from "lodash";
export default class Slider {
/** @type { HTMLElement } */
#parentNode;
/** @type { HTMLElement } */
#trackNode;
/** @type { HTMLElement[] } */
@YaroslavShapoval
YaroslavShapoval / random_highcharts_data.php
Created September 8, 2016 07:01
Generate random data for highcharts
<?php
$begin = new Datetime();
$begin->modify('first day of this month');
$begin->setTime(0,0,0);
$end = new Datetime();
$end->modify('last day of this month');
$end->setTime(23,59,59);
@YaroslavShapoval
YaroslavShapoval / getting_last_month_day.php
Created September 8, 2016 07:00
Getting first and last days for week, month, year
<?php
function getFirstWeekDayDatetime($datetime) {
return $datetime->modify('+ 1 day')->modify('last monday');
}
function getLastWeekDayDatetime($datetime) {
return $datetime->modify('- 1 day')->modify('next sunday');
}
#/bin/bash
rm -f "/backups/sitename-`date -d "-5 days" --iso`.tar.gz"
mysqldump -u username -ppassword www>db.sql
tar -cvzf "/backups/sitename-`date --iso`.tar.gz" db.sql /var/www/sitefolder --exclude "/var/www/sitefolder/exclude_files"
@YaroslavShapoval
YaroslavShapoval / ubuntu-idea-launcher
Created November 15, 2015 05:36 — forked from stephanetimmermans/ubuntu-idea-launcher
Add IntelliJ IDEA Launcher in Ubuntu 14.04
#In IDEA, go to Tools > Create Desktop Entry to create a launcher in /usr/share/applications.
cp /usr/share/applications/jetbrains-idea.desktop ~/.local/share/applications/
#http://nufailm.blogspot.be/2012/05/custom-launcher-for-intellij-idea-in.html
#http://stackoverflow.com/questions/14424254/intellij-launcher-doesnt-work-on-unity
@YaroslavShapoval
YaroslavShapoval / post-merge
Created September 22, 2015 08:56
Post-update git hook to set right owner and permissions for changed files
#!/bin/sh
# default owner user
OWNER="www-data:www-data"
# changed file permission
PERMISSION="664"
# web repository directory
REPO_DIR="/var/www/sitename"