Monday, November 16, 2020

moving lots of files with BOX

I had to move like 300K files in BOX, so just sharing a bit of how I did it and how to check the progress.

Basically, get:

1. BOX drive (no gnu/linux version available, so mounting the "folder" on a gnu/linux VM as a shared dir, and working from there)

2. A gnu/linux VM (I use virtualbox) with the necessary kernel stuff to mount shared dirs (thing to mount vboxfs)


I guess you could have done something similar in windows or mac too just writing a program directly in those platforms. But I hate both OSs, so, no.


You just write the program to rename/move the files however you want, and run it as with any other dir.


The catchy part is that box is super slow (for me at least), so even when in your disk all files would have been updated fairly fast, in the background, the thing takes forever to finish the sync... so if you check in the web version, many of the files would still be in the old location/will have their old filenames.

There should be a file called Box-{version?}.log in:

c:/Users/$USER/AppData/Local/Box/Box/logs/


There you should be able to see logs in the format:

DATE TIME ID? INFO    LocalExecutor-2      box_fs_sync_api       Move item on box.  XXXX

Telling you what it's doing.
I also mounted this in my VM and checked the logs with tail -f.


As of the time of this post, there is apparently no way to tell the sync progress besides this... And you basically will have to grep the log and compare with the list of files done with whatever you have in order to have an idea of the total percentage.

Not the coolest system.

Until the sync is complete, your box drive icon will show "Box Drive is updating your files" on mouse over. And it takes really super long... But maybe it's because of the many requests I sent, so my account was limited or something. It's like 1~3 requests a second based on the logs above.

If you're luckier than me, it should take under 3 days. If not, I hope you have a quiet computer.

Thursday, May 14, 2020

installing gnu/linux in DELL G5 5090

So, first time ever not buying a used computer or server. Wanting to enjoy 4K and everything, I bought Dell's G5 5090, obviously to use with GNU/Linux.

First impressions

1. the blue thingy is super annoying. Why is it so damn bright... I guess it must be a gaming/visual thing that makes no sense for engineers. (I was able to disable the LED from the bios later)
2. besides that, it looks awesome, lots of USB slots, a nice video card, HDMI interface, and lots of PCI slots to add more stuff if I need to.

After opening it

1. apparently it only has 2 HDDs slots... more would be nicer. I'll just use my external stands I guess.
2. holy sh*t the NVME disk is tiny

Installing GNU/linux

  1. The first issue is that by default, it won't let you access the BIOS... no matter how many times you press the F2 button. It immediately boots windows, and gets you that incredibly ugly and hard to use "compulsory" setup screen.
    For god's sake, windows is annoying.
    So, we have reset the CMOS so we can enter the BIOS setup screen, and choose another disk to boot (and disable the UEFI "secure" boot thing). Let's do that...
  2. Resetting the CMOS is pretty easy actually. You just open the cover, and move the jumper from the PASSWD slot to the CMOS_CLEAR or something slot. Here is a reference document: https://www.dell.com/support/article/ja-jp/sln284985/how-to-perform-a-bios-or-cmos-reset-and-clear-the-nvram-on-dell-systems?lang=en#Shortcut_2 
  3. now we can see the bios screen, yay. You will need to:
    1. disable UEFI secure boot (so you access your GNU/Linux install disk prob)
    2. change the SATA controller from intel RAID to AHCI (so you can actually use your NVME disk from linux)
  4. that's basically it. Now you can just insert your USB stick with the GNU/Linux install (I recommend Debian 10, whatever you choose, just no f*cking ubuntu ok?), and it should boot on it by default. If that doesn't work for you, access the BIOS again, go to the boot order screen, and make sure your linux disk is at the top.
    Partition notes: If you want to boot from your NVME disk, remember to create an EFI on the partition guide. Otherwise you'll have to boot from an external disk just for the boot loader.

Warning

