venerdì, marzo 16, 2018

Git Handbook

How to setup git with SSH Key

# git remote set-url origin git@github.com:<Username>/<Project>.git

Windows CRLF chars.

Su windows bisogna disattivare questa funziona altrimenti non funzionano i caratteri CRLF.
# git config core.autocrlf false

How can I debug git/git-shell related problems?

If you have problem with Git and you need to debug you can run this:

# GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull
Ref: https://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems

How to get list of files between change log ?

If you need to get list of files (included directory tree) from change list you can use:

# git diff-tree -r --name-only 2c636a^ 5b47402 | xargs -I {} rsync -aR {} output/

Delete files from git index when they are already deleted

# git ls-files --deleted -z | xargs -0 git rm


How do I show my global git config?

# git config --list


Show remote branches

# git branch -vr

venerdì, marzo 02, 2018

How to improve reading of log files

There 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.

I've found two tools:

  • Generic Colouriser (GRC)https://github.com/garabik/grc - there are programs: grc and grcat. The main is grcat, 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. 
  • Log File Navigator (LNAV)http://lnav.org/ - 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. 

martedì, agosto 29, 2017

How 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.
I found the answer on ServerFault (link).

# openssl crl2pkcs7 -nocrl -certfile bundle.crt | openssl pkcs7 -print_certs -text -noout



lunedì, marzo 06, 2017

martedì, dicembre 27, 2016

Ping host and log output with timestamp

If 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.

ping host | perl -nle 'BEGIN {$|++} print scalar(localtime), " ", $_' > outputfile

Source: http://stackoverflow.com/questions/10679807/how-to-timestamp-every-ping-result

venerdì, ottobre 28, 2016

httpie - 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.

HTTPie - aitch-tee-tee-pie - (httpie.org) 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.

For example, it's very simple to make a simple GET request with only one parameter:

# http httpbin.org/ip

It's available on multiplatform (Linux, Windows, MacOS X) and it's well documented.

So, what else ? Go to documentation, read all and make your http request easy!

giovedì, febbraio 04, 2016

Windows Shortcuts

General

  • Win+Up Maximize
  • Win+Down Restore / Minimize
  • Win+Left Snap to left
  • Win+Right Snap to right
  • Win+Shift+Left Jump to left monitor
  • Win+Shift+Right Jump to right monitor
  • Win+Home Minimize / Restore all other windows
  • Win+T Focus the first taskbar entry (Pressing again will cycle through them, you can can arrow around.)
  • Win+Shift+T cycles backwards.
  • Win+Space Peek at the desktop
  • Win+P External display options (mirror, extend desktop, etc)
  • Win+# (# = 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.
  • Win + + and Win + – (plus or minus key) Zoom in or out.

Explorer

  • Alt+P Show/hide Preview Pane


Taskbar modifiers

  • Shift + Click on icon Open a new instance
  • Middle click on icon Open a new instance
  • Ctrl + Shift + Click on icon Open a new instance with Admin privileges
  • Shift + Right-click on icon Show window menu (Restore / Minimize / Move / etc) Note: Normally you can just right-click on the window thumbnail to get this menu
  • Shift + Right-click on grouped icon Menu with Restore All / Minimize All / Close All, etc.
  • Ctrl + Click on grouped icon Cycle between the windows (or tabs) in the group



sabato, gennaio 23, 2016

How to get the sizes of the tables of a mysql database

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.

SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
WHERE table_schema = "$DB_NAME"
    AND table_name = "$TABLE_NAME";


Ref: http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database

martedì, dicembre 22, 2015

Grep Quick Reference

Basic grep usage



Get lines which does not begin with "#" or ";"?
# grep "^[^#;]" /path/to/my/file 
Search recursively through single file extension
# grep -r --include=<pattern> <string> <directory>
Print two line after and before the match.
# grep -A 2 -B 2 "pattern" /path/to/my/file"

Download Oracle JDK with single command


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.


If you want to don't want to use browser and you have to get it from command line you can use


# curl -LO ${URL} -H "Cookie: oraclelicense=accept-securebackup-cookie" 

where {URL} can be:


  • http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz for JDK 8
  • http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz for JDK 7