16 Mar 2017
|
git
Submodule update
Api is a submodule of VoD.
git submodule update <path/to/the/submodule>
Reset submodules at the commit where they were at the last commit of the superproject. In case of no submodule is provided, apply the command to each one.
![alt tag](https://github.com/antoan2/Reminiz_sysadmin/blob/master/tips/git/images/submodules_0.png)
git submodule update --remote <path/to/the/submodule>
Pull the submodules at HEAD stated in .gitmodules.
![alt tag](https://github.com/antoan2/Reminiz_sysadmin/blob/master/tips/git/images/submodules_1.png)
New commit in superproject
After a git submodule update --remote
, when you’re in state V0 / HEAD, you create a new commit of the superproject.
This creates a new commit, and associate the commit hashes of the submodules currently used.
![alt tag](https://github.com/antoan2/Reminiz_sysadmin/blob/master/tips/git/images/submodules_2.png)
09 Mar 2017
|
azure
Disabling caching a webapp
By default, Azure is caching files to speed-up the access to your Web app.
This may be inconvenient when you are developing and frequently uploading files on the FTP server for instance.
You can reach a state where: main.js
has been erased on the FTP, but main.js
is availabke through your browser.
On www.portal.azure.com:
- Go to your Webapp page
- Select
Application settings
- Scroll down to
App settings
- Add the key
WEBSITE_DYNAMIC_CACHE
with the value 0
And voilà !
Don’t forget to reenable it once you are done developing.
08 Mar 2017
|
bash
To copy the output of a command directly into clipboard, without having to select it manually, add
<some_command> | xclip -sel clip
at the end of the command. You can then paste the content !
Example : to copy the SSH key cat ~/.ssh/id_rsa.pub | xclip -sel clip
03 Mar 2017
|
docker
Setting the terminal encoding
- To avoid errors when printing special characters, we need a terminal that supports printing UTF-8 characters.
Default behaviour
Using a simple Dockerfile
FROM ubuntu
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
python-dev
Now attached to the docker
root@7ec9e210dbdd$ locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
root@50327e3b3d41$ python -c "print u'\xff'"
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in position 0: ordinal not in range(128)
The current terminal encoding cannot print non-ASCII characters
With UTF-8 encoding
Add the following lines to the Dockerfile
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8
This sets the terminal encoding to UTF-8 (and other things).
root@6669fd6259de$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
root@6669fd6259de$ python -c "print u'\xff'"
ÿ
01 Mar 2017
|
python
Printing default values with argparse
Normal mode
- code (
visu.py
):
```Python
parser = argparse.ArgumentParser(description=”View the live in your web browser”)
parser.add_argument(‘–config’,
help=’config.ini file of the run’,
required=False,
default=’../config.ini’)
parser.add_argument(‘–port’,
help=’specify port to run server’,
required=False,
default=5000,
type=int)
parser.add_argument(‘-r’, ‘–reload’,
help=’Description’,
action=’store_true’)
args = parser.parse_args()
- Using the script:
```Shell
$ python visu.py --help
usage: visualisator.py [-h] [--config CONFIG] [--port PORT] [-r]
View the live in your web browser
optional arguments:
-h, --help show this help message and exit
--config CONFIG config.ini file of the run
--port PORT specify port to run server
-r, --reload Description
usage: visualisator.py [-h] [–config CONFIG] [–port PORT] [-r]
View the live in your web browser
optional arguments:
-h, –help show this help message and exit
–config CONFIG config.ini file of the run (default: ../config.ini)
–port PORT specify port to run server (default: 5000)
-r, –reload Description (default: False)
```