One more really annoying thing, is that apparently windows rewrites the bios settings once you boot it. So if you by mistake boot in windows, the next time you start your computer you won't be able to access the BIOS again. So you'll have to do the CMOS reset once again... really really really get rid of that piece of sh*t OS.

Message for Dell

Please sell it to me cheaper, and without windows. That's a real win-win situation.
I also didn't need the mouse and keyboard... which is not even in a keymap I can/like to use.

Thursday, April 30, 2020

workaround for MySQL server has gone away error with flask

I had this issue when my flask simple app kept failing the next day it was started.
It kept giving the error "MySQL server has gone away".

I tried a couple of things like, starting the mysql session for every request instead of for each flask process (app-wide). But apparently flask doesn't like that.
At least not when using flaskext.mysql's MySQL.

I think I didn't have much luck trying to change the timeout on flask either, as this module just didn't let me.

I could have changed the module to use mysql, but I didn't have much time to finish the damn thing, so in the end I just set a cron job to access the mysql select query using page every 10 min or so. Ugly, but simple workaround.

It was like
curl -k https://localhost/some_app/index.html

every 10m.

flask app returns select with old data

I had this issue where my flask app kept giving me different results (doing a select query).

And it only happened on production, not in the development one.
Apparently due to the fact that flask has a couple of fork processes running, each with their own mysql session.
Even when you commit after an insert/update query, you still need for some reason to do a commit before a select in order to see the latest results.

The following is a sample code with some basic functions in order to do select and update queries.
I just call validate_sql_conn()  for pretty much everything I need to do in mysql, so it's always committing itself.


from flask import Flask, render_template, url_for, request, send_from_directory
from flaskext.mysql import MySQL
import yaml

app = Flask(__name__, template_folder='views')

def get_mysql_conf(mysql_conf_file="some_app_name_conf/mysql_conf.yml"):
    "gets the conf to use for the mysql connection"
    with open(mysql_conf_file, 'r') as f:
        content = f.read()
    yaml_content = yaml.load(content, Loader=yaml.FullLoader)
    return yaml_content

mysql = MySQL()
mysql_conf = get_mysql_conf()
app.config['MYSQL_DATABASE_USER'] = mysql_conf['mysql_database_user']
app.config['MYSQL_DATABASE_PASSWORD'] = mysql_conf['mysql_database_password']
app.config['MYSQL_DATABASE_DB'] = mysql_conf['mysql_database_db']
app.config['MYSQL_DATABASE_HOST'] = mysql_conf['mysql_database_host']
mysql.init_app(app)

conn = mysql.connect()
cursor = conn.cursor()


def validate_sql_conn():
    """
    uses global connection variable (conn) and recreates 
    it if seems to have dropped
    """
    global conn
    global cursor
    try:
        cursor.execute("show tables")
    except:
        conn = mysql.connect()
        cursor = conn.cursor()
    conn.commit()
    return True
        

def run_sql_and_get_results(sql_query, cursor=cursor):
    validate_sql_conn()
    cursor.execute(sql_query)
    data = cursor.fetchall()
    return data


def run_sql_and_commit(sql_query, cursor=cursor, conn=conn):
    validate_sql_conn()
    cursor.execute(sql_query)
    data = cursor.fetchall()
    commit_data = conn.commit()
    return commit_data


Thursday, April 16, 2020

gnus filtering html body mail

If you love emacs, you probably use gnus, which is in my opinion the
best mailer ever.
You can manage your complete filter in emacs lisp, and there are so many
ways to filter stuff.

The most complex and useful filtering method is using
"nnmail-split-fancy".

Which as I'm showing in this example, can be set as something like this:

(setq nnmail-split-fancy
      '(|
 ("subject" ".*/var/log/messages.*" "server_syslogs")
 (any "some_sender" "some_annoying_sender")
 ;; to me, not mailing lists
 (any ".*MY_NAME.*"
      (|
       (from ".*some_from_field.*" "some_company")
       (from "some_mailer_that_needs_body_filtering"
      (| 
       (: split-on-body ".*Assignee: MY_NAME.*" "your_service_me_assigned")
       (: split-on-body ".*Reporter: MY_NAME.*" "your_service_me_requested")
       "your_crappy_service")))
      "me_somewhere"
      ))
      "misc")

