## jueves, 17 de octubre de 2019

### Using Office365 Mail and Calendar in Linux

The following content is a direct copy of a blogpost by Keheliya, I prefer to keep a copy here in case the link stops working at any point.Keheliya stack exchange: https://stackexchange.com/users/215269/keheliyaSource: http://keheliya.blogspot.com/2018/01/using-office365-mail-and-calendar-in.html

## Friday, January 26, 2018

### For some reason, if your school or workplace is using Microsoft Office365/Outlook for all communication, you can configure your Linux e-mail client to support most of those features such as e-mail, calendar, and contacts working. Sometime back, support for Microsoft Exchange-based services was very buggy in open-source e-mail clients like Thunderbird and Evolution. But they have come a long way since then. Here are the steps I followed to get my University e-mail working in Evolution.

Step 1: First install the software needed.
sudo apt-get install evolution evolution-ews

Step 2: (Optional) If you are not using a GNOME-based Desktop Enivronment you need to install following dependencies as well. (For example, I'm using XFCE with i3WM)
sudo apt-get install gnome-online-accounts gnome-control-center

Step 3: Then start the gnome-contol-center. If you're not on GNOME, you might have to trick the Desktop to make it believe you're on GNOME like this:
env XDG_CURRENT_DESKTOP=GNOME gnome-control-center

Step 4: Click on Online Accounts and add your Microsoft Exchange details. (Here use outlook.office365.com as the server.)

Step 5: Go to Evolution. Add an identity.

Step 6: In Receiving e-mail section, use https://outlook.office365.com/EWS/Exchange.asmx as the Host URL. Then when you click the Fetch URL button, OAB URL should be auto-completed.

Step 7: Once you restart, everything should be synced.

# Environment-modules

## Installation

It is possible that environment-modules is in your package manager. In debian based OS just look for the package
aptitude search environment modules
# or
# apt-cache search environment modules
It actually finds one package called environment-modules. You can install it in Debian based OS with
sudo aptitude install environment-modules
# or
# apt-get install environment-modules
After the installation, there is some automatic configuration to do
It will ask to confirm the modifications (by default is yes)
adds a few lines to the beginning of your
/home/maikel/.profile, /home/maikel/.bashrc, and
possibly your /home/maikel/.kshenv (or whatever is
specified by the ENV environment variable).
The lines are prepended for sourcing the /etc/csh.modules or
/etc/profile.modules files or to define the module alias or function.
Why is it necessary?
To insure that you will have access to modules for all subshells,
these lines need to be added to some of your 'dot' files.

renamed to .login.old, .cshrc.old, .profile.old, .bashrc.old and
.kshenv.old respectively.  So if you have any problems you will
can easily restore them.

This is version $Id: 196cf1d4fbd7d3deecf648e85ee37ead75a60a93$ .

Continue on (type n for no - default=yes)?\c

Cleaning .profile
Adding sourcing lines at beginning of .profile

Cleaning .bashrc
Adding alias or function lines at beginning of .bashrc
You had no .kshenv as I see it.  Copying /etc/skel/.kshenv for you.
/bin/cp: cannot stat ‘/etc/skel/.kshenv’: No such file or directory
/bin/cp: cannot stat ‘/etc/skel/.login’: No such file or directory
You had no .cshrc as I see it.  Copying /etc/skel/.cshrc for you.
/bin/cp: cannot stat ‘/etc/skel/.cshrc’: No such file or directory
source ~/.bashrc
Now, create and register the folder where all the modules will be specified
mkdir ~/modulefiles
module use ~/modulefiles
Test that it is working by calling
module avail
You should not see any error.

You can customize your own environment by creating and loading your own modulefiles. To use your own modulefiles you must first create a directory for them, register that directory and create the file. Here is a step by step example: Create and register the directory
mkdir ~/modulefiles
module use ~/modulefiles
This adds your newly created directory to the MODULEPATH environment variable and makes the files you place in there visible to the loader. Add the 'module use' directive to .profile or .bashrc depending on the file you use to initialize the module package. Create the modulefile Use this file as an example. The content is discussed below.
#%Module1.0####################################################################
##
##  mymodule modulefile
##
##  My new module that sets my personal environment
##
proc ModulesHelp { } {
puts stderr "\tAdds my personal stuff to the environment."
}

## Create a whatis file.  Not nessecary but cool.

## Set a few personal aliases
set-alias       "ll"    "ls -al"

## Add my bin directory to the path
append-path     PATH    ~/bin

## Set an environment variable
setenv          MY_VAR  "hello"

### Explanation

Line 1: This line contains the syntax version that is used. Line 2-6: Comments Line 7-9: This is optional. This prints a module specific help when used with the 'module help' command. Line 12: This command sets an alias. Line 15: This command appends ~/bin to your PATH environment variable. You can also use prepend-path Line 18: Create and set a new environment variable.

## References

• 2
• http://modules.sourceforge.net/
• https://www.nersc.gov/users/software/nersc-user-environment/modules/

# PyPi

### Install and upgrade some requirements

pip install pip setuptools twine --upgrade

### Create accounts

On PyPI Live and also on PyPI Test. You must create an account in order to be able to upload your code. I recommend using the same email/password for both accounts, just to make your life easier when it comes time to push.

### Create .pypirc file

Create a .pypirc file in your home with the following content
[distutils]
index-servers =
pypi
pypitest

[pypi]

[pypitest]
repository:https://test.pypi.org/legacy/
Change permissions for other users
chmod 600 ~/.pypirc

### Tag the git repo

git tag 0.1 -m "Adds a tag so that we can put this on PyPI."
git push --tags origin master

### setup.cfg

python setup.py register -r pypitest
python setup.py sdist upload -r pypitest

## miércoles, 8 de febrero de 2017

### Opening Java GUIs on the Awesome Window Manager (e.g. Matlab)

It seems that opening Matlab, Maple, and other programs that rellie in a Java GUI do not work properly when using the Awesome Window Manager. In all the cases the window is not loaded and a grey square is shown instead.

The problem seems to be that the Java Virtual Machine does not recognise this desktop when checking the system environment.

To solve the problem it is only necessary to change the appropriate environment variables to a known environment (e.g. LG3D). This can be achieved by installing wmname and running

wname LG3D

just before opening any of the applications.

source: https://kb.wisc.edu/cae/page.php?id=30963

## martes, 31 de enero de 2017

### Simple example of Sphinx apidoc

I created a gihub repo with a really simple example of how to use the sphinx-apidoc program to automatically generate documentation of a python package.
You can find the repo here
The following text is just a copy-paste of the README file of the mentioned repo
To try this example just clone the package
git clone git@github.com:perellonieto/sphinx_apidoc_example.git
And then go into the created folder
cd sphinx_apidoc_example
In order to create the documentation first it is necessary to generate all the configuration files. The easiest way is just to run the following script.
sphinx-apidoc -o docs -E -H PackageName -A "Author Name" -V 0.1 -f -F package/
where
• -o Directory to place the output files.
• -E Put each module file in its own page.
• -H Project name to put into the configuration.
• -A Author name(s) to put into the configuration.
• -V Project version.
• -f Usually, apidoc does not overwrite files, unless this option is given.
• -F If given, a full Sphinx project is generated using sphinx-quickstart.
Then you need to modify the file docs/conf.py by adding the path to the root folder with the package.
import os
import sys
sys.path.insert(0, os.path.abspath('../'))
Now it is possible to generate the documentation by going to the docs folder and running the sphinx code. The easiest way is
cd docs
make html
It will generate an index.html in docs/_build/html/index.html and it should look something similar to this index.html

## jueves, 26 de enero de 2017

### Visualise and modify the character encoding of a file

To see the character encoding of a file use the command "file" with the option -i or --mime. This shows the mime (Multipurpose Internet Mail Extensions) type strings. In the following example, we see the charset of an index.html file

$file -i ./index.html ./index.html: text/html; charset=iso-8859-1 We can use the command "iconv" to convert the encoding of a given file from one encoding to another. In the next example from iso-8859-1 to utf-8$ iconv -f ISO-8859-1 -t UTF-8 index.html -o index.html

where -f is --from-code, -t is --to-code and -o is --output

source: http://stackoverflow.com/questions/11316986/how-to-convert-iso8859-15-to-utf8

## jueves, 19 de enero de 2017

### SSH Master and slave connections

If you connect often to a server and you need to do simultaneously various tasks (e.g. get files by SFTP or using scp). It is possible to authenticate only one time and use the first session as a tunnel for all the subsequent connections.

Create the file ~/.ssh/config or edit the file by appending these two lines
ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r

Now, after the first connection requiring authentication, all the following ones will use the first one as a tunnel and do not require authentication.

The master connection can not be closed until all the slave connections are closed.

Source http://unix.stackexchange.com/questions/2857/ssh-easily-copy-file-to-local-system