export SSLKEYLOGFILE=/home/jsn/Downloads/sslkeys/sslkeys.log
search
Wednesday, September 14, 2016
Analyze http2 with Wireshark
Most of the time http2 requests are sent over TLS, which means that Wireshark needs to decrypt information before we can analyze it.
Fortunately, Chrome allows to dump cryptographic keys in the file. To do that, before you start Chrome, export environmental variable SSLKEYLOGFILE:
Firefox also allows to do it, but as for now (48) it is disabled by default. Get more information
Now we need to configure Wireshark to use exported keys. Go to Edit - Preferences - Protocols - SSL and point (Pre)-Master-Secret log filename to the file with keys (/home/jsn/Downloads/sslkeys/sslkeys.log)
Now you can filter records by http2 and analyze them.
Wednesday, August 24, 2016
tar: Archives cheatsheet
Create archive:
Extract files:
tar -czvf compressed_file.tar.gz original_file.sql
tar -xzvf compressed_file.tar.gz
Tuesday, August 2, 2016
Number of connections to the specific port
To check how many connections are exists to the port 3306:
watch -n 1 "sudo netstat -anp | grep 3306 | wc -l"
Monday, June 27, 2016
fedora: Increase watches limit
Open configuration file:
Add the following line to the end of the file to increase watches limit:
sudo vim /etc/sysctl.d/90-override.conf
fs.inotify.max_user_watches = 524288
Saturday, June 25, 2016
postgresql: How to fix ERROR: new encoding (UTF8) is incompatible
Sometimes I'm unable to create a database in UTF8 encoding because the template database is in the ASCII encoding. To fix it we need to recreate template database in UTF8.
Start psql console:
Run the following commands:
psql -U postgres
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1
VACUUM FREEZE;
Tuesday, May 31, 2016
Preview apiary.io docs
It is possible to preview apiary docs before pushing to the repository. To do that, install apiaryio CLI:
The executable file of the installed application is located somewhere there:
Generate html file to preview docs and open it in the browser:
gem install apiaryio
/home/jsn/.gem/ruby/gems/apiaryio-0.3.3/bin/apiary
/home/jsn/.gem/ruby/gems/apiaryio-0.3.3/bin/apiary preview --output="preview.html"
Friday, May 13, 2016
fedora: Install HipChat 4
UPDATED: Atlassian team has a rpm repository which they do not mention on the official download page. To install hipchat4 from it, create a repository file:
Install alien package which will convert deb package to the rpm package:
Convert hipchat debian package to rpm package:
Install hipchat:
sudo gedit /etc/yum.repos.d/hipchat4.repoWith the following content:
[atlassian-hipchat4] name=Atlassian Hipchat4 baseurl=https://atlassian.artifactoryonline.com/atlassian/hipchat-yum-client/ enabled=1 gpgcheck=0Install hipchat:
sudo dnf install hipchat4 --refresh----- Atlassian team wasn't able to release rpm package for the latest hipchat for more than 2 months. Fortunately, it is possible to intsall hipchat from the debian package. Download the latest available debian package from here.
Install alien package which will convert deb package to the rpm package:
sudo dnf install alien
sudo alien HipChat4-4.0.1635-Linux.deb -r
sudo dnf install hipchat4-4.0.1635-2.x86_64.rpm
fedora: X11 forwarding issue
Here I have a nice post how to open browser window on the remote machine. On fedora 23 that method stopped to work. It was possible to start simple application like xclock, but firefox or chrome.
The problem is in the xorg-x11-drv-intel package. The latest version which is available in the official fedora repo is xorg-x11-drv-intel-2.99.917-19.20151206.fc23 (as for 13 May 2016). Downgrading the package to the previous version fixes the issue.
The latest version of the package which is known to work is xorg-x11-drv-intel-2.99.917-19.20151206.fc23. Let's install it:
It would be also nice to lock the package version, so the next time you start updating the system it won't be updated:
The problem is in the xorg-x11-drv-intel package. The latest version which is available in the official fedora repo is xorg-x11-drv-intel-2.99.917-19.20151206.fc23 (as for 13 May 2016). Downgrading the package to the previous version fixes the issue.
The latest version of the package which is known to work is xorg-x11-drv-intel-2.99.917-19.20151206.fc23. Let's install it:
sudo dnf install xorg-x11-drv-intel-2.99.917-16.20150729.fc23.x86_64
sudo dnf install 'dnf-command(versionlock)'
sudo dnf versionlock add xorg-x11-drv-intel
Monday, May 2, 2016
How to format USB stick as FAT32
First step is to find the name of the USB stick in the system:
In my case the name of the device is /dev/sdc
If the USB stick is mounted, unmount it with command:
Finally, run the command to format USB stick:
sudo fdisk -l
sudo umount /dev/sdc
mkdosfs -F 32 -I /dev/sdc
Monday, April 18, 2016
apt-get: Install package with specific version and hold it on the next upgrade
If you need to install specific version of the package in your system, you can list all available package versions with the command:
After you know the package version you can install it with:
To hold the package on the selected version during the next upgrade:
You can also "unhold it" with:
apt-cache madison varnish
sudo apt-get install varnish=4.0.2-1
sudo apt-mark hold varnish
sudo apt-mark unhold varnish
Sunday, March 13, 2016
fedora: Install accidentally removed sqlite package
If sqlite package (or, for example, sqlite-libs package) was accidentally removed from your system, you can't reinstall it using dnf or yum because they depend on it.
To fix this problem, download missing rpm package from https://admin.fedoraproject.org/pkgdb/package/rpms/sqlite/.
From the downloaded file location, run command:
It will create usr folder with extracted files. Run next command to copy them to the right location:
Pay attention to the package architecture.
You should be able to use dnf again. It would be good to reinstall missed package with dnf again:
rpm2cpio sqlite-libs-3.11.0-3.fc23.x86_64.rpm | cpio -idmv
sudo cp -R usr/ /
sudo dnf --best --allowerasing install sqlite-libs
Thursday, February 18, 2016
Set up logging with Flask and gunicorn
Let's say that we want to be able to log in the specified log file and syslog. Our application - is a simple app.py file.
The first step, I suggest, is to set logger name:
You can log in your project like this:
A log configuration file for the gunicorn may look something like this:
The last step is starting gunicorn:
import os
from flask import Flask
app = Flask(__name__)
app.logger_name = "flask.app"
# ...
if __name__ == "__main__":
app.run()
app.logger.info("Hello")
[loggers]
keys=root, gunicorn.error, gunicorn.access, requests.packages.urllib3.connectionpool, __main__
[handlers]
keys=log_file, syslog
[formatters]
keys=generic
[logger_root]
level=INFO
handlers=log_file, syslog
[logger___main__]
level=DEBUG
handlers=log_file, syslog
propagate=0
qualname=__main__
[logger_gunicorn.error]
level=INFO
handlers=log_file, syslog
propagate=0
qualname=gunicorn.error
[logger_gunicorn.access]
level=INFO
handlers=log_file, syslog
propagate=0
qualname=gunicorn.access
[logger_requests.packages.urllib3.connectionpool]
level=WARN
handlers=log_file, syslog
propagate=0
qualname=requests.packages.urllib3.connectionpool
[handler_syslog]
class=logging.handlers.SysLogHandler
formatter=generic
args=()
[handler_log_file]
class=logging.FileHandler
formatter=generic
args=('/home/myuser/log/gunicorn.log',)
[formatter_generic]
format=%(asctime)s [%(process)d:%(name)s:%(lineno)s] [%(levelname)s] %(message)s
datefmt=%Y-%m-%d %H:%M:%S
class=logging.Formatter
gunicorn app:app --log-config /home/myuser/gunicorn_logging.conf
Conditions in the Vagrantfile
Every developer could have different hardware configuration. Let's say one is ready to provision a virtual machine with 4 cpus and another - only with 2 cpus. It would be nice to handle this situation with environmental variables:
With that config the number of the provisioned cpus can be controled via VAGRANT_CPUS environmental variable.
Vagrant.configure(2) do |config|
config.vm.box = "box-cutter/debian81"
config.vm.network "private_network", ip: "192.168.33.10"
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
if ENV.has_key?('VAGRANT_CPUS')
vb.cpus = ENV['VAGRANT_CPUS']
else
vb.cpus = "2"
end
end
end
Gnome: How to record a screencast
Gnome 3 has in-built screencast functionality. To start record your screen simply press
Ctrl + Shift + Alt + RThe indicator (a red circle) will appear in the panel, informing you that the recording has started. Default video length is limited to 30s, what might be not enough in most cases. To adjust this parameter install dconf Editor and go to the:
org.gnome.settings-daemon.plugins.media-keysAnd look for max-screencast-length to adjust.
Tuesday, January 26, 2016
komodo: Use custom version of the jshint
Komodo has an outdated version of the jshint. If you want to use, for example, moz:true option, you need to upgrade it. I tried it multiple times and never succeed. The problem was not in komodo (at least that was the developers say) but in jshint. All latest versions of the jshint does not work with komodo. The latest version of the jshint that is known to work with komodo is 2.6.0.
To configure komodo to use jshint 2.6.0, open File -> Preferences -> Syntax Checking -> Language: Javascript and point Custom linter to the downloaded file:
The version 2.6.0 is somewhere from the early 2015 but still much better then the default one.
Subscribe to:
Posts (Atom)