venerdì 8 dicembre 2017

Can you store password in Putty sessions?

The short answer is no. But you have a workaround that can help you to reach the same result: a one-click Putty shortcut to your server from your desktop.
That's the issue of this article.

Here is how to do:

  1. Create on the desktop a shortcut to Putty.exe
  2. Right click on the shortcut, select "properties" and edit the target attribute
  3. Change
    "C:\ProgramFiles\putty.exe"
    in
    "C:\ProgramFiles\putty.exe" root@207.150.12.233 -pw YourPassword
    where
    "C:\ProgramFiles\putty.exe" is the correct path of your putty.exe file
    "root" to the user you would use to login to your remote server
    "207.150.12.233" is the remote server IP
    "YourPassword" is the correct password.
  4. Click "Apply" then "OK" to commit the change.

Now simply double-click on your new shortcut and you'll be logged on your server.

domenica 26 novembre 2017

Eloquent collections methods

The Eloquent ORM provides a beautiful, simple ActiveRecord implementation for working with your database.
The results of Eloquent queries are always returned as Collection instances and Eloquent has a list of methods to work with Collections.

Here it is an interesting article about 10 less-known Eloquent collections methods:
avg()
chunk()
contains()
every()
filter()
forget()
implode()
keyBy()
map()
plunk()

Howto preview sql query code generated in Eloquent

The simplest method to show the query generated by Eloquent is by utilizing a ->toSql() method.
We only need to replace the closing ->get() with ->toSql() and then print out the results with dd() or die() funnction.

Here is an example:

    
    $users = DB::table('users')
        ->where('email', 'x@y.xxx')
        ->where('is_active', true)
        ->toSql();
//        ->get();
    dd($users);

This is the output:

"select * from `users` where `name` = ? and `is_active` = ?"

A little more complex and complete way is to enable and use the QueryLog method.

Here the example:

    DB::enableQueryLog();
    $users = DB::table('users')
    ->where('email', 'x@y.xxx')
    ->get();

    dd(DB::getQueryLog());

This is the output:

array:1 [
  0 => array:3 [
    "query" => "select * from `users` where `email` = ?"
    "bindings" => array:1 [
      0 => "x@y.xxx"
    ]
    "time" => 61.13
  ]
]

domenica 12 novembre 2017

Linux commands and tools for networking and sysadmin

I 20 comandi indispensabili per un amministratore di sistema.
20 Linux commands every sysadmin should know

Comandi e tools linux interessanti per il networking.
https://itsubuntu.com/linux-networking-commands-and-scripts/

lunedì 17 luglio 2017

Ricerca in VIM

Comandi per ricercare una stringa in un file con l'editor VIM:

/ + ENTER

Per passare all'occorrenza successiva premere "n"
Per passare all'occorrenza precedente premere "N"