This would split stuff by subject first (having /var/log/messages in the subject), then see if the header contains "some_sender" and put the mail in the mail folder "some_annoying_sender". If neither of those matched, then would look for MY_NAME in the mail header, and split the logic even further, to split from the "from" header, and even on the mail body. It can be any function, but this "split-on-body" one is a common one I guess, since it comes with the documentation and all.
This is the split-on-body function:
(defun split-on-body (regexp-to-search group-to-split)
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-min))
      (when (re-search-forward regexp-to-search nil t)
 group-to-split))))

And it works great. But you get issues when filtering HTML mail... which gnus kind of usually parses someway (when you read it on gnus, it'll depend on the value of the "mm-text-html-renderer" variable).
The thing is, when the mail is being filtered, the text apparently is all in pure text, and that text kind of differs from the actual raw mail body, or what you see parsed in the mail view.
So, in short, you'll need to get the correct regexp, which you can't see anywhere but in the filter function itself...
So, here is a filter function for that purpose. It's pretty much the same as the above, but you get the prin1 text for the complete mail text in you *Messages* buffer.
;; debug version
(defun split-on-body (regexp-to-search group-to-split)
  "debug version"
    (save-excursion
      (save-restriction
 (widen)
 (goto-char (point-min))
 (message "searching for regexp in split on body")
 (let ((search-results (re-search-forward regexp-to-search nil t))
       (complete-buffer (prin1 (buffer-substring (point-min) (point-max))))
       )
   (message (concat  "regexp to search for = " regexp-to-search))
   (message (concat "search results =" (format "%S" search-results))))
 (goto-char (point-min))
 (when (re-search-forward regexp-to-search nil t)
   group-to-split))))

For some reason I didn't think of this until like 10 years after
starting using gnus...

Monday, April 13, 2020

rsyslog change output log file based on hostname

I want to put all the logs for hostnames starting with XXX in
/var/log/XXX.log.

And I'd also like to be able to read the file without having to do sudo
everytime...

Here is how:

in /etc/rsyslog.conf:

# remember to open your udp port to receive logs from other servers

$ModLoad imudp
$UDPServerRun 514
#### GLOBAL DIRECTIVES ####

# change umask so the default one doesn't mess with your filecreatemode permissions
$umask 0000

then create a file in /etc/rsyslog.d/50-my-XX-logs.conf:

#(any number is fine)

# this makes the file readable by anyone
$FileCreateMode 0644
:HOSTNAME, startswith, "XXX" /var/log/UHN2.log
# and stop any further filtering with the next line
& stop

This made it work for me. You can check more on the filters and
conditionals with rsyslog.conf(5) manual page.

Saturday, April 11, 2020

use youtube-dl with sites that need credentials/cookies

You might want to download something with youtube-dl, and get the following error:

ERROR: XXXX requires authentication. You may want to use --cookies.


Quick way to get the cookies and do the download:
1. get the chromium/chrome extension Editthiscookie
https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg/related?hl=en

2. on editthiscookie's settings, go to options -> "Choose the preferred
export format for cookies" -> "Netscape HTTP Cookie File"

3. on the site you're trying to download the video, click on
editthiscookie's extension, export

4. paste/yank your clipboard's contents into a file

5. do youtube-dl --cookies exported_cookies_file https://the-vid-you-wanted-to-download

fix emacs package-list's "Failed to verify signature..."

Everytime I called M-x package-list-packages, I got

package--check-signature: Failed to verify signature
some_package.el.sig: ("No public key for XXX")

I'm not really sure what effect this had, but it was annoying.


Fix

1. in a random buffer, do

(setq package-check-signature nil) ;; press C-x C-e here

2. do M-x package-list-packages
search for gnu-elpa (complete name: gnu-elpa-keyring-update)
and install that

3. then just restart emacs or do
(setq package-check-signature 'allow-unsigned) ;; press C-x C-e here


The next time you run package-list-packages, the warning should be gone.

emacs as rest client (API testing interface, like postman)

I love being able to use emacs as a REST API testing interface, kinda like postman, but in emacs.

Here are two ways to do this:

- restclient-mode http://emacsrocks.com/e15.html
- walkman https://github.com/abrochard/walkman

In short

Restclient should be your thing 90% of the time.
walkman prob 10%. But walkman works inside org-mode, so if you like org,
maybe can be 100% your thing.

In long


Restclient's thing even has a cute video and everything. So,
noob-friendly.
Resclient is probably the de facto standard right now to use in this
kind of thing though.
It's awesome, you can easily use variables, which can be plain elisp,
and it uses emacs' internal http request libraries for HTTP interaction.
The output is json-prettified and all, and requests are done async, very
nice.

The only thing, is that those libraries appear to be a bit buggy... and
sometimes won't work as expected.
I have this thing, that for this specific site, I always get a 404 or
500 status code.
But when I generate the curl request from the exact same block, it works
(curl works, elisp's request library apparently doesn't like my
headers ?).

So for that API, I use walkman inside org-mode, which uses pure curl,
and that works perfectly.

I like walkman a lot, as I love org-mode.
But the variable definitions must done in elisp, and you have to quote
them to use them... which is not very readable (and elisp code doesn't
look too good in org mode).

Samples

restclient

# -*- mode: restclient; -*-
# block1 gets fsf's site
GET https://www.fsf.org

# press C-c C-c somewhere in this block to send the request
# block2 POSTing stuff with a payload
POST https://your-fav-api/v1/resource
YOUR-HEADERS-HERE
{your payload
can use multiple lines
}

# block3 ...

walkman


* get a page
GET https://www.fsf.org

# you do C-c C-RET here to send the request

* post something
  POST https://your-favorite-api/v1/resource
  - HEADER1
  - HEADER2
  { PAYLOAD-HERE }

That's about it. They're both pretty intuitive, and the documentation is
clear enough to let you do whatever you want within like 5mins of
looking for it.

I'd usually want to test/use the API interface in a different file. So I
guess I'd be using restclient mainly, linking it from my "task" file in
org-mode. Mostly because the variables, and output are more readable
(highlighted and everything).
And when that fails, use walkman.

But that's just me.

Thursday, April 2, 2020

playing dvds in debian10

Steps
1. add the contrib (and probably non-free) repo to your sources list
2. install the libdvd-pkg package, and a player
3. run the libdvdcss library installer
4. (might be necessary to) set the region for your dvd device
5. try playing it

From top to bottom
if necessary, change your sources list

$ cat /etc/apt/sources.list
deb http://debian-mirror.sakura.ne.jp/debian/ buster main non-free contrib
deb-src http://debian-mirror.sakura.ne.jp/debian/ buster main non-free contrib
...


(you need to have the contrib repo as above)
if you did any changes, do "sudo apt-get update" to fetch the new repo data.

install the libdvd-pkg

$ sudo apt-get install libdvd-pkg
or better
$ sudo apt-get install libdvd-pkg libdvdcss-dev libdvdcss2 libdvdcss2-dbgsym libdvdnav4 libdvdread4 lsdvd regionset mpv lsdvd

then run the configure script, to compile the libdvdcss library
$ sudo dpkg-reconfigure libdvd-pkg

I don't remember if you needed to do this the first time, or just if your dvd wouldn't play... but try inserting a dvd, and do
$ sudo regionset
Some commercial DVDs won't play unless you have the "correct" dvd region for the region they were supposed to be sold to. Capitalism can be scary.
So, you can select a region, or just leave it as it is.
More info at /usr/share/doc/regionset/README

Finally, let's try playing something
$ mpv dvd://1

And you can check your dvd contents with
$ lsdvd

I'm sure you can also click around with your favorite desktop environment and find a way to play your dvd as well.

Tuesday, March 31, 2020

flask basic auth super simple

I wrote a super simple basic auth using flask app that does all the authentication in the app side.

https://gitlab.com/rikijpn/flask_simple_basic_auth

Don't ask me why... But hey, it works.

Using microsoft graph API to book things in outlook

Quick notice

I hate microsoft. Soooo much. And its API even more. I hated everything about using it, and having to read its very hard to understand documentation.
But it's the lesser evil to actually having to use ms outlook to book meeting rooms in an environment non ms free. The real solution is to get rid of microsoft and everything microsoft in your office.

Purpose

My office has these meeting rooms, which are always occupied. And it's very hard to make a reservation. I hate ms outlook too much to have to do this every day manually, so I checked out the ms "graph API" (in case you wonder, it's not to make "graphs", it's just the stupid name they use for their office API).
Now I can get all the meeting rooms I need daily for all my team without having to move a finger.

Code

The actual script I use is here: https://gitlab.com/rikijpn/ugly_ms_outlook_appointment_taker
I'm obviously removing all the tokens though.
It's in python, running daily. So you can just put this in cron, so as soon as they let you book meeting rooms (like 30, 60 days after the current day's specific time) you'be able to send the appointment request.

Preparation (create an "app")


1. create app (in your azure portal)
In the left-hand navigation pane, select the Azure Active Directory service, and then select App registrations → New registration.
https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps
2. in azure, select Manage → API Permissions → app (Microsoft APIs → Microsoft Graph → Delegated permissions)
Make sure you have the following permissions:
Calendars.ReadWrite
User.Read
offline_access

3. in azure, select Manage → Authentication → "Default client type" → "Treat application as public client"
4. in azure, select Manage → Authentication → "Supported account types" → "Accounts in this organizational directory only (this will probably have your company/school name here)"
5. get consent
https://login.microsoftonline.com/${tenant_id}/oauth2/v2.0/authorize?client_id=${client_id}&response_type=code&response_mode=query&state=12345&scope=offline_access%20user.read%20Calendars.ReadWrite
The "tenant_id" here is just  whatever you already have in your url when looking azure, a long senseless string, that is common through all the pages for your organization.
"client_id" will be shown in your "app"'s top/info page.
You can just ignore the rest and use it as it is.

Put this in your browser, and you'll be sent to a blank page by default. Check the URL in your browser, and you'll see there will be an "access" and "refresh" token.

Usage

And that's pretty much it. Now you are ready to do some tests.
I'm posting the test code (emacs's restclient-mode stuff) in the same gitlab repo: https://gitlab.com/rikijpn/ugly_ms_outlook_appointment_taker/-/blob/master/sample_requests.txt
In short, every time you want to use it, you'll have to use your "refresh_token" to create a new "access_token", which lasts very shortly (a couple of mins? one hour? don't remember).


