Skip to content

Instantly share code, notes, and snippets.

@havran
havran / get_next_2weeks_day.rb
Last active June 2, 2017 06:22
Compute next day in two weeks interval from start_date.
# Compute next day in two weeks interval from start_date.
# date - current day (today)
# start_date - date from which interval started
# day_of_week - day of week as number monday = 1 ... sunday = 0
def get_next_2week_day(date, start_date, day_of_week)
date = date.to_date
next_day = date + ((day_of_week - date.wday) % 7)
next_next_day = next_day + 7.days
start_date = start_date.to_date
# Compute previous scheduled date.
def get_previous_day(date, day_of_week)
date = date.to_date
date - ((date.wday - day_of_week) % 7)
end
def get_previous_month_day(date, day_of_month)
date = date.to_date
@havran
havran / Vagrantfile.rb
Last active April 6, 2020 04:14
Vagrantfile -> Ubuntu 16.04 / PHP 5.6/7.1/7.2 / Nginx / MySQL (MariaDB)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@havran
havran / links-in-html.directive.ts
Last active February 24, 2018 14:49
Angular 2+ directive for routing HTML links in raw loaded HTML
# If your Angular (2) tests stop watching file changes on Unix you may have small inotify number system seeting.
# This should correct this.
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p --system
@havran
havran / wsl2-gpu-python-support.md
Last active April 26, 2023 19:35
2023-04-26 WSL2 docker-ce + NVIDIA CUDA support for tensorflow / pytorch GPU support