Skip to content

Instantly share code, notes, and snippets.

@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
# 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 / links-in-html.directive.ts
Last active February 24, 2018 14:49
Angular 2+ directive for routing HTML links in raw loaded HTML
@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
# 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 / 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
@havran
havran / sort-columns-in-row.sql
Last active February 8, 2017 05:09
PostgreSQL - sort columns in row
-- Table: public.testy
-- DROP TABLE public.testy;
CREATE TABLE public.testy
(
id integer NOT NULL DEFAULT nextval('testy_id_seq'::regclass),
prod1 integer,
prod2 integer,
prod3 integer,
var createSubmitForm = function(path, parameters, method = 'POST') {
var form = $('<form></form>');
form.attr('action', path);
form.attr('method', method);
parameters.authenticity_token = $('meta[name="csrf-token"]').attr('content');
for (var key in parameters) {
if (parameters.hasOwnProperty(key)) {
# Geocoding script for large list of addresses.
# Shane Lynn 10/10/2013
#load up the ggmap library
library(ggmap)
# get the input data
infile <- "input"
data <- read.csv(paste0('c:\\Temp\\R scripts\\', infile, '.csv'), fileEncoding = "UTF-8")
# get the address list, and append "Ireland" to the end to increase accuracy
# Spustit cez []->Source
#
library(curl)
library(jsonlite)
# Zistime si meno adresara v ktorom sa nachadza subor so scriptom
sourceDir <- getSrcDirectory(function(dummy) {dummy})
# Vlozime script s funciami pre geocoding.
source(paste(sourceDir, '/', 'geocoding.R', sep = ''))