One thing though, is that every time you change your password, you'll have to do get consent again:
https://login.microsoftonline.com/${tenant_id}/oauth2/v2.0/authorize?client_id=${client_id}&response_type=code&response_mode=query&state=12345&scope=offline_access%20user.read%20Calendars.ReadWrite

And update your tokens.

When you make a meeting room reservation (appointment, using the meeting room as a "resource"), you'll get a 200 status code if your auth has no issues. But that DOES NOT mean your meeting room was acknowledged, and that you got the meeting room. It just means the damn ms outlook server got  your request. The pain.
You'll get an e-mail with the approval/denial response a bit after your request is processed. I think you can also check with the API somehow.

Final thoughts

Really ugly documentation. That's how I've described pretty much all ms documentation in the past, and how I still do for everything about this "graph API" thing.
It's like, they don't really want you to be able to use it.
The token usage is frankly not bad, seems like a good (secure and clear) authorization and all, most likely thanks to its usage of OAuth2.0 and JWT.

Thursday, March 26, 2020

ssh tunnels

I love ssh tunnels.

Working in an office, with a super strict data center, they make my work so much easier.

Basically an ssh tunnel is a way to put a local port in a remote server, and vice-versa.

Scenarios it might be useful:

  1. You have a bastion/jump server that you need to connect to do EVERYTHING. It makes sense to just have one main ssh session established, and just connect with the same dynamic proxy tunnel to all the rest of the servers stepping through, without having to connect again each time.

    Situation:
    local machine TO jump server
    local machine TO jump server, jump server TO server only accessible by jump server1
    local machine TO jump server, jump server TO server only accessible by jump server2
    ...
    (above, you need to ssh to the jump server, and from then, ssh to the remote server, every time.)

    Solution:
    local machine TO jump server
    local machine ( through tunnel ) server only accessible by jump server1
    local machine ( through tunnel ) server only accessible by jump server2
    ...
    (above, you just open one session to the jump server. And then can ssh directly from your local box to the remote servers through the tunnel)
  2. You can ssh from your local machine TO a server, but not the other way around (due to firewall, being behind a router, etc)

    Situation:
    local machine TO remote server = OK
    remote  server TO local machine = NO

    Solution:
    local machine TO remote server (remote forward:9001 to localhost:22)
    remote server TO remote server port 22 (=local machine's ssh port = local machine)
  3. You want to share a port/server only accessible from the office, to a remote server. Let's say, your intra network's GIT server, to a server. Or your mail server, local printer, etc.

    Situation:
    local machine TO intra git = OK
    remote server TO intra anything = NO

    Solution:
    local machine TO remote server (remote forward RANDOM_PORT to intra git server's SSH PORT)
    remote server TO remote server's RANDOM_PORT (goes through your local box, and to intra's git server)
  4. Debugging your flask DEV env on port 5000, and your firewall doesn't let you access it directly.

    Situation:
    local machine TO remote server's port 5000 = NO
    local machine TO remote server = OK (ssh)
    remote server  TO remote server's port 5000 = OK

    Solution:
    local machine TO remote server (local forward 5000 to localhost:5000)
    local machine TO local machine's port 5000 ( = remote server's port 5000)

