This site is a hybrid of Blog system and personal knowledge base. The information here is based on personal experience.
The blog entries include my personal opinion. The categorized content removes personal and leaves only the knowledge.
This site was started in August, 2018 and it is growing from my daily experience and from my private knowledge base being made public.
Categorized Content SKB
Color in Terminal
Changing Just Directory Color in Terminal For ls command to display directories in easy to see manner. Fixing colors in ls. Change /etc/bash.bashrc or ~/.bashrc. For WINDOWS bash LS_COLORS="ow=01;36;40" && export LS_COLORS For UBUNTU 16.10: LS_COLORS="di=01;36;40" && export LS_COLORS or LS_COLORS="di=01;32;40" && export LS_COLORS Source VIM Color Highlight Create ~/.vimrc with: set background=dark 2nd line is required in Hyper-V terminal in Ubuntu 16.04 LTS: colorscheme darkblue Bash for Windows Configuration of Colors Content or Registry File
DataWeave (MuleSoft)
DataWeave Notes
Maven
Maven Parent Files To reference Maven parent file located in the repository use the following example: <parent> <groupId>org_or_com.organization_name</groupId> <artifactId>application-name-component-name</artifactId> <version>1.2.3-15</version> <relativePath></relativePath> </parent> It is important to specify empty relative path. Self-closing version might work, but I run into one tim issue at some point. Standard dependency version resolution rules don’t work in parent element. So, you must specify artifact version explicitly! Maven Aritfact Versioning It is difficult to find information on the topic.
Sphinx Installation
Applies to: Ubuntu 16.04 LTS. Installation on Ubuntu Ubuntu already has python3 installed and it is supported by Sphinx. Installation is simple: sudo apt-get install python3-sphinx That’s it for installation. Installation with PIP on any platform For existing projects you can restore python dependencies with a single command: pip install -r requirements.txt If starting from scratch, install the following python packages manually. Command: pip install -U sphinx Install Theme unless custom theme is desired:
CLI Notes for PostgreSQL
psql Use To get to administrator prompt: sudo su - su - postgres psql DB Access Give user access to the database from IP address by editing file: sudo -u postgres vi /etc/postgresql/9.4/main/pg_hba.conf Add line: hostssl fireflyd firefly 10.0.1.13/31 md5 The line above allows firefly user to connect to fireflyd database from 10.0.1.13 IP address. Subnet /31 points to only one IP address. Reload configuration with:
Linux Admin Land
Linux Administration
Log4j2
Log4j 2 configuration
Sphinx Development Environment
Building Documentation Commands: make html make latexpdf Troubleshooting no module named doc8 Command: pip install doc8 Note Run as normal user.
IP Address
Use INET for IP address of the endpoint. Use CIDR for network address. Details
Networking in Linux
Netowrking Tasks in Linux
Sphinx References
reStructuredText Primer HTML theming support LaTeX Builder
Visual Studio Code
Highlight Current Line "workbench.colorCustomizations": { "editor.lineHighlightBorder": "#00aa00" } To URL Encode Text Use Browser debugger: encodeURI("V%") VSCode REST Example that uses variables @clientId = cid @clientSecret = some_secret_value @userId = uid # NOTE: the value might have to be URL encoded, depending on context @password = some_password ### - this is a separator # @name login # the name gets refrenced in other runs post http://host/oauth2/v1/token Content-Type: application/x-www-form-urlencoded Authorization: Basic {{clientId}} {{clientSecret}} userName={{userId}} &password={{password}} ### # refernces login response body above GET https://host/api/do-something Authorization: Bearer {{login.
Graphs for Software Development Documentation
VSCode supports the format. Example 1 digraph unix { rootNode; node1 [ shape=record label="{ Node 1 | attr1 \l attr2 \l attr3 \l }" ]; rootNode -> node1; rootNode -> node2 [style="dotted"]; } Useful Visual Studio Code Extensions Name: Graphviz (dot) language support for Visual Studio Code Id: joaompinto.vscode-graphviz Description: This extension provides GraphViz (dot) language support for Visual Studio Code Version: 0.0.5 Publisher: João Pinto VS Marketplace Link: https://marketplace.
SQL Notes for PostgreSQL
High Availability and Balance Loading References PostgreSQL Documentation: Chapter 26. High Availability, Load Balancing, and Replication repmgr PostgreSQL Cluster does not match standard definition of cluster: What’s a PostgreSQL “Cluster” and how do I create one?. Wiki on replication. Create DB User and Database for Application Create DB User: CREATE USER name_u WITH LOGIN NOSUPERUSER CREATEROLE -- CREATEDB INHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD 'type_password_here'; Create Database:
May, 2019
Posts in May, 2019
July, 2019
Posts in July, 2019
August, 2019
Posts in August, 2019
Manjaro
Manjaro
NPM Notes
NPM Notes
October, 2019
Posts in October, 2019
November, 2019
Posts in November, 2019
ZFS on Manjaro
ZFS on Manjaro
January, 2020
Posts in January, 2020
nginx
nginx
CSS Notes
CSS Notes
XFCE
XFCE Notes
Loaders in JavaScript
Loaders in JavaScript
Java on Linux
Debian To Install apt-get install default-jre apt-get install default-jre-headless Debian 8.8 (Jessie) openjdk-7 or openjre-7 is supported by default. JDK 8 is not supported. Ubuntu Ubuntu 16.04 LTS It supports Java 9 and 8. Search example: apt-cache search jre Example installation: apt-get install default-jre-headless which installs openjdk-8-jre-headless.
URXVT on Ubuntu 14.04 LTS
URXVT is a nice terminal. Copy/Paste with Gnome is not integrated and an extension needs to be installed: https://github.com/muennich/urxvt-perls Install xsel to get copy/paste working.
X Windows
X Windows
Research on SQLite UUIDs
SQLite UUIDs ** UUIDs ** http://sqlite.1065341.n5.nabble.com/How-to-store-128-bit-values-td25224.html In reply to this post by Steve Krulewitz On 7/11/07, Steve Krulewitz <[hidden email]> wrote: In the application I am working on (Songbird), we have a simple two table schema representing the tracks in your music collection and the properties on those tracks. The keys used are all UUIDs (128 bit number) which we are currently storing in hex string form in a text column, so they literally appear in the database as “ee89b823-e709-40c5-bed7-dcb0b2b791a8”.
Webpack
Webpack
Browserify
Browserify
Bower
Bower
Angular Notes
Angular Notes
Links 2019
Unorganized collection of links in 2019
UUID in PostgreSQL
Generated Primary and Foreign Keys for Distributed Databases ID Conditions: unique to identify table row across databases. ordered for efficient clustered index performance. Examples UUID is not effective when data is spread across multi-master replication (MMR) scenario. It fails condition #2 above. -- to enable gen_random_uuid() function CREATE EXTENSION pgcrypto; CREATE SCHEMA IF NOT EXISTS core; create table core.user ( userPK UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(), created timestamp without time zone NOT NULL, updated timestamp without time zone NOT NULL ); References UUID Primary Keys in PostgreSQL
LXC
LXC Containers
LXD
LXD Containers
Backup with rsync
Example to rsync: sync -avhP --delete ~/important /mnt/externaldrive How to Use rsync to Backup Your Data on Linux How to Backup Files in Linux With Rsync on the Command Line rdiff-backup is a good alternative which focuses on incremental changes.
Posts
Posts are unorganized and uncategorized blog messages. Year 2020 January, 2020 Posts in January, 2020 Year 2019 May, 2019 Posts in May, 2019 July, 2019 Posts in July, 2019 August, 2019 Posts in August, 2019 October, 2019 Posts in October, 2019 November, 2019 Posts in November, 2019 Links 2019 Unorganized collection of links in 2019 Year 2018 August, 2018 August 14, 2018 In August 14 I worked on Google OAuth2 in ASP.
August 14, 2018
In August 14 I worked on Google OAuth2 in ASP.NET Core 2.
Keeping Uptodate with Geary
My personal laptop runs on Ubuntu 16.04 LTS and I use Geary to work with Gmail accounts. I recently run into an issue of Geary not deleting email messages from Inbox and generally being sluggish with getting new mail. I checked and version of the application is \“0.12-dev\“. The currently released version is 0.12.3. So, I decided to upgrade: sudo add-apt-repository ppa:geary-team/releases sudo apt-get update sudo apt-get install geary It appears that update has fixed the issue.
Logging in ASP.NET Core
https://stackoverflow.com/questions/49128340/asp-net-core-include-timestamp-in-all-log-entries?noredirect=1&lq=1
VSTS to AWS
AWS CLI is supported on Python, which is an excellent cross-platform tool. Python package management works well. To add the following line to requirements.txt file: awscli==1.15.72 An alternative is to install AWS CLI with command (run as Administrator on Windows): pip install awscli pip freeze > requirements.txt Linux Hosted generates command to restore Python packages. Make sure it is active in your project: > python -m pip install \--upgrade pip && pip install -r requirements.
AWS Static Website: References
How Do I Configure an S3 Bucket for Static Website Hosting?. Hosting a Static Website on Amazon S3. Example: Setting up a Static Website Using a Custom Domain.
Site Workflow
My worflow on this site consists of: Author content in Visual Studio Code. Run make html and visually inspect the result. Upload to Azure static website host using Azure Storage plugin for VSC. Verify the result at http://sergei.gnezdov.us website. Commit GIT code and push to origin. The origin is a private GIT repository on Visual Studio. NOТЕ: Azure static website is in preview and setup of it was not painless.
Sphinx Comments Deployment
August 3, 2018 I have setup Shinx documentation system for work. We used Read the Docs Sphinx Theme. I decided to add publically available comments to the system. My major restriction is to limit amount of used technologies on the server to reduce chance of breaking the server with installation of new dependencies. It is largely a self-imposed restriction influenced by a set of particular circumstances at work. We currently use IIS Server to run .
Sphinx Theme Customization
Sphinx has some good themes, but customizaiton is a bit limitted. For example, it seems to be not possible to add comments to existing sphinx_rtd_theme theme. So, I had to figure out how to use a custome theme embedded into the project itself. Here is the process I used with sphinx_rtd_theme theme. Steps: Create _theme directory in your project source directory. Copy sphinx_rtd_theme directory (it is the directory that contains theme.
Last work at Itron
My most recent work involved trying out LightweightM2M server on Java (Leshan) with goal of forwarding data to .NET Core 2 backend serving Angular frontend. A couple weeks prior to that I put together a small Angular application with NodeJS on backend. That pretty much touches almost all major development stacks. Full stack development effort starting with working GO language on Linux and FreeBSD. Sending IoT data over CoAP to a GO based server.
Gitlab CI Examples Publish an Artifacts Directory exposeArtifacts: script: echo Exposing artifacts artifacts: paths: - artifacts/x86_64/
Authentication and Authorization in ASP.NET Core 2
public void ConfigureServices(IServiceCollection services) { // ... services.AddCors(); services.AddSingleton<IWorkService, WorkService>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(o => o.LoginPath = new Microsoft.AspNetCore.Http.PathString("/login")) .AddGoogle(googleOptions => { googleOptions.ClientId = Configuration["Authentication:Google:ClientId"]; googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"]; }); services.AddAuthorization(options => { options.AddPolicy("authenticated", policy => { policy.AuthenticationSchemes.Add(GoogleDefaults.AuthenticationScheme); policy.RequireAuthenticatedUser(); }); }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<Startup> logger, IConfiguration config) { // ... app.UseAuthentication(); } References Authorize with a specific scheme in ASP.NET Core. aspnet/Security on GitHub. Using OAuth2 Middleware with ASP.
CORS on .NET Core 2 with Web API
How to enable CORS in ASP.net Core WebAPI Install-Package Microsoft.AspNetCore.Cors public void ConfigureServices(IServiceCollection services) { services.AddCors(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IConfiguration config) { // ... app.UseCors(options => options.WithOrigins("http://example.com") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); ); app.UseCors(builder => { var allowedOrigins = config.GetSection("AllowedOrigins").GetChildren().ToArray().Select(c => c.Value).ToArray(); logger.LogInformation("Allowed Origins: {0}", string.Join(", ", allowedOrigins)); builder.WithOrigins(allowedOrigins).AllowAnyMethod(); }); // ... } References original MSDN instructions based on StackOverflow discussion obsolete link contains instructions for older version of Web API (Web API 1).
DNS Tools
Windows Linux To list TXT record: dig TXT talkingwithrebecca.com @dns4.registrar-servers.com FreeBSD About hostname: host hostname To list TXT record type for \_amazonses hostname using @dns1 nameserver: drill txt _amazonses.gnezdovi.com @dns1.registrar-servers.com Reverse Lookup Name from IP: drill -x 24.16.122.177 Mac OS X List TXT record: nslookup -type=TXT _amazones.gnezdovi.com dns1.registrar-servers.com. Clear DNS cache: sudo killall -HUP mDNSResponder
Embedded Development in Python
Read spidev in Python on BeagleBone Black import spidev import time spi = spidev.SpiDev() # open(bus, device) spi.open(1, 0) spi.max_speed_hz=50000 spi.mode = 0 while True: print spi.readbytes(5) time.
Git Extensions
Troubleshooting Cloning Errors If cloning using SSH protocol returns an error “bad line length character”. Try switching from PUTTY to OpenSSH. Try other solutions. Git Extensions Fails to Change to OpenSSH Git Extensions does not report any errors. However, if you reopen settings dialog you will see that Putty is still selected. Remove GIT_SSH environment variable.
Git Submodules as Dependency Management
Git can be used for managing dependencies. It some cases it is the best solution and has to be considered as a viable tool. C++ does not have package management system and thus git submodules are a natural model to add any library dependencies. This results in highly cohesive approach to dependency management. Many languages these days provide “packages”: NodeJS has NPM .NET has NuGet Python has pip However, in a mixed solution environment it can be time consuming to maintain all custom package repositories.
Git Versioning
Git can be used for versioning. It is great, because version number autoincrements with every check-in. Even if you branch, each version will remain unique. Version label is easy to control with git tags. Advantages: version is automatically maintained without additional effort. Depending on your goal it is a PRO or CON: rebuilding the same check-in generates the same version number regardless of what machine is used.
Netmask
Easy explanation of netmask. Visual reference: Class Address # of Hosts Netmask (Binary) Netmask (Decimal) CIDR /4 240,435,456 11110000 00000000 00000000 00000000 240.0.0.0 CIDR /5 134,217,728 11111000 00000000 00000000 00000000 248.0.0.0 CIDR /6 67,108,864 11111100 00000000 00000000 00000000 252.0.0.0 CIDR /7 33,554,432 11111110 00000000 00000000 00000000 254.0.0.0 A /8 16,777,216 11111111 00000000 00000000 00000000 255.0.0.0 CIDR /9 8,388,608 11111111 10000000 00000000 00000000 255.128.0.0 CIDR /10 4,194,304 11111111 11000000 00000000 00000000 255.
Ports
Listening Ports Find Out What Ports Are Listening / Open On My Linux & FreeBSD Server Various Ways to List Ports on Linux. Option #2 works on barebones machine. Option #2 for barebones machine: sudo ss -lntu Port Binding Applies to: “Ubuntu 16.04 LTS” Ubuntu 16 Linux uses authbind application to control which non-root users can bind on <1000 port numbers. Use the following procedure to add new application-port registration.
Python 'requirements.txt' File
The file can be generated with command: pip freeze > requirements.txt The file is used to track python package dependencies. To install packages listed in requirements file: pip install -r requirements.txt
Remote Editing with rmate
rmate utility was originally created on Mac OS X by TextMate editor. It allows user to edit file on remote system over SSH protocol. Today we can see find multiple implementations of rmate using different languages. Many editors support this protocol including Visual Studio Code and Sublime. I prefer shell based implementation, because it does not have additional dependencies. Original GitHub instructions. To install shell version: wget -O /usr/sbin/rmate https://raw.github.com/aurora/rmate/master/rmate --no-check-certificate sudo chmod a+x /usr/sbin/rmate For standard SSH:
TL-R600VPN
Hardware VPN
WPF XBAP and WCF Trusted Security
The WSHttpBinding with name WSHttpBinding failed validation because it contains a BindingElement with type System.ServiceModel.Channels.SymmetricSecurityBindingElement which is not supported in partial trust. Consider disabling the message security and reliable session options, using BasicHttpBinding, or hosting your application in a full-trust environment. Partial Trust Support in .NET 3.5 description What is supported and what is not Best Practices WPF Partial Trust Error Request for the permission of type ‘System.Net.WebPermission, System, Version=2.
WebSockets in ASP.NET Core 2
References How to use WebSocket with ASP.NET Core. WebSockets support in ASP.NET Core (2.1).
rundll32 usage example
Really Old Note rundll32.exe can be used to start DLL file without executable file. It is very nice if you know what you are doing: rundll32.exe %SystemRoot%\system32\shimgvw.dll,ImageView_Fullscreen %1 rundll32.exe url.dll,FileProtocolHandler "C:\Documents and Settings\Sergei\My Documents\My Pictures\JumpKeys-1.PNG" The following is possibly an original source of information.