Цитата

Если твое счастье зависит от того, как поступают другие, то, пожалуй, у тебя действительно есть проблемы. (c) Ричард Дэвис Бах

OpenCV 3.1.0 build deb package for Ubuntu 16.04 from source

Create workspace

$ mkdir workspace && cd workspace

Download OpenCV 3.1.0 from official release archive

$ wget https://github.com/Itseez/opencv/archive/3.1.0.zip
$ unzip 3.1.0.zip

Download OpenCV Contrib archive and checkout correct version branch

$ git cone https://github.com/opencv/opencv_contrib.git
$ cd opencv_contrib
$ git checkout 3.1.0
$ cd ../

Switch to OpenCV downloaded sources dir

$ cd opencv-3.1.0
$ mkdir build && cd build

You should select options you need

$ cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DCMAKE_INSTALL_PREFIX=/usr/local \
    -DWITH_VTK=ON \
    -DWITH_TBB=ON \
    -DWITH_GDAL=ON \
    -DBUILD_TESTS=OFF \
    -DBUILD_PERF_TESTS=OFF \
    -DWITH_EIGEN=ON \
    -DWITH_V4L=ON \
    -DBUILD_EXAMPLES=OFF
..

Install checkinstall tool if we didn’t have one, We will use it to create deb package

$ sudo apt-get install checkinstall
sudo checkinstall \
    --type debian \
    --pkgname opencv3 \
    --pkglicense "3-clause BSD" \
    --maintainer "User Name \\<user @domain.ltd\\>" \
    --nodoc \
    --arch $(dpkg --print-architecture) \
    --pkgsource="https://github.com/Itseez/opencv/archive/3.1.0.zip" \
    --pkgaltsource="https://github.com/opencv/opencv/tree/3.1.0" \
    --pkgversion="3.1.0" \
    --reset-uids \
    --addso \
    --exclude "/home*" \
    --pkggroup "universe" \
    -y \
    --install=no \
    --pkgrelease $(date +"%y%m%d")

Add Calendar.app subscription to US holidays calendar

Open Calendar.app
File -> New Calendar Subscription …
[Read the rest of this entry…]

Cisco AnyConnect Secure Mobility Client on MacOS autofill password and connect (apple script) (version 2.0)

1 — password storage move to keychain
2 — reactions for already connected connection with suggestion to reconnect or abort
3 — some code improvements

run from command line:

$ osascript ./vpn_run.scpt

Quote #

The good news: it’s really easy to do. The bad news: there is no bad news.

(c) https://www.pluralsight.com/blog/news/add-course-completions-and-assessment-certifications-to-your-linkedin-profile

Очередной анекдот

«В британском отеле портье подходит к американскому туристу, нетерпеливо жмущему на кнопку лифта.
— Сэр, лифт скоро будет здесь.
— Лифт? О, вы имеете в виду элеватор.
— Нет, сэр, здесь мы называем это лифт.
— Но, поскольку он был изобретен в Америке, он называется элеватор.
— Да, сэр, но поскольку язык был изобретен здесь, то это называется лифт».

Using sed to swap year and day in the file name

$ ls -la
-rw-r--r--@  1 user  group  204279 Oct 18 15:02 RT-01.08.14.pdf
-rw-r--r--@  1 user  group  204103 Oct 18 15:02 RT-04.01.15.pdf
-rw-r--r--@  1 user  group   96029 Oct 18 15:02 RT-09.08.16.pdf
-rw-r--r--@  1 user  group  204001 Oct 18 15:02 RT-10.04.14.pdf
-rw-r--r--@  1 user  group  204246 Oct 18 15:02 RT-11.01.16.pdf
-rw-r--r--@  1 user  group  204280 Oct 18 15:02 RT-11.02.15.pdf
-rw-r--r--@  1 user  group  204529 Oct 18 15:02 RT-11.06.16.pdf
-rw-r--r--@  1 user  group  403242 Oct 18 15:02 RT-13.08.14.pdf
-rw-r--r--@  1 user  group  204254 Oct 18 15:02 RT-13.09.16.pdf
-rw-r--r--@  1 user  group  172961 Oct 18 15:02 RT-14.10.13.pdf
-rw-r--r--@  1 user  group  204371 Oct 18 15:02 RT-15.12.15.pdf
-rw-r--r--@  1 user  group  204334 Oct 18 15:02 RT-18.03.16.pdf
-rw-r--r--@  1 user  group  204360 Oct 18 15:02 RT-18.05.14.pdf
-rw-r--r--@  1 user  group  204246 Oct 18 15:02 RT-18.10.16.pdf
-rw-r--r--@  1 user  group  204271 Oct 18 15:02 RT-19.07.15.pdf
-rw-r--r--@  1 user  group  204249 Oct 18 15:02 RT-19.08.15.pdf
-rw-r-----@  1 user  group  204438 Oct 18 15:02 RT-20.10.15.pdf
-rw-r--r--@  1 user  group  204321 Oct 18 15:02 RT-21.02.16.pdf
-rw-r--r--@  1 user  group  204425 Oct 18 15:02 RT-23.03.15.pdf
-rw-r--r--@  1 user  group   61505 Oct 18 15:02 RT-28.01.14.pdf
-rw-r--r--@  1 user  group  204243 Oct 18 15:02 RT-28.02.14.pdf
$ find . -name 'RT-*.pdf' -exec echo {} \; | sed "s/.\/RT-\([0-9]*\).\([0-9]*\).\([0-9]*\).pdf/.\/RT-\1.\2.\3.pdf .\/RT-\3.\2.\1.pdf/" | xargs  -n2 mv
$ ls -la
-rw-r--r--@  1 user  group  172961 Oct 18 15:02 RT-13.10.14.pdf
-rw-r--r--@  1 user  group   61505 Oct 18 15:02 RT-14.01.28.pdf
-rw-r--r--@  1 user  group  204243 Oct 18 15:02 RT-14.02.28.pdf
-rw-r--r--@  1 user  group  204001 Oct 18 15:02 RT-14.04.10.pdf
-rw-r--r--@  1 user  group  204360 Oct 18 15:02 RT-14.05.18.pdf
-rw-r--r--@  1 user  group  204279 Oct 18 15:02 RT-14.08.01.pdf
-rw-r--r--@  1 user  group  403242 Oct 18 15:02 RT-14.08.13.pdf
-rw-r--r--@  1 user  group  204103 Oct 18 15:02 RT-15.01.04.pdf
-rw-r--r--@  1 user  group  204280 Oct 18 15:02 RT-15.02.11.pdf
-rw-r--r--@  1 user  group  204425 Oct 18 15:02 RT-15.03.23.pdf
-rw-r--r--@  1 user  group  204271 Oct 18 15:02 RT-15.07.19.pdf
-rw-r--r--@  1 user  group  204249 Oct 18 15:02 RT-15.08.19.pdf
-rw-r-----@  1 user  group  204438 Oct 18 15:02 RT-15.10.20.pdf
-rw-r--r--@  1 user  group  204371 Oct 18 15:02 RT-15.12.15.pdf
-rw-r--r--@  1 user  group  204246 Oct 18 15:02 RT-16.01.11.pdf
-rw-r--r--@  1 user  group  204321 Oct 18 15:02 RT-16.02.21.pdf
-rw-r--r--@  1 user  group  204334 Oct 18 15:02 RT-16.03.18.pdf
-rw-r--r--@  1 user  group  204529 Oct 18 15:02 RT-16.06.11.pdf
-rw-r--r--@  1 user  group   96029 Oct 18 15:02 RT-16.08.09.pdf
-rw-r--r--@  1 user  group  204254 Oct 18 15:02 RT-16.09.13.pdf
-rw-r--r--@  1 user  group  204246 Oct 18 15:02 RT-16.10.18.pdf