These are just some simple examples.
You can also kind of nest them! One ssh tunnel to another, and another... and sometimes it gives you a bit of a headache.
My .ssh/config file is huge due to this, but it beats the alternative of not being able to debug a flask development instance live with your browser, for example.


What is dynamic/local/remote forwarding?

In short:
Dynamic tunnels act as SOCKS servers. This means you can ssh connect with the nc command sending all the stream directly. When you set up dynamic forwarding for a host, your local machine dynamic forwarding port will act as a SOCKS server.

local forwarding = the port will be on your local machine, pointing to somewhere in the remote server

remote forwarding = the port will be in the remote server, pointing to somewhere on your local machine

Easy, right?

So, how to do you this?


I think you can do this in windows terminals too, and even macs. But This is GNU/Linux blog, so I'll be talking only about the ssh command and its config.

You can do all this with arguments to the ssh command, but I was never able to remember those. So I just edit my ~/.ssh/config file for all these settings, and that's the way I'll be introducing.

All settings below will be in your local machine's ~/.ssh/config.

Let's create a dynamic tunnel


Host some-jump-server.net
  # these two aren't really necessary, I just like them
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  DynamicForward 5555

So, you just "ssh some-jump-server.net" in one terminal, and keep that session open.
To access a server only accessible from the jump server, you just add that server to your ~/.ssh/config, defining it as a server that needs to go through that proxy, or you can also like create a script for the same purpose.

