Sunday 28 October 2018

Hyper-V Ubuntu Enhanced Session — actually make it work

The typical situation is that after entering your creds for xorg session you only see a teal screen, and nothing else happens. In short — turn off autologin for your user, and the enhanced sessions will start to work. Oh my had I spent a time searching for a solution, surprisingly found it on youtube: https://www.youtube.com/watch?v=oPHqoLbNTP8. Just watch.

Also check this https://www.frodehus.dev/resize-disk-for-ubuntu-hyper-v-quick-create-image/ for disk sizes. And this: https://www.youtube.com/watch?v=pY9x9wx9mb4 for vm-tools.

Tuesday 9 October 2018

Chrome Plugins 101

1. Print innerHTML every 3 seconds

manifest.json

{
  "manifest_version": 2,
  "name": "Try me",
  "version": "0.3",
  "permissions": [
    "<all_urls>"
  ],
  "content_scripts": [{
    "js": [ "content-script.js" ],
    "all_frames": true,
    "run_at": "document_end",
    "matches": ["<all_urls>"]
  }]
}

content-script.js

window.setInterval(function() {
  alert(document.getElementsByTagName('html')[0].innerHTML);
}, 3000);

Monday 8 October 2018

Tuesday 27 March 2018

Change an author of the last commit in both origin and remote

Only if it isn't too late ;)

git commit --amend --author "John Doe <john.doe@protonmail.ch>" --no-edit
git push origin <your_branch_name> --force

Tuesday 12 December 2017

Going dark

Dark mode helps remove eye-strain.
  1. Black Contrast — high contrast setting for Windows.
  2. --force-dark-mode for chrome to remove white address bar.
  3. Dark Reader chrome plugin (doesn't invert images, dark and light modes).
  4. Reluminate chrome plugin to selectively invert images.

Monday 11 December 2017

Set git ssh auth on linux

Trivial story, but... Sometimes simple things are made very difficult.

Say your user is john. Put to /home/john/.ssh/github (c:\Users\john\.ssh\github\ or %USERPROFILE%\.ssh\github\ on windows) your private ssh key, set access mode read/write to just your user (chmod or, say, in Double Commander). You generate this key file through, say, PuttyGen. Then, in /home/scd/.ssh (ssh_config in c:\Program Files\Git\etc\ssh\ on windows) create a ssh_config text file and put there:

Host github.com
    IdentityFile ~/.ssh/github/private-ssh

On windows: add AddKeysToAgent yes to the beginning, change ~/ to the value of %USERPROFILE%/. On Windows, this referenced key file needs to be converted to OpenSSH format.

Done.

Monday 15 September 2014

Nginx service failover to 1x1 gif with timeout

That's what I love nginx for. Really simple and declarative. At 8086 we have a service that is non-stable, at 8091 there is virtual gif substitutor. On 300ms timeout there will be 1x1 gif as a response. Nginx resides on 8090 for presentation.

http {
  include mime.types;
  default_type application/octet-stream;
  upstream backend {
    server localhost:8086;
    server localhost:8091 backup;
  }
  server {
    listen 8090;
    server_name localhost:8090;
    location /sf.gif { empty_gif; }
    location / {
      proxy_pass http://backend;
      proxy_next_upstream error timeout
        invalid_header http_500 http_502 http_503
        http_504 http_403 http_404;
      proxy_connect_timeout 300ms;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For
        $proxy_add_x_forwarded_for;
      proxy_redirect off;
    }
  }
  server {
    listen 8091;
    server_name localhost:8091;
    location / {
      rewrite ^ http://localhost:8090/sf.gif redirect; }
    location ^ {
      rewrite ^ http://localhost:8090/sf.gif redirect; }
  }
}