tag:blogger.com,1999:blog-99081462024-03-14T06:45:46.226+01:00L'AmministraTuriMy personal-tech blogSalvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.comBlogger65125tag:blogger.com,1999:blog-9908146.post-45017890658441670072024-02-25T18:49:00.005+01:002024-02-25T18:53:41.617+01:00Odoo: Facciamo chiarezza sulle XPath - Parte 1
<p>
Benvenuti!<br/><br/>
Questo articolo contiene la prima parte di una serie di puntate dove voglio provare a fare chiarezza su un aspetto fondamentale per lo sviluppo delle UI di Odoo.<br/>
Il contenuto è rivolto ad un pubblico tecnico che possiede un background per sviluppare con il framework di Odoo.<br/>
Potete trovare il codice usato in questo tutorial su questo <a href="https://github.com/salvorapi/odoo-xpath-tutorial" target="_blank" >repository</a>.
</p>
<h2>XPath: XML Path Language</h2>
<p>
XPath, acronimo di XML Path Language, è un linguaggio utilizzato per navigare e selezionare elementi in documenti XML. <br/>
Fornisce un modo per individuare e accedere a specifici nodi o elementi all'interno di un documento XML (DOM).<br/>
Utilizza una sintassi a Path (come nel filesystem) per indicare la posizione di un elemento nell'albero gerarchico di un documento XML.<br />
Ad esempio, un'espressione XPath potrebbe essere <i>"//book/title"</i>, che selezionerebbe tutti gli elementi "title" che sono discendenti diretti di un elemento "book" in un documento XML.<br/>
Per chi volesse approfondire l'argomento su questo linguaggio potete trovare materiale ai seguenti link:
</p>
<ul>
<li><a href="https://www.w3schools.com/xml/xpath_syntax.asp" target="_blank">https://www.w3schools.com/xml/xpath_syntax.asp</a>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/XPath" target="_blank">https://developer.mozilla.org/en-US/docs/Web/XPath</a>
</ul>
<h2>Odoo e XPath: Un cocktail da brivido!</h2>
<p>
Le interfacce web (o view) di Odoo fanno uso di una sintassi, attravero il motore di template QWeb, <br />
basata sul linguaggio XML per la rappresentazione nei vari formati (Tree, Form, Kanban, etc...).<br/>
In generale, il meccanismo e la struttura di Odoo non permette di modificare direttamente il codice sorgente della singola view di tipo QWeb.<br/>
Piuttosto, il principio di modifica delle view esistenti (quelle di sistema o di addons esterni) <br/>si basa sul meccanismo di <b>ereditarietà</b>:
in sostanza, viene costruita una nuova vista <i>VE</i> che eredità dall'originale <i>V</i> che altera (aggiunge o modifica) il contenuto dalla vista genitore.
<br />
<br />
<b>Domanda:</b> quale sintassi utilizzare per modificare il contenuto della vista genitore ? <br/>
<b>Risposta:</b> La risposta è <b>XPath</b>!
<br />
<br />
Nella documentazione ufficiale di Odoo (<a href="https://www.odoo.com/documentation/master/developer/howtos/website_themes/layout.html#xpath">link</a>) si fa riferimento a quello che ho descritto sopra.
Attraverso degli esempi pratici andremmo ad approfondire meglio come si usano le XPath.
</p>
<h2>XPath Tutorial: Da zero a eroe delle XPath.</h2>
<p>
Per facilitare l'apprendimento delle XPath ho preparato un modulo (o addons) <i>xpath_tutorial</i> che trovate sul mio spazio GitHub.<br/>
Per semplicità, definisce solo un Controller su cui viene fatto il render di un template <i>index</i> definito dentro il file <i>templates.xml</i>.<br/>
Completata l'installazione del modulo, il risultato è che potete accedere all'indirizzo <br/>
<br />
<a href="http://localhost:8069/xpath_tutorial">http://localhost:8069/xpath_tutorial</a>
<br />
<br />
e vederne il risultato.
<br/>
<code>
<pre class="xml">
<template id="index" name="xpath_index">
<t t-call="web.layout">
<h1>Hello, Xpath!</h1>
</t>
</template>
</pre>
</code>
Adesso, passo dopo passo vedremmo come riuscire a essere confindenti con le XPath
</p>
<h2>Esempio 1: Aggiugiamo un poco di colore al nostro template</h2>
<p>
L'obiettivo di questo esempio è modificare il colore dell'intestazione h1 con il colore rosso senza modificare il codice della vista originale.<br />
Per fare questo andremmo a definire un nuovo template <i>index_inherit</i> che eredita da quello di origine <i>index</i>.
<br />
Il contenuto del template inizia con il tag <i><xpath></i> che ci permette di modificare il contenuto del template da cui ereditiamo.<br />
Troviamo due attributi fondamentali:
</p>
<ul>
<li><b>expr</b>: contiene l'espressione XPath (o selettore) del tag (o nodo) che vogliamo intercettare e modificare</li>
<li><b>position</b>: contiene la "posizione" su cui vogliamo intervenire, nel caso dell'esempio usiamo il valore <i>attributes</i> per intervenire sugli attributi del tag intercettato. </li>
</ul>
<p> Di seguito trovate l'esempio che riporta la modifica dell'attributo <i>style</i> del nodo <h1> che si trova dentro la vista ereditata.</p>
<pre class="xml">
<template id="index_inherit" inherit_id="index" name="inherith">
<xpath expr="//h1" position="attributes">
<!-- Importante è il nome dell'attributo -->
<attribute name="style" add="color:red" />
</xpath>
</template>
</pre>
<p>
Il risultato finale sarà che l'intestazione si colora di rosso.
Potete provare da soli a cambiare l'intesazione di un altro colore oppure rimuovere la riga <attribute> così da vederne l'effettivo risultato.
</p>
<p>
Nella seconda parte andremmo ad approfondire i valori possibili dell'attributo <i>position</i> utilizzato dentro il tag XPath.
</p>
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-63173914553372212772023-01-05T10:01:00.002+01:002023-01-05T10:01:58.841+01:00Happy new 2023 and work!Happy new year! And happy new work to me!<div><br /></div><div>I'm very pleasure to announce that this year I got a new job within a startup, Pixora, where I will continue to invest to my capabilities with the role of "Senior Project Development Manager".</div><div><br /></div><div>If you want to get other information on this company, go to main website <a href="https://www.pixora.it/" target="_blank">https://www.pixora.it/</a></div><div><br /></div><div><br /></div><div>So, let's begin with this new adventure...stay tuned!</div><div><br /></div><div><br /></div>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.comCatania CT, Italia37.5078772 15.08303049.6177740655073016 -20.0732196 65.3979803344927 50.2392804tag:blogger.com,1999:blog-9908146.post-49298908908998327742021-06-29T15:55:00.006+02:002021-11-05T17:15:38.962+01:00Log raw mail content to file<div>Hi!</div>
<div><br /></div>
<div>
After a long time, I return to write on my personal blog with a personal
challenge. I've a Linux box with some scheduled tasks using cron service. I
want to send mail to my personal mailbox in case of error of a single task
(preferably with error log). It's not hard to configure the <span
style="background-color: white;"
>environment </span
>because just use a simple MTA (personally prefer msmtp) to send mails via
command line. But it's hard to set up the values of <i>From</i> and
<i>To</i> fields because cron use the default of execution user.
</div>
<div>
So, the first question was:
<b>How to write the raw content of mail to disk ?</b>
</div>
<div>
The solution is to write a simple bash script that replace sendmail and write
content of the mail to disk.
</div>
<pre><code class="bash">
#!/bin/bash
cat - >> /tmp/$(date +%s).txt
</code>
</pre>
<div><br /></div>
<div>
Then, create a symbolic link of the script with sendmail name, and it's ready
to write raw content to tmp path. The next step is to change the values of
From and To fields....easy. With
</div>
<div><br /></div>
<pre><code class="bash">sed "s/From: root\.*/From: from@domain.com /" | sed "s/To: root/To: dest@domain.com/" | /usr/bin/msmtp $*</code></pre>
<div style="text-align: left;">
and it's done! Now, my mailbox has a set of mail sent from my linux box.
</div>
<p>
See youu.....
</p>
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0Via degli Agrumi, 11, 95121 Catania CT, Italia37.4745144 15.049978637.42002852456109 14.981314049218749 37.529000275438904 15.118643150781249tag:blogger.com,1999:blog-9908146.post-84266669511991667532021-03-04T10:12:00.002+01:002021-03-04T10:12:16.951+01:00nmap Quick Reference<h3>Basic usage</h3>
<dl>
<dt>Enum SSL Chipers on specific port (RDP 3389)</dt>
<dd>
<pre><code class="bash">nmap -sV --script ssl-enum-ciphers -p 3389 192.168.x.x</code></pre>
</dd>
</dl>
<dl>
<dt>Simple ping hosts</dt>
<dd>
<pre><code class="bash">nmap -sn 192.168.x.x</code></pre>
</dd>
</dl>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-77181835037536645652020-05-20T10:38:00.005+02:002021-05-04T17:23:12.670+02:00Docker Quick Reference<p>This post is for me a place where to store notes about Docker. I hope that this can be helpful for you.</p>
<h3>Basic usage</h3>
<dl>
<dt>How do you disable auto-restart on a container? (<a
href="https://stackoverflow.com/questions/37599128/docker-how-do-you-disable-auto-restart-on-a-container"
target="_blank">Ref.</a>)
</dt>
<dd>
<pre><code class="bash">docker update --restart=no my-container</code></pre>
</dd>
<dt>How can we see all possible variables for a format?</dt>
<dd>
<pre><code class="bash">docker container ls -a --format '{{json .}}'</code></pre>
</dd>
<dt>How to analyze disk usage of a Docker container ? (<a
href="https://stackoverflow.com/questions/26753087/how-to-analyze-disk-usage-of-a-docker-container"
target="_blank">Ref.</a>)
</dt>
<dd>
<pre><code class="bash">docker ps --size</code></pre>
or
<pre><code class="bash">docker system df --verbose</code></pre>
</dd>
<dt>How to show container bind ports ?</dt>
<dd>
<pre><code class="bash">docker port container_name</code></pre>
</dd>
</dl>
<h3>Images</h3>
<dl>
<dt>How to export all images ?</dt>
<dd>
<pre><code class="bash">eval $(docker image ls --format 'docker save {{.ID}} -o "{{.ID }}.tar.gz";')</code></pre>
</dd>
</dl>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-58177604785396763802019-06-25T14:21:00.000+02:002020-01-08T07:14:54.264+01:00Vim Quick Reference<p>Basically, <i>vim</i> has three working modes:<br />
</p><ol><li> Command mode<br />
<li> Insert Mode<br />
<li> Ex-mode<br />
</ol><h3>Basic VIM Movement</h3><p><ul><li><i>b</i> move back from word </li>
<li><i>w</i> move next to word </li>
</ul></p>
<h3>Commands</h3><p>Disable text wrap <pre>:set wrap!</pre>(you can use ~/.vimrc)</p><p>Display or hide line numbers?
<pre>:set number</pre>for display
<pre>:set nonumber</pre>for hide
</p>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-26311661263526165082019-04-29T11:54:00.000+02:002020-03-12T16:09:17.393+01:00VMWARE - Get snapshots and size of VMs<br />
Today I need to check the snapshots of all VMs of a VMware infrstructure. Unfortunately I have found that with vSphere Client and vSphere Web Client it's not possibile to get a list of snaps associated to VMs.<br />
<br />
So, after a advanced google search, I have found that this is possibile using VMware PowerCLI tools.<br />
I've installed the version 5.5 available in this page <a href="https://code.vmware.com/web/tool/5.5/vmware-powercli">https://code.vmware.com/web/tool/5.5/vmware-powercli</a><br />
<br />
After this, I use powershell for loading the snapin and connect to my vcenter server with this:<br />
<br />
<pre><code class="powershell">add-pssnapin vmware.vimautomation.core
connect-viserver myvcentersrv_FQDN
</code>
</pre><br />
Then with the commmand I get the list with VM name, number of snapshot and size:<br />
<br />
<pre><code class="powershell">Get-VM | Format-Table Name, @{Label="NumSnapshots";Expression={(Get-Snapshot -VM $_ | Measure-Object).Count}}, @{Label="TotalSnapShotSizeMB";Expression={(Get-Snapshot -VM $_ | Measure-Object -Sum SizeMB).Sum}}</code>
</pre><br />
Ref: <a href="http://www.vhersey.com/2016/03/01/quick-powercli-to-get-snapshots-and-size/">http://www.vhersey.com/2016/03/01/quick-powercli-to-get-snapshots-and-size/</a><br />
<br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-27263070880460162442018-12-04T17:17:00.002+01:002022-11-03T17:38:02.678+01:00Pip Quick Reference<h3>Basic pip usage</h3>
<dl>
<dt>Upgrade PIP</dt>
<dd>
<pre><code class="bash">python -m pip install --upgrade pip</code></pre>
</dd>
<dt>Find outdated/updatable pip packages</dt>
<dd>
<pre><code class="bash">pip list --outdated</code></pre>
</dd>
<dt>Getting info on your python environment</dt>
<dd>
<pre><code class="bash">python -m site</code></pre>
</dd>
</dl>
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-27626283370872259962018-09-08T22:59:00.001+02:002020-03-12T12:38:27.996+01:00Git Hooks - A way to automate deploy tasks<div style="text-align: justify;">During my work I use git for automate the deploy on production system. Sometimes I need execute some command or script immediately after checkout. Git has a very powerful mechanism called <b>hooks </b>(you can read more about it on official documentation follow <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" target="_blank">this link</a>).<br />
On client side to install hooks what you have to do is to create a dir called <i>hooks </i>under <i>.git/</i> . But you do not have to do any of this because when you have initialized your project git create it for you.<br />
If you list the content of hooks dir you can found a list of samples script to use (all of them are bash scripts). Most of this script start with the prefix <i>pre- </i>or <i>post-</i> followed by action name.<br />
The script that I found helpful is <i>post-checkout</i> that is automatically executed after a successful git checkout. My post-checkout script contain commands for adjust permissions on files and ask to restart web server.<br />
</div><div style="text-align: justify;"><br />
</div><pre><code class="bash">#!/bin/bash
git ls-files -z --with-tree="$2" --directory | xargs -0 chmod o-rxw --
git ls-files -z --with-tree="$2" --directory | xargs -0 chown www-data:www-data --
find . -type d | xargs -I {} chown www-data:www-data {}
find . -type d | xargs -I {} chmod o-rwx {}
exec < /dev/tty
while true;
do
read -p "Do you want to restart apache? [Y/N]:" choice
case "$choice" in
y|Y) service apache2 restart;break;;
n|N) break;;
*) echo "invalid" && break;;
esac
done
</code>
</pre><div style="text-align: justify;">Remember to add execute permission to this script or git won't execute it after the checkout.</div><div style="text-align: justify;"><br />
</div>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-45249592114751345792018-03-16T16:30:00.001+01:002022-01-26T16:01:33.867+01:00Git Handbook<h3>Git Setup</h3>
<div>
<h4>How to setup git with SSH Key</h3>
<pre><code class="bash">git remote set-url origin git@github.com:<Username>/<Project>.git</code></pre>
<h4>Configure username and mail<br />
</h4>
<pre><code class="bash">git config --global user.name "Name Surname"
git config --global user.email "mymail(at)mydomain.com"</code></pre>
<h4>Filename too long in git for windows</h4>
<pre><code class="bash">git config --system core.longpaths true</code></pre>
<p>
Note: You need to run as administrator.
<br />
Ref: <a
href="https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows">https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows</a><br />
</p>
<h4>Windows CRLF chars.</h4>Su windows bisogna disattivare questa funziona altrimenti non funzionano i caratteri
CRLF.<br />
<pre><code class="bash">git config core.autocrlf false</code></pre>
<h4>How can I debug git/git-shell related problems?</h4>
<p>If you have problem with Git and you need to debug you can run this:</p>
<pre><code class="bash">GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull</code></pre>Ref: <a
href="https://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems">https://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems</a><br />
<h4>How to get list of files between change log ?</h4>
<p>
If you need to get list of files (included directory tree) from change list you can use:
</p>
<pre><code class="bash">git diff-tree -r --name-only 2c636a^ 5b47402 | xargs -I {} rsync -aR {} output/</code></pre>
<h4>Delete files from git index when they are already deleted</h4>
<pre><code class="bash">git ls-files --deleted -z | xargs -0 git rm</code></pre>
<h4>How do I show my global git config?</h4>
<pre><code class="bash">git config --list</code></pre>
<h4>Show remote branches</h4>
<pre><code class="bash">git branch -vr</code></pre>
</div>
<h3>Git Commands</h3>
<div>
<h4>How to commit only staged modified and deleted files?</h4>
<pre><code class="bash">git add -u</code></pre>
<h4>List log with tag date</h4><br />
<pre><code class="bash">git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'</code></pre>
</div>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-48880580617051159362018-03-02T11:13:00.000+01:002018-03-02T11:13:42.222+01:00How to improve reading of log filesThere are hard times when a sysadmin have to read a lot of rows of log files for troubleshoot a system error. In this times can be helpful to use some tools to improve reading of these files.<br />
<br />
I've found two tools:<br />
<br />
<ul>
<li><b>Generic Colouriser (GRC)</b> - <a href="https://github.com/garabik/grc">https://github.com/garabik/grc</a> - there are programs: <i>grc</i> and <i>grcat</i>. The main is <i>grcat</i>, which acts as a filter, i.e. taking standard input, colourising it and writing to standard output. Then you can use configuration files for customize color ouput depend on you application output log. </li>
<li><b>Log File Navigator (LNAV)</b> - <a href="http://lnav.org/">http://lnav.org/</a> - this is a real log file navigator that parse content of file and follow the stream for read latest lines. Lnav can help highlight the parts that are important and filter out the noise. </li>
</ul>
<div>
<br /></div>
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-27599411068433965572018-01-19T18:06:00.000+01:002018-09-09T14:45:13.190+02:00How to launch python Idle from a virtual environment (virtualenv)<p>If you have a virtual environment and you want to use IDLE for write you pretty script you can run this command:</p><br />
<pre class="shell"># python -m idlelib.idle
</pre><br />
Ref: <a href="https://stackoverflow.com/questions/8792044/how-do-i-launch-idle-the-development-environment-for-python-on-mac-os-10-7/8792082#8792082">https://stackoverflow.com/questions/8792044/how-do-i-launch-idle-the-development-environment-for-python-on-mac-os-10-7/8792082#8792082</a>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-69704662351032728132017-08-29T12:43:00.001+02:002018-09-09T14:45:50.790+02:00How to view all ssl certificates in a bundle?This morning I got a problem with a certificate bundle and how to get single certificate inside it.<br />
I found the answer on ServerFault (<a href="https://serverfault.com/questions/590870/how-to-view-all-ssl-certificates-in-a-bundle">link</a>).<br />
<br />
<pre class="shell"># openssl crl2pkcs7 -nocrl -certfile bundle.crt | openssl pkcs7 -print_certs -text -noout
</pre><br />
<br />
<br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-53035574882654040512017-03-06T19:19:00.001+01:002017-03-06T19:19:54.642+01:00Sed Quick Reference<h3>Basic sed usage</h3><br />
<! -- Items --><br />
<dl><dt>Add "-dev" at the end of the match.</dt>
<dd><pre># sed -i 's|saml[1-2]-.*\.php/[a-zA-Z0-9\-]*|&-dev| </pre></dd> </dl><br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-24379421565705508322016-12-27T15:12:00.002+01:002016-12-27T15:12:27.678+01:00Ping host and log output with timestampIf you have some random network issue (specially on virtual machine) and you have to collect the time when it occur this command line can be helpful for you.<br />
<br />
<pre>ping host | perl -nle 'BEGIN {$|++} print scalar(localtime), " ", $_' > outputfile
</pre>
<br />
Source: <a href="http://stackoverflow.com/questions/10679807/how-to-timestamp-every-ping-result">http://stackoverflow.com/questions/10679807/how-to-timestamp-every-ping-result</a>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-17231233314425785312016-10-28T23:30:00.001+02:002016-10-28T23:31:19.183+02:00httpie - http for everyone!The life for a web app developer it's so difficult without a real tool for test HTTP request/response, in particular with xhr ajax near-realtime apps.<br />
<br />
HTTPie - aitch-tee-tee-pie - (<a href="http://httpie.org/">httpie.org</a>) is an open source CLI HTTP client that will make you smile: a user-friendly curl alternative that provides a simple http command designed for painless debugging and interaction with HTTP servers, RESTful APIs, and web services.<br />
<br />
For example, it's very simple to make a simple GET request with only one parameter:<br />
<br />
<pre># http httpbin.org/ip</pre>
<br />
It's available on multiplatform (Linux, Windows, MacOS X) and it's well documented.<br />
<br />
So, what else ? Go to documentation, read all and make your http request easy!<br />
<br />Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-85425985169444469952016-02-04T09:06:00.001+01:002016-02-04T09:26:13.220+01:00Windows Shortcuts<b>General</b><br />
<br />
<ul>
<li><b>Win+Up</b> Maximize</li>
<li><b>Win+Down</b> Restore / Minimize</li>
<li><b>Win+Left</b> Snap to left</li>
<li><b>Win+Right</b> Snap to right</li>
<li><b>Win+Shift+Left</b> Jump to left monitor</li>
<li><b>Win+Shift+Right </b>Jump to right monitor</li>
<li><b>Win+Home</b> Minimize / Restore all other windows</li>
<li><b>Win+T</b> Focus the first taskbar entry (Pressing again will cycle through them, you can can arrow around.)</li>
<li><b>Win+Shift+T</b> cycles backwards.</li>
<li><b>Win+Space</b> Peek at the desktop</li>
<li><b>Win+P</b> External display options (mirror, extend desktop, etc)</li>
<li><b>Win+#</b> (# = a number key) Launches a new instance of the application in the Nth slot on the taskbar. Example: Win+1 launches first pinned app, Win+2 launches second, etc.</li>
<li><b>Win + +</b> and <b>Win + – </b>(plus or minus key) Zoom in or out.</li>
</ul>
<br />
<b>Explorer</b><br />
<br />
<ul>
<li><b>Alt+P</b> Show/hide Preview Pane</li>
</ul>
<br />
<br />
<b>Taskbar modifiers</b><br />
<br />
<ul>
<li><b>Shift + Click</b> on icon Open a new instance</li>
<li><b>Middle click</b> on icon Open a new instance</li>
<li><b>Ctrl + Shift + Click</b> on icon Open a new instance with Admin privileges</li>
<li><b>Shift + Right-click</b> on icon Show window menu (Restore / Minimize / Move / etc) Note: Normally you can just right-click on the window thumbnail to get this menu</li>
<li><b>Shift + Right-click</b> on grouped icon Menu with Restore All / Minimize All / Close All, etc.</li>
<li><b>Ctrl + Click</b> on grouped icon Cycle between the windows (or tabs) in the group</li>
</ul>
<br />
<br />
<br />Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-73131750775038981812016-01-23T10:15:00.000+01:002020-03-12T16:15:47.357+01:00How to get the sizes of the tables of a mysql database<p>If you have a very big database with a lot of tables and you want to know which tables use more spaces, run the following query replacing %DB_NAME% with your database and %TABLE_NAME% if you know the table name.</p><pre><code class="sql">
SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`,
round((data_length / 1024 /1024), 2 ) `Data Length in MB` ,
round((index_length / 1024 /1024), 2) `Index Length in MB` ,
round(data_free / 1024 /1024, 2) `Free space in MB`
FROM information_schema.TABLES
where round(data_free/1024/1024) > 500
AND table_schema = "$DB_NAME"
AND table_name = "$TABLE_NAME";
</code></pre><br />
<br />
Ref: <a href="http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database">http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database</a>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-52097264548934124312015-12-22T10:14:00.001+01:002020-09-22T11:18:47.513+02:00Grep Quick Reference<h3>Basic grep usage</h3><br/>
<br/>
<dl>
<dt>Get lines which does not begin with "#" or ";"?</dt>
<dd>
<pre><code code class="bash">grep "^[^#;]" /path/to/my/file </code></pre>
</dd>
</dl>
<dl>
<dt>Search recursively through single file extension</dt>
<dd>
<pre><code code class="bash">grep -r --include=<pattern> <string> <directory></code></pre>
</dd>
</dl>
<dl>
<dt>Print two line after and before the match.</dt>
<dd>
<pre><code code class="bash">grep -A 2 -B 2 "pattern" /path/to/my/file"</code></pre>
</dd>
</dl>
<dl>
<dt>Print the file name for each match</dt>
<dd>
<pre><code code class="bash">grep -H word /path/to/file</code></pre>
</dd>
</dl>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-14436094700835729352015-12-22T09:57:00.003+01:002015-12-22T09:58:18.247+01:00Download Oracle JDK with single command<br />
<p>Today I want to show you how to download JDK with one single command. Yes, because if you want to get java from oracle web site you have to accept license before start the download.</p><br />
<p>If you want to don't want to use browser and you have to get it from command line you can use</p><br />
<pre># curl -LO ${URL} -H "Cookie: oraclelicense=accept-securebackup-cookie" </pre><br />
<p>where {URL} can be:</p><br />
<ul><li>http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz for JDK 8</li>
<li>http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz for JDK 7</li>
</ul><br />
<br />
<br />
<br />
<br />
<br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-68751993366252314932015-12-09T18:01:00.000+01:002017-08-29T12:40:13.666+02:00How to securely connect to IMAP using OpenSSL<p>I never knew how to connect to an IMAP server when SSL/TLS were forced. With unencrypted connections, you can just Telnet in, but this exposes your login credentials and data, so many servers will not allow that. The secure equivalent to Telnet, I found, is OpenSSL's <i>s_client</i> tool. The documentation clearly labels it as a debug tool.<br />
</p><p>You'd resort to either connection method for verification or troubleshooting purposes; I can't imagine anyone wanting to do employ Telnet or s_client regularly — rather than use some mail client.</p><br />
<p>As an example, here's how you could log into an Exchange account, select the <b>Inbox</b> folder, and log out:</p><br />
<pre># openssl s_client -connect server:port -crlf
? LOGIN username password
? SELECT Inbox
? LOGOUT
</pre>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-22401388606028511032015-11-12T12:53:00.001+01:002015-11-12T12:53:30.083+01:00How to generate and send an time stamp request ?Hi,<br />
<br />
today the problem is how to generate and send a time stamp request to a Time Stamp Authority (TSA).<br />
<br />
For this quick guide I use free time stamp service (limited to 5 timestamps per day and IP) available on <a href="https://tsa.safecreative.org/">https://tsa.safecreative.org/</a><br />
<br />
Alright, cut the chatter, men. Enjoy!<br />
<br />
First we have to create the file you will want to timestamp:<br />
<br />
<pre># echo "This is the content of test file." > inputfile.txt
</pre><br />
Then generate a timestamp request that we want to sign:<br />
<br />
<pre># openssl ts -query -data inputfile.txt -cert -sha256 -no_nonce -out request.tsq
</pre><br />
Then send the request to timestamp server<br />
<br />
<pre># curl -k -H "Content-Type: application/timestamp-query" --data-binary @request.tsq "https://tsa.safecreative.org/" > inputfile.txt.tsr
</pre><br />
If all it's fine the content of inputfile.txt.tsr is the response of your request.<br />
<br />
If you want to verify the content you can do:<br />
<br />
<br />
<pre># curl -k -H "Content-Type: application/timestamp-query" --data-binary @request.tsq "https://tsa.safecreative.org/" > inputfile.txt.tsr
</pre><br />
<br />
<br />
<br />
<br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-12926834976275256542015-11-11T10:27:00.002+01:002015-11-11T10:27:52.472+01:00How to change editor for for crontab fileIf you want to specify an editor, when opening crontab file. And not just use the default for your system. You need to use VISUAL environment variable.<br />
<br />
Export the value of VISUAL and then run crontab -e command.<br />
<br />
<pre># export VISUAL=nano; crontab -e
</pre><br />
Of course you need to have vim or nano installed in your system if you want to use them.Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-40337393225756984752015-10-14T11:27:00.003+02:002015-10-14T11:28:24.573+02:00How to analyze long output of a MySQL query?Using MySQL in command line mode can be a problem when you have to analyze query result that have long lines.<br />
<br />
If you use Linux for you can set the <a href="https://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html#option_mysql_pager">pager</a> option of mysqlclient <br />
<br />
<pre>mysql> pager less -n -i -S
</pre><br />
If you want to make it permanently you can setup your my.cnf with this:<br />
<br />
<pre>[client]
pager = less -n -i -S
</pre><br />
Ref: <a href="http://stackoverflow.com/questions/4285664/how-to-adjust-display-settings-of-mysql-command-line">http://stackoverflow.com/questions/4285664/how-to-adjust-display-settings-of-mysql-command-line</a>Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0tag:blogger.com,1999:blog-9908146.post-9922465642228520302015-09-30T14:15:00.000+02:002015-09-30T14:15:11.734+02:00Ceph Quick ReferenceIn this post you can found a lot of helpful commands that you can use with Ceph.<br />
<br />
<h3>RBD</h3><br />
<dl><dt><b>sudo rbd map disk_name --pool pool_name</b></dt>
<dd>Map the image to a block device.</dd>
<dt><b>sudo rbd unmap /dev/rbd/pool_name/disk_name </b></dt>
<dd>Unmap the image to a block device.</dd>
</dl><br />
<br />
Salvo Rapisardahttp://www.blogger.com/profile/10306713103049047456noreply@blogger.com0