This is how I'd register the server:

Host some-server.my-subnet
     ProxyCommand nc -x 127.0.0.1:5555 %h %p

Then you just "ssh some-server.my-subnet". And in one ssh, you should be accessing the remote server.
You'll probably be needing an ssh agent if you plan to do this though, but that's a topic for another post.

Also, notice you don't need to add hosts one by one, you can set complete sub-domains, or just "all" with the "*" wildcard (next to the "Host" keyword). "*.my-subnet" for example, would set this dynamic proxy port for all servers you try to ssh that end with ".my-subnet".

Let's try a localforward

Local Fowards open a port in your local machine, to somewhere pointing on the remote server.
Let's use the flask development port (5000) for example, that you can only see in your server, and can't access directly from anywhere else.

Host some-server-with-my-flask-dev.my-subnet
     LocalForward 8559 localhost:5000

So, now you can just put your in local machine's browser the url http://localhost:8559/, and you'll be accessing your remote host's port 5000, yay. No need to proxy or anything, just ssh.

And, let's try a remoteforward

The last one, remote forward, opens a port in the remote server, pointing somewhere in your local machine.

Host some-server-that-needs-intra-stuff.my-subnet
  # pointing your local git server for example
  RemoteForward 5757 192.168.11.1:7999

  # or to your tiny proxy http proxy, in case you need to access intra web
  RemoteForward 8999 localhost:8888