Distribute NuGet package resources without copy to project resources folder

My local folder structure:
nuget package local structure

MyDemoPack.nuspec

< ?xml version="1.0"?>
<package>
  <metadata>
    <id>MyDemoPack</id>
    <version>$version$</version>
    <authors>Our Team</authors>
    <owners>Our Corp</owners>
    <requirelicenseacceptance>false</requirelicenseacceptance>
    <description>Description</description>
    <copyright>Copyright © 2016</copyright>
    <tags>my demo pack nuget resources</tags>
  </metadata>

  <files>
    <file src="build/MyDemoPack.targets" target="build/Xamarin.iOS"></file>
    <file src="res/**" target="Resources/"></file>
  </files>
</package>

build/MyDemoPack.targets

< ?xml version="1.0" encoding="utf-8"?>  
<project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  <itemgroup>
    <content Include="$(MSBuildThisFileDirectory)\..\..\Resources\TextDocument.txt">
      <link />Resources/TextDocument.txt
	</content>
	    <content Include="$(MSBuildThisFileDirectory)\..\..\Resources\Images\demoImage.png">
      <link />Resources/Images\demoImage.png
	</content>
  </itemgroup>
</project>
$ nuget pack MyDemoPack.nuspec -properties Configuration=Release -version "1.0.0"
Attempting to build package from 'MyDemoPack.nuspec'.
Successfully created package '<dir>/MyDemoPack.1.0.0.nupkg'.

Result package content:
NuGet package content

When you are going to install this package, you will not see these resources in Solution explorer, but they will be automatically copied to the project (Bundle) folder on build.
I tested and this approach works in Visual Studio, and Xamarin IDEs.

Cisco AnyConnect Secure Mobility Client on MacOS autofill password and connect (apple script)

--
-- for command line osascript ./vpn_run.scpt and add permission to "security & privacy"
-- 
activate application "Cisco AnyConnect Secure Mobility Client"
tell application "System Events"
	repeat until window 1 of process "Cisco AnyConnect Secure Mobility Client" exists
	end repeat
	
	tell process "Cisco AnyConnect Secure Mobility Client"
		
		tell window 1
			tell combo box 1
				set focused to 1
				set value to "vpn.company.com"
			end tell
			
			click button "Connect"
		end tell
		
		repeat until window "Cisco AnyConnect | vpn.company.com" exists
		end repeat
		
		tell window "Cisco AnyConnect | vpn.company.com"
			tell text field 1
				set value to "<user>"
			end tell
			tell text field 2
				set value to "<password>"
			end tell
			click button "OK"
		end tell
	end tell
end tell

to run from command line:

$ osascript ./vpn_run.scpt

Using SED to update CMakeLists.txt version.

#!/bin/bash

major=$1
minor=$2
patch=$2

sed -i.bak -E "s/set\(MYTOOL_VERSION_MAJOR [0-9]+\)$/set(MYTOOL_VERSION_MAJOR ${major})/g" CMakeLists.txt
sed -i.bak -E "s/set\(MYTOOL_VERSION_MINOR [0-9]+\)$/set(MYTOOL_VERSION_MINOR ${minor})/g" CMakeLists.txt
sed -i.bak -E "s/set\(MYTOOL_VERSION_PATCH [0-9]+\)$/set(MYTOOL_VERSION_PATCH ${patch})/g" CMakeLists.txt