So, if you ssh to some-server-that-needs-intra-stuff.my-subnet, you'll be able to see with "netstat -atn|grep LISTEN" for example, that the ports 5757 and 8999 are open. And they'll be pointing to your local machine's 7999 and 8888 ports respectively. In this example, they're your local git server, and http proxy. So virtually, you could be accessing the same INTRA web from a DC that shouldn't have access at all! yay! Welcome to the wonderful world of security risks as well, be careful!


In conclusion, ssh tunneling is fun. Remember you can also have multiple remote and local forwards in each host block, and you mix them as well. It can be quite a mess! But sooo damn useful.

Wednesday, March 25, 2020

using synergy to share your keyboard and mouse with another computer

What's Synergy?

An awesome program that allows you to share your mouse/keyboard over the network with another computer.
You basically need to have the "server" installed on the computer your keyboard/mouse are connected to, and a "client" to the other one.


I use this at the office, where I'm sadly forced to use ms windows, and connect it to my GNU/Linux box.
I also use it at home when I bring my office laptop sometimes, and just do all the input with my home keyboard/mouse, as I'm a happyhacking keyboard fan.

How to install

On Windows: google for "windows synergyc 1.8.8", for the windows one, and install that
On GNU/Linux Debian-family: sudo apt-get install synergy

in Debian 10

As of debian 10, synergy is an outdated package apparently. I guess it wasn't very popular...

But you can install it from the stretch's repo directly, like this:


sudo apt-get install libcrypto++6 libqt4-network libqtcore4 libqtgui4
wget http://ftp.jp.debian.org/debian/pool/main/s/synergy/synergy_1.4.16-2_amd64.deb #just find this deb file in whatever mirror you prefer
sudo dpkg -i synergy_1.4.16-2_amd64.deb 


How to setup

in ms windows (client)

Just make a "shortcut" with something like "C:\Synergy\synergyc.exe XX.XX.XX.XX"  (your server's IP)

in GNU/Linux

create a file /etc/synergy.conf with these contents:


section: screens
random_name_for_your_server_box:
random_name_for_your_client_box:
end
 
section: links
random_name_for_your_client_box:
        left = random_name_for_your_server_box
random_name_for_your_server_box:
        right  = random_name_for_your_client_box
end


You'll also need to put your "random_name_for_your_server_box" name in /etc/hosts.

How to use

1. in windows: double click the "shortcut" thing
2. in GNU/Linux, open a terminal, and type "synergys"

The client terminal should show some debug messages, like "server connected!" and stuff like that.
Just move your mouse pointer and see it go from your server screen to your client's.

I'm surprised really so few people know about this and end up buying more keyboards, or worst, using a bluetooth one just to be able to switch the input (facepalm). sshing is also super useful and all, but sometimes you use a crappy OS like ms windows in which that's just not possible, or just want to use it on its same screen.

You can also use this in a better environment, GNU/Linux with GNU/Linux.
Don't get me started about macs.